use of org.mapstruct.ap.test.constructor.Person in project mapstruct by mapstruct.
the class SimpleConstructorTest method mapWithConstants.
@ProcessorTest
public void mapWithConstants() {
PersonDto source = new PersonDto();
source.setName("Bob");
source.setAge(30);
source.setJob("Software Engineer");
source.setCity("Zurich");
source.setAddress("Plaza 1");
source.setChildren(Arrays.asList("Alice", "Tom"));
Person target = SimpleConstructorMapper.INSTANCE.mapWithConstants(source);
assertThat(target.getName()).isEqualTo("Bob");
assertThat(target.getAge()).isEqualTo(25);
assertThat(target.getJob()).isEqualTo("Software Developer");
assertThat(target.getCity()).isEqualTo("Zurich");
assertThat(target.getAddress()).isEqualTo("Plaza 1");
assertThat(target.getChildren()).containsExactly("Alice", "Tom");
}
use of org.mapstruct.ap.test.constructor.Person in project mapstruct by mapstruct.
the class SimpleConstructorTest method mapDefault.
@ProcessorTest
public void mapDefault() {
PersonDto source = new PersonDto();
source.setName("Bob");
source.setAge(30);
source.setJob("Software Engineer");
source.setCity("Zurich");
source.setAddress("Plaza 1");
source.setChildren(Arrays.asList("Alice", "Tom"));
Person target = SimpleConstructorMapper.INSTANCE.map(source);
assertThat(target.getName()).isEqualTo("Bob");
assertThat(target.getAge()).isEqualTo(30);
assertThat(target.getJob()).isEqualTo("Software Engineer");
assertThat(target.getCity()).isEqualTo("Zurich");
assertThat(target.getAddress()).isEqualTo("Plaza 1");
assertThat(target.getChildren()).containsExactly("Alice", "Tom");
}
use of org.mapstruct.ap.test.constructor.Person in project mapstruct by mapstruct.
the class ManySourceArgumentsConstructorMappingTest method shouldCorrectlyUseDefaultValueForSourceParameters.
@ProcessorTest
public void shouldCorrectlyUseDefaultValueForSourceParameters() {
Person person = ManySourceArgumentsConstructorMapper.INSTANCE.map(null, "Test Valley");
assertThat(person).isNotNull();
assertThat(person.getName()).isEqualTo("Tester");
assertThat(person.getCity()).isEqualTo("Test Valley");
person = ManySourceArgumentsConstructorMapper.INSTANCE.map("Other Tester", null);
assertThat(person).isNotNull();
assertThat(person.getName()).isEqualTo("Other Tester");
assertThat(person.getCity()).isEqualTo("Zurich");
}
use of org.mapstruct.ap.test.constructor.Person in project mapstruct by mapstruct.
the class SimpleConstructorTest method mapWithExpressions.
@ProcessorTest
public void mapWithExpressions() {
PersonDto source = new PersonDto();
source.setName("Bob");
source.setAge(30);
source.setJob("Software Engineer");
source.setCity("Zurich");
source.setAddress("Plaza 1");
source.setChildren(Arrays.asList("Alice", "Tom"));
Person target = SimpleConstructorMapper.INSTANCE.mapWithExpression(source);
assertThat(target.getName()).isEqualTo("Bob");
assertThat(target.getAge()).isEqualTo(20);
assertThat(target.getJob()).isEqualTo("software developer");
assertThat(target.getCity()).isEqualTo("Zurich");
assertThat(target.getAddress()).isEqualTo("Plaza 1");
assertThat(target.getChildren()).containsExactly("Alice", "Tom");
}
Aggregations