Search in sources :

Example 1 with ZonedDateTimeProperty

use of org.mapstruct.ap.test.builtin.java8time.bean.ZonedDateTimeProperty in project mapstruct by mapstruct.

the class BuiltInTest method shouldApplyBuiltInOnZonedDateTimeToCalendar.

@ProcessorTest
@WithClasses(ZonedDateTimeToCalendarMapper.class)
public void shouldApplyBuiltInOnZonedDateTimeToCalendar() throws ParseException {
    assertThat(ZonedDateTimeToCalendarMapper.INSTANCE.map(null)).isNull();
    ZonedDateTimeProperty source = new ZonedDateTimeProperty();
    source.setProp(ZonedDateTime.of(1999, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault()));
    source.publicProp = ZonedDateTime.of(2016, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault());
    CalendarProperty target = ZonedDateTimeToCalendarMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp()).isEqualTo(createCalendar("02.03.1999"));
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp).isEqualTo(createCalendar("02.03.2016"));
}
Also used : XmlGregorianCalendarProperty(org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty) CalendarProperty(org.mapstruct.ap.test.builtin.bean.CalendarProperty) ZonedDateTimeProperty(org.mapstruct.ap.test.builtin.java8time.bean.ZonedDateTimeProperty) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 2 with ZonedDateTimeProperty

use of org.mapstruct.ap.test.builtin.java8time.bean.ZonedDateTimeProperty in project mapstruct by mapstruct.

the class BuiltInTest method shouldApplyBuiltInOnCalendarToZonedDateTime.

@ProcessorTest
@WithClasses(CalendarToZonedDateTimeMapper.class)
public void shouldApplyBuiltInOnCalendarToZonedDateTime() throws ParseException {
    assertThat(CalendarToZonedDateTimeMapper.INSTANCE.map(null)).isNull();
    CalendarProperty source = new CalendarProperty();
    source.setProp(createCalendar("02.03.1999"));
    source.publicProp = createCalendar("02.03.2016");
    ZonedDateTimeProperty target = CalendarToZonedDateTimeMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp()).isEqualTo(ZonedDateTime.of(1999, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault()));
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp).isEqualTo(ZonedDateTime.of(2016, 3, 2, 0, 0, 0, 0, ZoneId.systemDefault()));
}
Also used : XmlGregorianCalendarProperty(org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty) CalendarProperty(org.mapstruct.ap.test.builtin.bean.CalendarProperty) ZonedDateTimeProperty(org.mapstruct.ap.test.builtin.java8time.bean.ZonedDateTimeProperty) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

CalendarProperty (org.mapstruct.ap.test.builtin.bean.CalendarProperty)2 XmlGregorianCalendarProperty (org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty)2 ZonedDateTimeProperty (org.mapstruct.ap.test.builtin.java8time.bean.ZonedDateTimeProperty)2 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)2 WithClasses (org.mapstruct.ap.testutil.WithClasses)2