use of org.mapstruct.ap.testutil.WithClasses 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");
}
use of org.mapstruct.ap.testutil.WithClasses 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")));
}
use of org.mapstruct.ap.testutil.WithClasses 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")));
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class JavaExpressionTest method testJavaExpressionInsertionWithSeveralSources.
@IssueKey("255")
@ProcessorTest
@WithClasses({ Source.class, Source2.class, Target.class, TimeAndFormat.class, SourceTargetMapperSeveralSources.class })
public void testJavaExpressionInsertionWithSeveralSources() throws ParseException {
Source source1 = new Source();
String format = "dd-MM-yyyy,hh:mm:ss";
Date time = getTime(format, "09-01-2014,01:35:03");
source1.setFormat(format);
source1.setTime(time);
Source2 source2 = new Source2();
source2.setAnotherProp("test");
Target target = SourceTargetMapperSeveralSources.INSTANCE.sourceToTarget(source1, source2);
assertThat(target).isNotNull();
assertThat(target.getTimeAndFormat().getTime()).isEqualTo(time);
assertThat(target.getTimeAndFormat().getFormat()).isEqualTo(format);
assertThat(target.getAnotherProp()).isEqualTo("test");
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class JavaExpressionTest method testJavaExpressionInsertion.
@ProcessorTest
@WithClasses({ Source.class, Target.class, TimeAndFormat.class, SourceTargetMapper.class })
public void testJavaExpressionInsertion() throws ParseException {
Source source = new Source();
String format = "dd-MM-yyyy,hh:mm:ss";
Date time = getTime(format, "09-01-2014,01:35:03");
source.setFormat(format);
source.setTime(time);
Target target = SourceTargetMapper.INSTANCE.sourceToTarget(source);
assertThat(target).isNotNull();
assertThat(target.getTimeAndFormat().getTime()).isEqualTo(time);
assertThat(target.getTimeAndFormat().getFormat()).isEqualTo(format);
assertThat(target.getAnotherProp()).isNull();
}
Aggregations