use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class InnerClassesImportsTest method mapperRequiresInnerInnerClassImports.
@ProcessorTest
@IssueKey("412")
public void mapperRequiresInnerInnerClassImports() {
SourceInnerClass source = new SourceInnerClass();
source.setValue(412);
TargetInnerInnerClass target = InnerClassMapper.INSTANCE.innerSourceToInnerInnerTarget(source);
assertThat(target).isNotNull();
assertThat(target.getValue()).isEqualTo(412);
generatedSource.addComparisonToFixtureFor(InnerClassMapper.class);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class InnerClassesImportsTest method mapperRequiresInnerEnumImports.
@ProcessorTest
@IssueKey("209")
public void mapperRequiresInnerEnumImports() {
BeanWithInnerEnum source = new BeanWithInnerEnum();
source.setTest("whatever");
source.setInnerEnum(InnerEnum.A);
BeanFacade target = BeanWithInnerEnumMapper.INSTANCE.toFacade(source);
assertThat(target).isNotNull();
assertThat(target.getInnerEnum()).isEqualTo("A");
BeanWithInnerEnum sourceAgain = BeanWithInnerEnumMapper.INSTANCE.fromFacade(target);
assertThat(sourceAgain).isNotNull();
assertThat(sourceAgain.getInnerEnum()).isEqualTo(InnerEnum.A);
generatedSource.addComparisonToFixtureFor(BeanWithInnerEnumMapper.class);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class InheritedMappingMethodTest method shouldMapUsingUnboundedInheretedMappingMethod.
@ProcessorTest
public void shouldMapUsingUnboundedInheretedMappingMethod() {
// given
CarDto bikeDto = new CarDto();
bikeDto.setHorsepower(130);
// when
UnboundMappable<CarDto, Car> instance = CarMapper.INSTANCE;
Car bike = instance.from(bikeDto);
// then
assertThat(bike).isNotNull();
assertThat(bike.getHorsepower()).isEqualTo(130);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class SourceTypeContainsCollectionWithExtendsBoundTest method generatesImportsForCollectionWithExtendsBoundInSourceType.
@ProcessorTest
@IssueKey("768")
public void generatesImportsForCollectionWithExtendsBoundInSourceType() {
Astronaut astronaut = new Astronaut();
astronaut.setName("Bob");
Spaceship spaceship = new Spaceship();
spaceship.setAstronauts(Collections.singleton(astronaut));
SpaceshipDto spaceshipDto = SpaceshipMapper.INSTANCE.spaceshipToDto(spaceship);
assertThat(spaceshipDto).isNotNull();
assertThat(spaceshipDto.getAstronauts()).extracting("name").containsOnly("Bob");
generatedSource.forMapper(SpaceshipMapper.class).containsImportFor(Astronaut.class);
generatedSource.forMapper(SpaceshipMapper.class).containsImportFor(Spaceship.class);
generatedSource.forMapper(SpaceshipMapper.class).containsImportFor(AstronautDto.class);
generatedSource.forMapper(SpaceshipMapper.class).containsImportFor(SpaceshipDto.class);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class Issue1799Test method fluentJavaBeanStyleSettersShouldWork.
@ProcessorTest
public void fluentJavaBeanStyleSettersShouldWork() {
Target target = Issue1799Mapper.INSTANCE.map(new Source(new Date(150), "Switzerland"));
assertThat(target.getSettlementDate()).isEqualTo(new Date(150));
assertThat(target.getGetawayLocation()).isEqualTo("Switzerland");
}
Aggregations