use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.
the class NamedTest method testFactorySelectionWithQualifier.
@ProcessorTest
@WithClasses({ MovieFactoryMapper.class, ReleaseFactory.class, CreateGermanRelease.class })
@IssueKey("342")
public void testFactorySelectionWithQualifier() {
OriginalRelease foreignMovies = new OriginalRelease();
foreignMovies.setTitle("Sixth Sense, The");
foreignMovies.setKeyWords(Arrays.asList("evergreen", "magnificent"));
Map<String, List<String>> facts = new HashMap<>();
facts.put("director", Arrays.asList("M. Night Shyamalan"));
facts.put("cast", Arrays.asList("Bruce Willis", "Haley Joel Osment", "Toni Collette"));
facts.put("plot keywords", Arrays.asList("boy", "child psychologist", "I see dead people"));
foreignMovies.setFacts(facts);
AbstractEntry abstractEntry = MovieFactoryMapper.INSTANCE.toGerman(foreignMovies);
assertThat(abstractEntry).isNotNull();
assertThat(abstractEntry).isInstanceOf(GermanRelease.class);
assertThat(abstractEntry.getTitle()).isEqualTo("Sixth Sense, The");
assertThat(abstractEntry.getKeyWords()).isNotNull();
assertThat(abstractEntry.getKeyWords().size()).isEqualTo(2);
assertThat(abstractEntry.getKeyWords()).containsSequence("evergreen", "magnificent");
assertThat(abstractEntry.getFacts()).isNotNull();
assertThat(abstractEntry.getFacts()).hasSize(3);
assertThat(abstractEntry.getFacts()).contains(entry("director", Arrays.asList("M. Night Shyamalan")), entry("cast", Arrays.asList("Bruce Willis", "Haley Joel Osment", "Toni Collette")), entry("plot keywords", Arrays.asList("boy", "child psychologist", "I see dead people")));
}
use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.
the class InnerClassesImportsTest method mapperRequiresInnerClassImports.
@ProcessorTest
@IssueKey("412")
public void mapperRequiresInnerClassImports() {
SourceWithInnerClass source = new SourceWithInnerClass();
source.setInnerClassMember(new SourceInnerClass(412));
TargetWithInnerClass target = InnerClassMapper.INSTANCE.sourceToTarget(source);
assertThat(target).isNotNull();
assertThat(target.getInnerClassMember().getValue()).isEqualTo(412);
generatedSource.addComparisonToFixtureFor(InnerClassMapper.class);
}
use of org.mapstruct.ap.testutil.IssueKey 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.IssueKey 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.IssueKey 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);
}
Aggregations