mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#2131 Add extra test case
This commit is contained in:
parent
13df6a21bc
commit
082704cc55
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* 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._2131;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.NullValueCheckStrategy;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Filip Hrisafov
|
||||||
|
*/
|
||||||
|
@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
|
||||||
|
public interface Issue2131Mapper {
|
||||||
|
|
||||||
|
Issue2131Mapper INSTANCE = Mappers.getMapper( Issue2131Mapper.class );
|
||||||
|
|
||||||
|
TestDto map(TestModel source);
|
||||||
|
|
||||||
|
class TestModel {
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
public TestModel(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestDto {
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public TestDto(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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._2131;
|
||||||
|
|
||||||
|
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("2131")
|
||||||
|
@RunWith(AnnotationProcessorTestRunner.class)
|
||||||
|
@WithClasses(Issue2131Mapper.class)
|
||||||
|
public class Issue2131Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldCompile() {
|
||||||
|
Issue2131Mapper mapper = Issue2131Mapper.INSTANCE;
|
||||||
|
|
||||||
|
Issue2131Mapper.TestDto target = mapper.map( new Issue2131Mapper.TestModel( "test" ) );
|
||||||
|
|
||||||
|
assertThat( target ).isNotNull();
|
||||||
|
assertThat( target.getName() ).isEqualTo( "test" );
|
||||||
|
|
||||||
|
target = mapper.map( new Issue2131Mapper.TestModel( null ) );
|
||||||
|
assertThat( target ).isNotNull();
|
||||||
|
assertThat( target.getName() ).isNull();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user