use of org.mapstruct.ap.test.complex.source.Person 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.complex.source.Person 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.complex.source.Person 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.complex.source.Person 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.complex.source.Person 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());
}
Aggregations