Search in sources :

Example 1 with OriginalRelease

use of org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease 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")));
}
Also used : AbstractEntry(org.mapstruct.ap.test.selection.qualifier.bean.AbstractEntry) OriginalRelease(org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease) HashMap(java.util.HashMap) List(java.util.List) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 2 with OriginalRelease

use of org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease in project mapstruct by mapstruct.

the class QualifierTest method shouldNotUseQualifierAnnotatedMethod.

@ProcessorTest
@WithClasses({ MapperWithoutQualifiedBy.class, Facts.class, EnglishToGerman.class, Reverse.class })
@IssueKey("341")
public void shouldNotUseQualifierAnnotatedMethod() {
    OriginalRelease foreignMovies = new OriginalRelease();
    foreignMovies.setTitle("Sixth Sense, The");
    GermanRelease result = MapperWithoutQualifiedBy.INSTANCE.map(foreignMovies);
    assertThat(result).isNotNull();
    assertThat(result.getTitle()).isEqualTo("ehT ,esneS htxiS");
}
Also used : GermanRelease(org.mapstruct.ap.test.selection.qualifier.bean.GermanRelease) CreateGermanRelease(org.mapstruct.ap.test.selection.qualifier.annotation.CreateGermanRelease) OriginalRelease(org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 3 with OriginalRelease

use of org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease in project mapstruct by mapstruct.

the class QualifierTest method shouldMatchClassAndMethod.

@ProcessorTest
@WithClasses({ Titles.class, Facts.class, PlotWords.class, OriginalRelease.class, EnglishToGerman.class, TitleTranslator.class, MovieMapper.class, KeyWordMapper.class, FactMapper.class })
public void shouldMatchClassAndMethod() {
    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);
    GermanRelease germanMovies = MovieMapper.INSTANCE.toGerman(foreignMovies);
    assertThat(germanMovies).isNotNull();
    assertThat(germanMovies.getTitle()).isEqualTo("Der sechste Sinn");
    assertThat(germanMovies.getKeyWords()).isNotNull();
    assertThat(germanMovies.getKeyWords().size()).isEqualTo(2);
    assertThat(germanMovies.getKeyWords()).containsSequence("Evergreen", "Großartig");
    assertThat(germanMovies.getFacts()).isNotNull();
    assertThat(germanMovies.getFacts()).hasSize(3);
    assertThat(germanMovies.getFacts()).contains(entry("Regisseur", Arrays.asList("M. Night Shyamalan")), entry("Besetzung", Arrays.asList("Bruce Willis", "Haley Joel Osment", "Toni Collette")), entry("Handlungstichwörter", Arrays.asList("Jungen", "Kinderpsychologe", "Ich sehe tote Menschen")));
}
Also used : GermanRelease(org.mapstruct.ap.test.selection.qualifier.bean.GermanRelease) CreateGermanRelease(org.mapstruct.ap.test.selection.qualifier.annotation.CreateGermanRelease) OriginalRelease(org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease) HashMap(java.util.HashMap) List(java.util.List) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 4 with OriginalRelease

use of org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease in project mapstruct by mapstruct.

the class QualifierTest 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")));
}
Also used : AbstractEntry(org.mapstruct.ap.test.selection.qualifier.bean.AbstractEntry) OriginalRelease(org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease) HashMap(java.util.HashMap) List(java.util.List) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 5 with OriginalRelease

use of org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease in project mapstruct by mapstruct.

the class NamedTest method shouldMatchClassAndMethod.

@ProcessorTest
@WithClasses({ Titles.class, Facts.class, PlotWords.class, OriginalRelease.class, EnglishToGerman.class, TitleTranslator.class, MovieMapper.class, KeyWordMapper.class, FactMapper.class })
public void shouldMatchClassAndMethod() {
    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);
    GermanRelease germanMovies = MovieMapper.INSTANCE.toGerman(foreignMovies);
    assertThat(germanMovies).isNotNull();
    assertThat(germanMovies.getTitle()).isEqualTo("Der sechste Sinn");
    assertThat(germanMovies.getKeyWords()).isNotNull();
    assertThat(germanMovies.getKeyWords().size()).isEqualTo(2);
    assertThat(germanMovies.getKeyWords()).containsSequence("Evergreen", "Großartig");
    assertThat(germanMovies.getFacts()).isNotNull();
    assertThat(germanMovies.getFacts()).hasSize(3);
    assertThat(germanMovies.getFacts()).contains(entry("Regisseur", Arrays.asList("M. Night Shyamalan")), entry("Besetzung", Arrays.asList("Bruce Willis", "Haley Joel Osment", "Toni Collette")), entry("Handlungstichwörter", Arrays.asList("Jungen", "Kinderpsychologe", "Ich sehe tote Menschen")));
}
Also used : GermanRelease(org.mapstruct.ap.test.selection.qualifier.bean.GermanRelease) CreateGermanRelease(org.mapstruct.ap.test.selection.qualifier.annotation.CreateGermanRelease) OriginalRelease(org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease) HashMap(java.util.HashMap) List(java.util.List) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

OriginalRelease (org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease)5 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)5 WithClasses (org.mapstruct.ap.testutil.WithClasses)5 HashMap (java.util.HashMap)4 List (java.util.List)4 CreateGermanRelease (org.mapstruct.ap.test.selection.qualifier.annotation.CreateGermanRelease)3 GermanRelease (org.mapstruct.ap.test.selection.qualifier.bean.GermanRelease)3 IssueKey (org.mapstruct.ap.testutil.IssueKey)3 AbstractEntry (org.mapstruct.ap.test.selection.qualifier.bean.AbstractEntry)2