Search in sources :

Example 11 with CarDto

use of org.mapstruct.ap.test.complex._target.CarDto in project mapstruct by mapstruct.

the class NullValueMappingTest method shouldMapExpressionAndConstantRegardlessOfIterableNullArgOnConfig.

@ProcessorTest
public void shouldMapExpressionAndConstantRegardlessOfIterableNullArgOnConfig() {
    // when
    CarDto carDto = CarMapperIterableSettingOnConfig.INSTANCE.carToCarDto(null);
    // then
    assertThat(carDto).isNotNull();
    assertThat(carDto.getMake()).isNull();
    assertThat(carDto.getSeatCount()).isEqualTo(0);
    assertThat(carDto.getModel()).isEqualTo("ModelT");
    assertThat(carDto.getCatalogId()).isNotEmpty();
}
Also used : DriverAndCarDto(org.mapstruct.ap.test.nullvaluemapping._target.DriverAndCarDto) CarDto(org.mapstruct.ap.test.nullvaluemapping._target.CarDto) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 12 with CarDto

use of org.mapstruct.ap.test.complex._target.CarDto in project mapstruct by mapstruct.

the class NullValueMappingTest method shouldMapExpressionAndConstantRegardlessMapNullArgOnMapper.

@ProcessorTest
public void shouldMapExpressionAndConstantRegardlessMapNullArgOnMapper() {
    // when
    CarDto carDto = CarMapperMapSettingOnMapper.INSTANCE.carToCarDto(null);
    // then
    assertThat(carDto).isNotNull();
    assertThat(carDto.getMake()).isNull();
    assertThat(carDto.getSeatCount()).isEqualTo(0);
    assertThat(carDto.getModel()).isEqualTo("ModelT");
    assertThat(carDto.getCatalogId()).isNotEmpty();
}
Also used : DriverAndCarDto(org.mapstruct.ap.test.nullvaluemapping._target.DriverAndCarDto) CarDto(org.mapstruct.ap.test.nullvaluemapping._target.CarDto) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 13 with CarDto

use of org.mapstruct.ap.test.complex._target.CarDto in project mapstruct by mapstruct.

the class NullValueMappingTest method shouldMapExpressionAndConstantRegardlessOfMapNullArgOnConfig.

@ProcessorTest
public void shouldMapExpressionAndConstantRegardlessOfMapNullArgOnConfig() {
    // when
    CarDto carDto = CarMapperMapSettingOnConfig.INSTANCE.carToCarDto(null);
    // then
    assertThat(carDto).isNotNull();
    assertThat(carDto.getMake()).isNull();
    assertThat(carDto.getSeatCount()).isEqualTo(0);
    assertThat(carDto.getModel()).isEqualTo("ModelT");
    assertThat(carDto.getCatalogId()).isNotEmpty();
}
Also used : DriverAndCarDto(org.mapstruct.ap.test.nullvaluemapping._target.DriverAndCarDto) CarDto(org.mapstruct.ap.test.nullvaluemapping._target.CarDto) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 14 with CarDto

use of org.mapstruct.ap.test.complex._target.CarDto in project mapstruct by mapstruct.

the class NullValueMappingTest method shouldMapExpressionAndConstantRegardlessNullArgOnConfig.

@ProcessorTest
public void shouldMapExpressionAndConstantRegardlessNullArgOnConfig() {
    // when
    CarDto carDto = CarMapperSettingOnConfig.INSTANCE.carToCarDto(null);
    // then
    assertThat(carDto).isNotNull();
    assertThat(carDto.getMake()).isNull();
    assertThat(carDto.getSeatCount()).isEqualTo(0);
    assertThat(carDto.getModel()).isEqualTo("ModelT");
    assertThat(carDto.getCatalogId()).isNotEmpty();
}
Also used : DriverAndCarDto(org.mapstruct.ap.test.nullvaluemapping._target.DriverAndCarDto) CarDto(org.mapstruct.ap.test.nullvaluemapping._target.CarDto) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 15 with CarDto

use of org.mapstruct.ap.test.complex._target.CarDto in project mapstruct by mapstruct.

the class CarMapperTest method shouldReverseMapIterableAttribute.

@ProcessorTest
public void shouldReverseMapIterableAttribute() {
    // given
    CarDto carDto = new CarDto("Morris", 2, "1980", new PersonDto("Bob"), Arrays.asList(new PersonDto("Alice"), new PersonDto("Bill")));
    // when
    Car car = CarMapper.INSTANCE.carDtoToCar(carDto);
    // then
    assertThat(car).isNotNull();
    assertThat(car.getPassengers()).hasSize(2);
    assertThat(car.getPassengers().get(0).getName()).isEqualTo("Alice");
    assertThat(car.getPassengers().get(1).getName()).isEqualTo("Bill");
}
Also used : Car(org.mapstruct.ap.test.complex.source.Car) PersonDto(org.mapstruct.ap.test.complex._target.PersonDto) CarDto(org.mapstruct.ap.test.complex._target.CarDto) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Aggregations

ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)24 CarDto (org.mapstruct.ap.test.complex._target.CarDto)13 Car (org.mapstruct.ap.test.complex.source.Car)13 CarDto (org.mapstruct.ap.test.nullvaluemapping._target.CarDto)10 DriverAndCarDto (org.mapstruct.ap.test.nullvaluemapping._target.DriverAndCarDto)10 GregorianCalendar (java.util.GregorianCalendar)8 Person (org.mapstruct.ap.test.complex.source.Person)6 PersonDto (org.mapstruct.ap.test.complex._target.PersonDto)5 Car (org.mapstruct.ap.test.nullvaluemapping.source.Car)4 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CarDto (org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto)1 FastCarDto (org.mapstruct.ap.test.inheritedmappingmethod._target.FastCarDto)1 Car (org.mapstruct.ap.test.inheritedmappingmethod.source.Car)1 FastCar (org.mapstruct.ap.test.inheritedmappingmethod.source.FastCar)1