Search in sources :

Example 1 with BikeDto

use of org.mapstruct.ap.test.subclassmapping.mappables.BikeDto in project mapstruct by mapstruct.

the class SubclassMappingTest method inverseMappingIsDoneUsingSubclassMapping.

@ProcessorTest
@WithClasses(SimpleSubclassMapper.class)
void inverseMappingIsDoneUsingSubclassMapping() {
    VehicleCollectionDto vehicles = new VehicleCollectionDto();
    vehicles.getVehicles().add(new CarDto());
    vehicles.getVehicles().add(new BikeDto());
    VehicleCollection result = SimpleSubclassMapper.INSTANCE.mapInverse(vehicles);
    assertThat(result.getVehicles()).doesNotContainNull();
    // remove generic so that test works.
    assertThat(result.getVehicles()).extracting(vehicle -> (Class) vehicle.getClass()).containsExactly(Car.class, Bike.class);
}
Also used : HatchBackDto(org.mapstruct.ap.test.subclassmapping.mappables.HatchBackDto) VehicleCollection(org.mapstruct.ap.test.subclassmapping.mappables.VehicleCollection) Bike(org.mapstruct.ap.test.subclassmapping.mappables.Bike) Diagnostic(org.mapstruct.ap.testutil.compilation.annotation.Diagnostic) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HatchBack(org.mapstruct.ap.test.subclassmapping.mappables.HatchBack) VehicleDto(org.mapstruct.ap.test.subclassmapping.mappables.VehicleDto) WithClasses(org.mapstruct.ap.testutil.WithClasses) BikeDto(org.mapstruct.ap.test.subclassmapping.mappables.BikeDto) Vehicle(org.mapstruct.ap.test.subclassmapping.mappables.Vehicle) VehicleCollectionDto(org.mapstruct.ap.test.subclassmapping.mappables.VehicleCollectionDto) IssueKey(org.mapstruct.ap.testutil.IssueKey) CarDto(org.mapstruct.ap.test.subclassmapping.mappables.CarDto) CompilationResult(org.mapstruct.ap.testutil.compilation.annotation.CompilationResult) Car(org.mapstruct.ap.test.subclassmapping.mappables.Car) ExpectedCompilationOutcome(org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome) BikeDto(org.mapstruct.ap.test.subclassmapping.mappables.BikeDto) VehicleCollectionDto(org.mapstruct.ap.test.subclassmapping.mappables.VehicleCollectionDto) CarDto(org.mapstruct.ap.test.subclassmapping.mappables.CarDto) VehicleCollection(org.mapstruct.ap.test.subclassmapping.mappables.VehicleCollection) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Bike (org.mapstruct.ap.test.subclassmapping.mappables.Bike)1 BikeDto (org.mapstruct.ap.test.subclassmapping.mappables.BikeDto)1 Car (org.mapstruct.ap.test.subclassmapping.mappables.Car)1 CarDto (org.mapstruct.ap.test.subclassmapping.mappables.CarDto)1 HatchBack (org.mapstruct.ap.test.subclassmapping.mappables.HatchBack)1 HatchBackDto (org.mapstruct.ap.test.subclassmapping.mappables.HatchBackDto)1 Vehicle (org.mapstruct.ap.test.subclassmapping.mappables.Vehicle)1 VehicleCollection (org.mapstruct.ap.test.subclassmapping.mappables.VehicleCollection)1 VehicleCollectionDto (org.mapstruct.ap.test.subclassmapping.mappables.VehicleCollectionDto)1 VehicleDto (org.mapstruct.ap.test.subclassmapping.mappables.VehicleDto)1 IssueKey (org.mapstruct.ap.testutil.IssueKey)1 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)1 WithClasses (org.mapstruct.ap.testutil.WithClasses)1 CompilationResult (org.mapstruct.ap.testutil.compilation.annotation.CompilationResult)1 Diagnostic (org.mapstruct.ap.testutil.compilation.annotation.Diagnostic)1 ExpectedCompilationOutcome (org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome)1