Search in sources :

Example 31 with WithClasses

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

the class JavaDefaultExpressionTest method testJavaDefaultExpressionWithNoValues.

@ProcessorTest
@WithClasses({ Source.class, Target.class, SourceTargetMapper.class })
public void testJavaDefaultExpressionWithNoValues() {
    Source source = new Source();
    Target target = SourceTargetMapper.INSTANCE.sourceToTarget(source);
    assertThat(target).isNotNull();
    assertThat(target.getSourceId()).isEqualTo("test");
    assertThat(target.getSourceDate()).isEqualTo(new Date(30L));
}
Also used : Date(java.util.Date) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 32 with WithClasses

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

the class JavaExpressionTest method testJavaExpressionInsertionWithExistingTarget.

@ProcessorTest
@WithClasses({ Source.class, Target.class, TimeAndFormat.class, SourceTargetMapper.class })
public void testJavaExpressionInsertionWithExistingTarget() 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 = new Target();
    Target target2 = SourceTargetMapper.INSTANCE.sourceToTargetWithMappingTarget(source, target);
    assertThat(target).isNotNull();
    assertThat(target.getTimeAndFormat().getTime()).isEqualTo(time);
    assertThat(target.getTimeAndFormat().getFormat()).isEqualTo(format);
    assertThat(target.getAnotherProp()).isNull();
    assertThat(target).isEqualTo(target2);
}
Also used : Date(java.util.Date) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 33 with WithClasses

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

the class WildCardTest method testWildCardAsSourceType.

@ProcessorTest
@WithClasses(SourceWildCardExtendsMapper.class)
public void testWildCardAsSourceType() {
    // prepare source
    SourceWildCardExtendsMapper.Wrapper<BigInteger> wrapper = new SourceWildCardExtendsMapper.Wrapper<>(new BigInteger("5"));
    SourceWildCardExtendsMapper.Source source = new SourceWildCardExtendsMapper.Source(wrapper);
    // action
    SourceWildCardExtendsMapper.Target target = SourceWildCardExtendsMapper.INSTANCE.map(source);
    // verify target
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isEqualTo("5");
}
Also used : BigInteger(java.math.BigInteger) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 34 with WithClasses

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

the class WildCardTest method testWildCard.

@ProcessorTest
@WithClasses(SourceWildCardExtendsMapper.class)
public void testWildCard() {
    // prepare source
    SourceWildCardExtendsMapper.Wrapper<BigInteger> wrapper = new SourceWildCardExtendsMapper.Wrapper<>(new BigInteger("5"));
    SourceWildCardExtendsMapper.Source source = new SourceWildCardExtendsMapper.Source(wrapper);
    // action
    SourceWildCardExtendsMapper.Target target = SourceWildCardExtendsMapper.INSTANCE.map(source);
    // verify target
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isEqualTo("5");
}
Also used : BigInteger(java.math.BigInteger) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 35 with WithClasses

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

the class Issue2195Test method test.

@ProcessorTest
@WithClasses(Issue2195Mapper.class)
public void test() {
    Source source = new Source();
    source.setName("JohnDoe");
    TargetBase target = Issue2195Mapper.INSTANCE.map(source);
    assertThat(target).isInstanceOf(Target.class);
}
Also used : TargetBase(org.mapstruct.ap.test.bugs._2195.dto.TargetBase) Source(org.mapstruct.ap.test.bugs._2195.dto.Source) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

WithClasses (org.mapstruct.ap.testutil.WithClasses)119 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)118 XmlGregorianCalendarBean (org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean)24 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)17 IssueKey (org.mapstruct.ap.testutil.IssueKey)17 LocalDateTimeBean (org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateTimeBean)16 XmlGregorianCalendarProperty (org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty)12 Song (org.mapstruct.ap.test.nestedsourceproperties.source.Song)11 DateTimeBean (org.mapstruct.ap.test.builtin.jodatime.bean.DateTimeBean)10 CalendarProperty (org.mapstruct.ap.test.builtin.bean.CalendarProperty)8 Song (org.mapstruct.ap.test.constructor.nestedsource.source.Song)8 ChartEntry (org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntry)7 BigDecimal (java.math.BigDecimal)6 BigInteger (java.math.BigInteger)6 ChartEntry (org.mapstruct.ap.test.constructor.nestedsource._target.ChartEntry)6 Date (java.util.Date)5 LocalDateTime (org.joda.time.LocalDateTime)5 StringProperty (org.mapstruct.ap.test.builtin.bean.StringProperty)5 XmlGregorianCalendarToLocalDateTime (org.mapstruct.ap.test.builtin.jodatime.mapper.XmlGregorianCalendarToLocalDateTime)5 VehicleCollection (org.mapstruct.ap.test.subclassmapping.mappables.VehicleCollection)5