Search in sources :

Example 1 with CalendarProperty

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

the class BuiltInTest method shouldApplyBuiltInOnXmlGregCalToCalendar.

@ProcessorTest
@WithClasses(XmlGregCalToCalendarMapper.class)
public void shouldApplyBuiltInOnXmlGregCalToCalendar() throws DatatypeConfigurationException {
    XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty();
    source.setProp(createXmlCal(1999, 3, 2, 60));
    source.publicProp = createXmlCal(2016, 3, 2, 60);
    CalendarProperty target = XmlGregCalToCalendarMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp().getTimeInMillis()).isEqualTo(920329200000L);
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp.getTimeInMillis()).isEqualTo(1456873200000L);
    assertThat(target.publicProp.getTimeInMillis()).isEqualTo(1456873200000L);
}
Also used : XmlGregorianCalendarProperty(org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty) CalendarProperty(org.mapstruct.ap.test.builtin.bean.CalendarProperty) XmlGregorianCalendarProperty(org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 2 with CalendarProperty

use of org.mapstruct.ap.test.builtin.bean.CalendarProperty 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 3 with CalendarProperty

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

the class BuiltInTest method shouldApplyBuiltInOnCalendarToDate.

@ProcessorTest
@WithClasses(CalendarToDateMapper.class)
public void shouldApplyBuiltInOnCalendarToDate() throws ParseException {
    CalendarProperty source = new CalendarProperty();
    source.setProp(createCalendar("02.03.1999"));
    source.publicProp = createCalendar("02.03.2016");
    DateProperty target = CalendarToDateMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp()).isEqualTo(createCalendar("02.03.1999").getTime());
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp).isEqualTo(createCalendar("02.03.2016").getTime());
}
Also used : XmlGregorianCalendarProperty(org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty) CalendarProperty(org.mapstruct.ap.test.builtin.bean.CalendarProperty) DateProperty(org.mapstruct.ap.test.builtin.bean.DateProperty) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 4 with CalendarProperty

use of org.mapstruct.ap.test.builtin.bean.CalendarProperty 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)

Example 5 with CalendarProperty

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

the class DatatypeFactoryTest method testNoConflictsWithOwnDatatypeFactory.

@ProcessorTest
public void testNoConflictsWithOwnDatatypeFactory() throws ParseException {
    DateProperty source1 = new DateProperty();
    source1.setProp(createDate("31-08-1982 10:20:56"));
    CalendarProperty source2 = new CalendarProperty();
    source2.setProp(createCalendar("02.03.1999"));
    XmlGregorianCalendarFactorizedProperty target1 = ToXmlGregCalMapper.INSTANCE.map(source1);
    assertThat(target1).isNotNull();
    assertThat(target1.getProp()).isNotNull();
    assertThat(target1.getProp().toString()).isEqualTo("1982-08-31T10:20:56.000+02:00");
    XmlGregorianCalendarFactorizedProperty target2 = ToXmlGregCalMapper.INSTANCE.map(source2);
    assertThat(target2).isNotNull();
    assertThat(target2.getProp()).isNotNull();
    assertThat(target2.getProp().toString()).isEqualTo("1999-03-02T00:00:00.000+01:00");
}
Also used : CalendarProperty(org.mapstruct.ap.test.builtin.bean.CalendarProperty) XmlGregorianCalendarFactorizedProperty(org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarFactorizedProperty) DateProperty(org.mapstruct.ap.test.builtin.bean.DateProperty) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Aggregations

CalendarProperty (org.mapstruct.ap.test.builtin.bean.CalendarProperty)9 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)9 XmlGregorianCalendarProperty (org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty)8 WithClasses (org.mapstruct.ap.testutil.WithClasses)8 DateProperty (org.mapstruct.ap.test.builtin.bean.DateProperty)3 StringProperty (org.mapstruct.ap.test.builtin.bean.StringProperty)2 ZonedDateTimeProperty (org.mapstruct.ap.test.builtin.java8time.bean.ZonedDateTimeProperty)2 SimpleDateFormat (java.text.SimpleDateFormat)1 XmlGregorianCalendarFactorizedProperty (org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarFactorizedProperty)1