use of org.mapstruct.ap.test.complex._target.CarDto in project mapstruct by mapstruct.
the class NullValueMappingTest method shouldMapExpressionAndConstantRegardlessNullArg.
@ProcessorTest
public void shouldMapExpressionAndConstantRegardlessNullArg() {
// given
Car car = new Car("Morris", 2);
// when
CarDto carDto1 = CarMapper.INSTANCE.carToCarDto(car);
// then
assertThat(carDto1).isNotNull();
assertThat(carDto1.getMake()).isEqualTo(car.getMake());
assertThat(carDto1.getSeatCount()).isEqualTo(car.getNumberOfSeats());
assertThat(carDto1.getModel()).isEqualTo("ModelT");
assertThat(carDto1.getCatalogId()).isNotEmpty();
// when
CarDto carDto2 = CarMapper.INSTANCE.carToCarDto(null);
// then
assertThat(carDto2).isNotNull();
assertThat(carDto2.getMake()).isNull();
assertThat(carDto2.getSeatCount()).isEqualTo(0);
assertThat(carDto2.getModel()).isEqualTo("ModelT");
assertThat(carDto2.getCatalogId()).isNotEmpty();
}
use of org.mapstruct.ap.test.complex._target.CarDto in project mapstruct by mapstruct.
the class NullValueMappingTest method shouldMapExpressionAndConstantRegardlessNullArgOnMapper.
@ProcessorTest
public void shouldMapExpressionAndConstantRegardlessNullArgOnMapper() {
// when
CarDto carDto = CarMapperSettingOnMapper.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();
}
use of org.mapstruct.ap.test.complex._target.CarDto in project mapstruct by mapstruct.
the class NullValueMappingTest method shouldMapExpressionAndConstantRegardlessNullArgSeveralSources.
@ProcessorTest
public void shouldMapExpressionAndConstantRegardlessNullArgSeveralSources() {
// given
Car car = new Car("Morris", 2);
// when
CarDto carDto1 = CarMapper.INSTANCE.carToCarDto(car, "ModelT");
// then
assertThat(carDto1).isNotNull();
assertThat(carDto1.getMake()).isEqualTo(car.getMake());
assertThat(carDto1.getModel()).isEqualTo("ModelT");
assertThat(carDto1.getSeatCount()).isEqualTo(car.getNumberOfSeats());
assertThat(carDto1.getCatalogId()).isNotEmpty();
// when
CarDto carDto2 = CarMapper.INSTANCE.carToCarDto(null, "ModelT");
// then
assertThat(carDto2).isNotNull();
assertThat(carDto2.getMake()).isNull();
assertThat(carDto2.getSeatCount()).isEqualTo(0);
assertThat(carDto2.getModel()).isEqualTo("ModelT");
assertThat(carDto2.getCatalogId()).isNotEmpty();
}
use of org.mapstruct.ap.test.complex._target.CarDto in project mapstruct by mapstruct.
the class NullValueMappingTest method shouldMapMapWithNullArg.
@ProcessorTest
@SuppressWarnings({ "rawtypes", "unchecked" })
public void shouldMapMapWithNullArg() {
// given
Car car = new Car("Morris", 2);
Map carMap = new HashMap();
carMap.put(1, car);
// when
Map<Integer, CarDto> carDtoMap1 = CarMapper.INSTANCE.carsToCarDtoMap(carMap);
// then
assertThat(carDtoMap1).isNotNull();
assertThat(carDtoMap1.size()).isEqualTo(1);
// when
Map<Integer, CarDto> carDtoMap2 = CarMapper.INSTANCE.carsToCarDtoMap(null);
// then
assertThat(carDtoMap2).isNotNull();
assertThat(carDtoMap2.isEmpty()).isTrue();
}
use of org.mapstruct.ap.test.complex._target.CarDto in project mapstruct by mapstruct.
the class InheritedMappingMethodTest method shouldMapUsingUnboundedInheretedMappingMethod.
@ProcessorTest
public void shouldMapUsingUnboundedInheretedMappingMethod() {
// given
CarDto bikeDto = new CarDto();
bikeDto.setHorsepower(130);
// when
UnboundMappable<CarDto, Car> instance = CarMapper.INSTANCE;
Car bike = instance.from(bikeDto);
// then
assertThat(bike).isNotNull();
assertThat(bike.getHorsepower()).isEqualTo(130);
}
Aggregations