use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto in project mapstruct by mapstruct.
the class CarMapperTest method shouldReverseMapIterable.
@ProcessorTest
public void shouldReverseMapIterable() {
// given
CarDto car1 = new CarDto("Morris", 2, "1980", new PersonDto("Bob"), new ArrayList<>());
CarDto car2 = new CarDto("Railton", 4, "1934", new PersonDto("Bill"), new ArrayList<>());
// when
List<Car> cars = CarMapper.INSTANCE.carDtosToCars(Arrays.asList(car1, car2));
// then
assertThat(cars).isNotNull();
assertThat(cars).hasSize(2);
assertThat(cars.get(0).getMake()).isEqualTo("Morris");
assertThat(cars.get(0).getNumberOfSeats()).isEqualTo(2);
assertThat(cars.get(0).getManufacturingDate()).isEqualTo(new GregorianCalendar(1980, Calendar.JANUARY, 1).getTime());
assertThat(cars.get(0).getDriver().getName()).isEqualTo("Bob");
assertThat(cars.get(1).getMake()).isEqualTo("Railton");
assertThat(cars.get(1).getNumberOfSeats()).isEqualTo(4);
assertThat(cars.get(1).getManufacturingDate()).isEqualTo(new GregorianCalendar(1934, Calendar.JANUARY, 1).getTime());
assertThat(cars.get(1).getDriver().getName()).isEqualTo("Bill");
}
use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto in project mapstruct by mapstruct.
the class CarMapperTest method shouldConsiderCustomMappingForReverseMapping.
@ProcessorTest
public void shouldConsiderCustomMappingForReverseMapping() {
// given
CarDto carDto = new CarDto("Morris", 2, "1980", new PersonDto("Bob"), new ArrayList<>());
// when
Car car = CarMapper.INSTANCE.carDtoToCar(carDto);
// then
assertThat(car).isNotNull();
assertThat(car.getNumberOfSeats()).isEqualTo(carDto.getSeatCount());
}
use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto in project mapstruct by mapstruct.
the class CarMapperTest method shouldMapReferenceAttribute.
@ProcessorTest
public void shouldMapReferenceAttribute() {
// 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.getDriver()).isNotNull();
assertThat(carDto.getDriver().getName()).isEqualTo("Bob");
}
use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto in project mapstruct by mapstruct.
the class CarMapperTest method shouldReverseMapReferenceAttribute.
@ProcessorTest
public void shouldReverseMapReferenceAttribute() {
// given
CarDto carDto = new CarDto("Morris", 2, "1980", new PersonDto("Bob"), new ArrayList<>());
// when
Car car = CarMapper.INSTANCE.carDtoToCar(carDto);
// then
assertThat(car).isNotNull();
assertThat(car.getDriver()).isNotNull();
assertThat(car.getDriver().getName()).isEqualTo("Bob");
}
use of org.mapstruct.ap.test.inheritedmappingmethod._target.CarDto in project mapstruct by mapstruct.
the class CarMapperTest method shouldApplyConverterForReverseMapping.
@ProcessorTest
public void shouldApplyConverterForReverseMapping() {
// given
CarDto carDto = new CarDto("Morris", 2, "1980", new PersonDto("Bob"), new ArrayList<>());
// when
Car car = CarMapper.INSTANCE.carDtoToCar(carDto);
// then
assertThat(car).isNotNull();
assertThat(car.getManufacturingDate()).isEqualTo(new GregorianCalendar(1980, Calendar.JANUARY, 1).getTime());
}
Aggregations