use of org.mapstruct.ap.test.constructor.PersonDto in project mapstruct by mapstruct.
the class ConstructorVisibilityTest method shouldUseDefaultAnnotatedConstructorAlways.
@ProcessorTest
@WithClasses({ SimpleWithPublicParameterlessConstructorAndDefaultAnnotatedMapper.class })
public void shouldUseDefaultAnnotatedConstructorAlways() {
PersonDto source = new PersonDto();
source.setName("Bob");
source.setAge(30);
SimpleWithPublicParameterlessConstructorAndDefaultAnnotatedMapper.Person target = SimpleWithPublicParameterlessConstructorAndDefaultAnnotatedMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getName()).isEqualTo("Bob");
assertThat(target.getAge()).isEqualTo(30);
}
use of org.mapstruct.ap.test.constructor.PersonDto in project mapstruct by mapstruct.
the class SimpleDefaultAnnotatedConstructorTest 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"));
PersonWithDefaultAnnotatedConstructor target = SimpleDefaultAnnotatedConstructorMapper.INSTANCE.mapWithConstants(source);
assertThat(target.getName()).isEqualTo("Bob");
assertThat(target.getAge()).isEqualTo(25);
}
use of org.mapstruct.ap.test.constructor.PersonDto 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