Search in sources :

Example 6 with Scientist

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");
}
Also used : ScientistDto(org.mapstruct.ap.test.array._target.ScientistDto) Scientist(org.mapstruct.ap.test.array.source.Scientist) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 7 with Scientist

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");
}
Also used : ScientistDto(org.mapstruct.ap.test.array._target.ScientistDto) Scientist(org.mapstruct.ap.test.array.source.Scientist) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 8 with Scientist

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;
}
Also used : Scientist(org.mapstruct.ap.test.array.source.Scientist)

Example 9 with Scientist

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;
}
Also used : ScientistDto(org.mapstruct.ap.test.array._target.ScientistDto) Scientist(org.mapstruct.ap.test.array.source.Scientist)

Example 10 with Scientist

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;
}
Also used : ScientistDto(org.mapstruct.ap.test.array._target.ScientistDto) Scientist(org.mapstruct.ap.test.array.source.Scientist)

Aggregations

Scientist (org.mapstruct.ap.test.array.source.Scientist)10 ScientistDto (org.mapstruct.ap.test.array._target.ScientistDto)9 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)7