use of org.mapstruct.ap.test.array.source.Scientist 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.source.Scientist 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.source.Scientist in project mapstruct by mapstruct.
the class ScienceMapperImpl method scientistsToDtos.
@Override
public ScientistDto[] scientistsToDtos(Scientist[] scientists, ScientistDto[] target) {
if (scientists == null) {
return target;
}
int i = 0;
for (Scientist scientist : scientists) {
if ((i >= target.length) || (i >= scientists.length)) {
break;
}
target[i] = scientistToDto(scientist);
i++;
}
return target;
}
use of org.mapstruct.ap.test.array.source.Scientist 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.source.Scientist 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;
}
Aggregations