use of org.mapstruct.ap.test.constructor.PersonDto in project mapstruct by mapstruct.
the class SimpleDefaultAnnotatedConstructorTest 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"));
PersonWithDefaultAnnotatedConstructor target = SimpleDefaultAnnotatedConstructorMapper.INSTANCE.mapWithExpression(source);
assertThat(target.getName()).isEqualTo("Bob");
assertThat(target.getAge()).isEqualTo(20);
}
use of org.mapstruct.ap.test.constructor.PersonDto in project mapstruct by mapstruct.
the class SimpleConstructorPropertiesTest 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"));
PersonWithConstructorProperties target = SimpleConstructorPropertiesMapper.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.PersonDto in project mapstruct by mapstruct.
the class SimpleConstructorPropertiesTest 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"));
PersonWithConstructorProperties target = SimpleConstructorPropertiesMapper.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.PersonDto in project mapstruct by mapstruct.
the class ConstructorMixedWithSettersTest 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"));
PersonMixed target = ConstructorMixedWithSettersMapper.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.PersonDto in project mapstruct by mapstruct.
the class ConstructorVisibilityTest method shouldUseSinglePublicConstructorAlways.
@ProcessorTest
@WithClasses({ SimpleWithPublicConstructorMapper.class })
public void shouldUseSinglePublicConstructorAlways() {
PersonDto source = new PersonDto();
source.setName("Bob");
source.setAge(30);
SimpleWithPublicConstructorMapper.Person target = SimpleWithPublicConstructorMapper.INSTANCE.map(source);
assertThat(target).isNotNull();
assertThat(target.getName()).isEqualTo("Bob");
assertThat(target.getAge()).isEqualTo(30);
}
Aggregations