use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto in project mapstruct by mapstruct.
the class CarMapperTest method shouldMapEnumToString.
@ProcessorTest
public void shouldMapEnumToString() {
// given
Car car = new Car();
car.setCategory(Category.CONVERTIBLE);
// when
CarDto carDto = CarMapper.INSTANCE.carToCarDto(car);
// then
assertThat(carDto).isNotNull();
assertThat(carDto.getCategory()).isEqualTo("CONVERTIBLE");
}
use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto in project mapstruct by mapstruct.
the class CarMapperTest method shouldMapIterable.
@ProcessorTest
public void shouldMapIterable() {
// given
Car car1 = new Car("Morris", 2, new GregorianCalendar(1980, Calendar.JANUARY, 1).getTime(), new Person("Bob"), new ArrayList<>());
Car car2 = new Car("Railton", 4, new GregorianCalendar(1934, Calendar.JANUARY, 1).getTime(), new Person("Bill"), new ArrayList<>());
// when
List<CarDto> dtos = CarMapper.INSTANCE.carsToCarDtos(Arrays.asList(car1, car2));
// then
assertThat(dtos).isNotNull();
assertThat(dtos).hasSize(2);
assertThat(dtos.get(0).getMake()).isEqualTo("Morris");
assertThat(dtos.get(0).getSeatCount()).isEqualTo(2);
assertThat(dtos.get(0).getManufacturingYear()).isEqualTo("1980");
assertThat(dtos.get(0).getDriver().getName()).isEqualTo("Bob");
assertThat(dtos.get(1).getMake()).isEqualTo("Railton");
assertThat(dtos.get(1).getSeatCount()).isEqualTo(4);
assertThat(dtos.get(1).getManufacturingYear()).isEqualTo("1934");
assertThat(dtos.get(1).getDriver().getName()).isEqualTo("Bill");
}
use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto in project mapstruct by mapstruct.
the class CarMapperTest method shouldApplyConverter.
@ProcessorTest
public void shouldApplyConverter() {
// 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.getManufacturingYear()).isEqualTo("1980");
}
use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto in project mapstruct by mapstruct.
the class CarMapperTest method shouldMapAttributeByName.
@ProcessorTest
public void shouldMapAttributeByName() {
// 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.getMake()).isEqualTo(car.getMake());
}
use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto in project mapstruct by mapstruct.
the class CarMapperTest method shouldMapStringToEnum.
@ProcessorTest
public void shouldMapStringToEnum() {
// given
CarDto carDto = new CarDto();
carDto.setCategory("CONVERTIBLE");
// when
Car car = CarMapper.INSTANCE.carDtoToCar(carDto);
// then
assertThat(car).isNotNull();
assertThat(car.getCategory()).isEqualTo(Category.CONVERTIBLE);
}
Aggregations