Search in sources :

Example 6 with Person

use of org.mapstruct.ap.test.complex.source.Person in project mapstruct by mapstruct.

the class CarMapperTest method shouldMapIterableAttribute.

@ProcessorTest
public void shouldMapIterableAttribute() {
    // given
    Car car = new Car("Morris", 2, new GregorianCalendar(1980, Calendar.JANUARY, 1).getTime(), new Person("Bob"), Arrays.asList(new Person("Alice"), new Person("Bill")));
    // when
    CarDto dto = CarMapper.INSTANCE.carToCarDto(car);
    // then
    assertThat(dto).isNotNull();
    assertThat(dto.getPassengers()).hasSize(2);
    assertThat(dto.getPassengers().get(0).getName()).isEqualTo("Alice");
    assertThat(dto.getPassengers().get(1).getName()).isEqualTo("Bill");
}
Also used : Car(org.mapstruct.ap.test.complex.source.Car) GregorianCalendar(java.util.GregorianCalendar) CarDto(org.mapstruct.ap.test.complex._target.CarDto) Person(org.mapstruct.ap.test.complex.source.Person) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Aggregations

GregorianCalendar (java.util.GregorianCalendar)6 CarDto (org.mapstruct.ap.test.complex._target.CarDto)6 Car (org.mapstruct.ap.test.complex.source.Car)6 Person (org.mapstruct.ap.test.complex.source.Person)6 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)6