use of org.mapstruct.ap.test.array._target.ScientistDto in project mapstruct by mapstruct.
the class ArrayMappingTest method shouldMapArrayToArrayExistingLargerSizedTarget.
@ProcessorTest
public void shouldMapArrayToArrayExistingLargerSizedTarget() {
ScientistDto[] existingTarget = new ScientistDto[] { new ScientistDto("Jim"), new ScientistDto("Bart"), new ScientistDto("John") };
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", "John");
}
use of org.mapstruct.ap.test.array._target.ScientistDto in project mapstruct by mapstruct.
the class ArrayMappingTest method shouldMapArrayToArray.
@ProcessorTest
public void shouldMapArrayToArray() {
ScientistDto[] dtos = ScienceMapper.INSTANCE.scientistsToDtos(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._target.ScientistDto in project mapstruct by mapstruct.
the class ScienceMapperImpl method scientistsToDtos.
@Override
public ScientistDto[] scientistsToDtos(Scientist[] scientists) {
if (scientists == null) {
return null;
}
ScientistDto[] scientistDtoTmp = new ScientistDto[scientists.length];
int i = 0;
for (Scientist scientist : scientists) {
scientistDtoTmp[i] = scientistToDto(scientist);
i++;
}
return scientistDtoTmp;
}
use of org.mapstruct.ap.test.array._target.ScientistDto in project mapstruct by mapstruct.
the class ScienceMapperImpl method scientistsToDtos.
@Override
public ScientistDto[] scientistsToDtos(List<Scientist> scientists) {
if (scientists == null) {
return null;
}
ScientistDto[] scientistDtoTmp = new ScientistDto[scientists.size()];
int i = 0;
for (Scientist scientist : scientists) {
scientistDtoTmp[i] = scientistToDto(scientist);
i++;
}
return scientistDtoTmp;
}
use of org.mapstruct.ap.test.array._target.ScientistDto in project mapstruct by mapstruct.
the class ScienceMapperImpl method scientistToDto.
@Override
public ScientistDto scientistToDto(Scientist scientist) {
if (scientist == null) {
return null;
}
ScientistDto scientistDto = new ScientistDto();
scientistDto.setName(scientist.getName());
String[] publications = scientist.getPublications();
if (publications != null) {
scientistDto.setPublications(Arrays.copyOf(publications, publications.length));
}
scientistDto.setPublicationYears(stringArrayTointArray(scientist.getPublicationYears()));
String[] publicPublications = scientist.publicPublications;
if (publicPublications != null) {
scientistDto.publicPublications = Arrays.copyOf(publicPublications, publicPublications.length);
}
scientistDto.publicPublicationYears = stringArrayTointArray(scientist.publicPublicationYears);
return scientistDto;
}
Aggregations