use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto in project mapstruct by mapstruct.
the class CarMapperTest method shouldMapAttributeWithCustomMapping.
@ProcessorTest
public void shouldMapAttributeWithCustomMapping() {
// given
Car car = new Car("Morris", 2, new GregorianCalendar(1980, Calendar.JANUARY, 1).getTime(), new Person("Bob"), new ArrayList<>());
// when
CarDto carDto = CarMapper.INSTANCE.carToCarDto(car);
// then
assertThat(carDto).isNotNull();
assertThat(carDto.getSeatCount()).isEqualTo(car.getNumberOfSeats());
}
use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto 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");
}
use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto in project mapstruct by mapstruct.
the class NullValueMappingTest method shouldMapIterableWithNullArg.
@ProcessorTest
public void shouldMapIterableWithNullArg() {
// given
Car car = new Car("Morris", 2);
// when
List<CarDto> carDtos1 = CarMapper.INSTANCE.carsToCarDtos(Arrays.asList(car));
// then
assertThat(carDtos1).isNotNull();
assertThat(carDtos1.size()).isEqualTo(1);
// when
List<CarDto> carDtos2 = CarMapper.INSTANCE.carsToCarDtos(null);
// then
assertThat(carDtos2).isNotNull();
assertThat(carDtos2.isEmpty()).isTrue();
}
use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto in project mapstruct by mapstruct.
the class NullValueMappingTest method shouldMapExpressionAndConstantRegardlessOfIterableNullArgOnMapper.
@ProcessorTest
public void shouldMapExpressionAndConstantRegardlessOfIterableNullArgOnMapper() {
// when
CarDto carDto = CarMapperIterableSettingOnMapper.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();
}
Aggregations