Search in sources :

Example 26 with IssueKey

use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.

the class ConflictingTypesNamesTest method importsForTargetTypes.

@ProcessorTest
@IssueKey("156")
public void importsForTargetTypes() {
    FooWrapper source = new FooWrapper();
    Foo value = new Foo();
    value.setName("foo");
    source.setValue(value);
    org.mapstruct.ap.test.imports.to.FooWrapper result = SecondSourceTargetMapper.INSTANCE.fooWrapperToFooWrapper(source);
    assertThat(result).isNotNull();
    assertThat(result.getValue()).isNotNull();
    assertThat(result.getValue().getName()).isEqualTo("foo");
}
Also used : Foo(org.mapstruct.ap.test.imports.from.Foo) FooWrapper(org.mapstruct.ap.test.imports.from.FooWrapper) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 27 with IssueKey

use of org.mapstruct.ap.testutil.IssueKey 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 28 with IssueKey

use of org.mapstruct.ap.testutil.IssueKey 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 29 with IssueKey

use of org.mapstruct.ap.testutil.IssueKey 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");
}
Also used : Date(java.util.Date) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 30 with IssueKey

use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.

the class AdderTest method testAdd.

@IssueKey("241")
@ProcessorTest
public void testAdd() throws DogException {
    AdderUsageObserver.setUsed(false);
    Source source = new Source();
    source.setPets(Arrays.asList("mouse"));
    Target target = SourceTargetMapper.INSTANCE.toTarget(source);
    assertThat(target).isNotNull();
    assertThat(target.getPets().size()).isEqualTo(1);
    assertThat(target.getPets().get(0)).isEqualTo(2L);
    assertTrue(AdderUsageObserver.isUsed());
}
Also used : Target(org.mapstruct.ap.test.collection.adder._target.Target) GeneratedSource(org.mapstruct.ap.testutil.runner.GeneratedSource) Source(org.mapstruct.ap.test.collection.adder.source.Source) SingleElementSource(org.mapstruct.ap.test.collection.adder.source.SingleElementSource) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Aggregations

IssueKey (org.mapstruct.ap.testutil.IssueKey)38 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)36 WithClasses (org.mapstruct.ap.testutil.WithClasses)14 Date (java.util.Date)6 GeneratedSource (org.mapstruct.ap.testutil.runner.GeneratedSource)6 BigInteger (java.math.BigInteger)4 Target (org.mapstruct.ap.test.collection.adder._target.Target)4 SingleElementSource (org.mapstruct.ap.test.collection.adder.source.SingleElementSource)4 BigDecimal (java.math.BigDecimal)3 HashMap (java.util.HashMap)3 Source (org.mapstruct.ap.test.collection.adder.source.Source)3 OriginalRelease (org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease)3 Time (java.sql.Time)2 Timestamp (java.sql.Timestamp)2 SimpleDateFormat (java.text.SimpleDateFormat)2 GregorianCalendar (java.util.GregorianCalendar)2 List (java.util.List)2 ListAssert (org.assertj.core.api.ListAssert)2 Test (org.junit.Test)2 Target (org.mapstruct.ap.test.bugs._1170._target.Target)2