use of org.mapstruct.ap.test.array.source.Scientist in project mapstruct by mapstruct.
the class ArrayMappingTest method shouldMapArrayToList.
@ProcessorTest
public void shouldMapArrayToList() {
List<ScientistDto> dtos = ScienceMapper.INSTANCE.scientistsToDtosAsList(new Scientist[] { new Scientist("Bob"), new Scientist("Larry") });
assertThat(dtos).isNotNull();
assertThat(dtos).extracting("name").containsOnly("Bob", "Larry");
}
use of org.mapstruct.ap.test.array.source.Scientist in project mapstruct by mapstruct.
the class ArrayMappingTest method shouldMapArrayToArrayExistingSmallerSizedTarget.
@ProcessorTest
public void shouldMapArrayToArrayExistingSmallerSizedTarget() {
ScientistDto[] existingTarget = new ScientistDto[] { new ScientistDto("Jim") };
ScientistDto[] target = ScienceMapper.INSTANCE.scientistsToDtos(new Scientist[] { new Scientist("Bob"), new Scientist("Larry") }, existingTarget);
assertThat(target).isNotNull();
assertThat(target).isEqualTo(existingTarget);
assertThat(target).extracting("name").containsOnly("Bob");
}
use of org.mapstruct.ap.test.array.source.Scientist in project mapstruct by mapstruct.
the class ArrayMappingTest method shouldCopyArraysInBean.
@ProcessorTest
public void shouldCopyArraysInBean() {
Scientist source = new Scientist("Bob");
source.setPublications(new String[] { "the Lancet", "Nature" });
source.publicPublications = new String[] { "public the Lancet", "public Nature" };
ScientistDto dto = ScienceMapper.INSTANCE.scientistToDto(source);
assertThat(dto).isNotNull();
assertThat(dto).isNotEqualTo(source);
assertThat(dto.getPublications()).containsOnly("the Lancet", "Nature");
assertThat(dto.publicPublications).containsOnly("public the Lancet", "public Nature");
}
use of org.mapstruct.ap.test.array.source.Scientist in project mapstruct by mapstruct.
the class ArrayMappingTest method shouldForgeMappingForIntToString.
@ProcessorTest
public void shouldForgeMappingForIntToString() {
Scientist source = new Scientist("Bob");
source.setPublicationYears(new String[] { "1993", "1997" });
source.publicPublicationYears = new String[] { "1994", "1998" };
ScientistDto dto = ScienceMapper.INSTANCE.scientistToDto(source);
assertThat(dto).isNotNull();
assertThat(dto.getPublicationYears()).containsOnly(1993, 1997);
assertThat(dto.publicPublicationYears).containsOnly(1994, 1998);
}
use of org.mapstruct.ap.test.array.source.Scientist in project mapstruct by mapstruct.
the class ArrayMappingTest method shouldMapArrayToArrayExistingEqualSizedTarget.
@ProcessorTest
public void shouldMapArrayToArrayExistingEqualSizedTarget() {
ScientistDto[] existingTarget = new ScientistDto[] { new ScientistDto("Jim"), new ScientistDto("Bart") };
ScientistDto[] target = ScienceMapper.INSTANCE.scientistsToDtos(new Scientist[] { new Scientist("Bob"), new Scientist("Larry") }, existingTarget);
assertThat(target).isNotNull();
assertThat(target).isEqualTo(existingTarget);
assertThat(target).extracting("name").containsOnly("Bob", "Larry");
}
Aggregations