use of org.mapstruct.ap.test.subclassmapping.mappables.Car in project mapstruct by mapstruct.
the class SubclassMappingTest method mappingIsDoneUsingSubclassMapping.
@ProcessorTest
@WithClasses(SimpleSubclassMapper.class)
void mappingIsDoneUsingSubclassMapping() {
VehicleCollection vehicles = new VehicleCollection();
vehicles.getVehicles().add(new Car());
vehicles.getVehicles().add(new Bike());
VehicleCollectionDto result = SimpleSubclassMapper.INSTANCE.map(vehicles);
assertThat(result.getVehicles()).doesNotContainNull();
// remove generic so that test works.
assertThat(result.getVehicles()).extracting(vehicle -> (Class) vehicle.getClass()).containsExactly(CarDto.class, BikeDto.class);
}
use of org.mapstruct.ap.test.subclassmapping.mappables.Car in project mapstruct by mapstruct.
the class SubclassMappingTest method existingMappingsAreUsedWhenFound.
@ProcessorTest
@WithClasses(SubclassMapperUsingExistingMappings.class)
void existingMappingsAreUsedWhenFound() {
VehicleCollection vehicles = new VehicleCollection();
vehicles.getVehicles().add(new Car());
VehicleCollectionDto result = SubclassMapperUsingExistingMappings.INSTANCE.map(vehicles);
assertThat(result.getVehicles()).extracting(VehicleDto::getName).containsExactly("created through existing mapping.");
}
Aggregations