Search in sources :

Example 1 with Scientist

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");
}
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 2 with Scientist

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");
}
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 3 with Scientist

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");
}
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 4 with Scientist

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);
}
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 5 with Scientist

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

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