mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#2121 Add extra test case
This commit is contained in:
parent
29b82e772c
commit
ef3cbc1b36
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._2121;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* @author Filip Hrisafov
|
||||
*/
|
||||
@Mapper
|
||||
public interface Issue2121Mapper {
|
||||
|
||||
Issue2121Mapper INSTANCE = Mappers.getMapper( Issue2121Mapper.class );
|
||||
|
||||
Target map(Source source);
|
||||
|
||||
class Target {
|
||||
|
||||
private final String value;
|
||||
|
||||
public Target(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
class Source {
|
||||
|
||||
private final SourceEnum value;
|
||||
|
||||
public Source(SourceEnum value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public SourceEnum getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
enum SourceEnum {
|
||||
VALUE1,
|
||||
VALUE2
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._2121;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Filip Hrisafov
|
||||
*/
|
||||
@IssueKey("2121")
|
||||
@RunWith(AnnotationProcessorTestRunner.class)
|
||||
@WithClasses(Issue2121Mapper.class)
|
||||
public class Issue2121Test {
|
||||
|
||||
@Test
|
||||
public void shouldCompile() {
|
||||
Issue2121Mapper mapper = Issue2121Mapper.INSTANCE;
|
||||
|
||||
Issue2121Mapper.Target target = mapper.map( new Issue2121Mapper.Source( Issue2121Mapper.SourceEnum.VALUE1 ) );
|
||||
assertThat( target ).isNotNull();
|
||||
assertThat( target.getValue() ).isEqualTo( "VALUE1" );
|
||||
|
||||
target = mapper.map( new Issue2121Mapper.Source( null ) );
|
||||
assertThat( target ).isNotNull();
|
||||
assertThat( target.getValue() ).isNull();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user