Search in sources :

Example 1 with XmlGregorianCalendarProperty

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

the class BuiltInTest method shouldApplyBuiltInStringToXmlGregCal.

@ProcessorTest
@WithClasses(StringToXmlGregCalMapper.class)
public void shouldApplyBuiltInStringToXmlGregCal() {
    StringProperty source = new StringProperty();
    source.setProp("05.07.1999");
    source.publicProp = "05.07.2016";
    XmlGregorianCalendarProperty target = StringToXmlGregCalMapper.INSTANCE.mapAndFormat(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp().toString()).isEqualTo("1999-07-05T00:00:00.000+02:00");
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp.toString()).isEqualTo("2016-07-05T00:00:00.000+02:00");
    // direct,via lexical representation
    source.setProp("2000-03-04T23:00:00+03:00");
    source.publicProp = "2016-03-04T23:00:00+03:00";
    target = StringToXmlGregCalMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp().toString()).isEqualTo("2000-03-04T23:00:00+03:00");
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp.toString()).isEqualTo("2016-03-04T23:00:00+03:00");
    // null string
    source.setProp(null);
    source.publicProp = null;
    target = StringToXmlGregCalMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNull();
    assertThat(target.publicProp).isNull();
}
Also used : XmlGregorianCalendarProperty(org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty) StringProperty(org.mapstruct.ap.test.builtin.bean.StringProperty) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 2 with XmlGregorianCalendarProperty

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

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

the class BuiltInTest method shouldApplyBuiltInOnDateToXmlGregCal.

@ProcessorTest
@WithClasses(DateToXmlGregCalMapper.class)
public void shouldApplyBuiltInOnDateToXmlGregCal() throws ParseException {
    DateProperty source = new DateProperty();
    source.setProp(createDate("31-08-1982 10:20:56"));
    source.publicProp = createDate("31-08-2016 10:20:56");
    XmlGregorianCalendarProperty target = DateToXmlGregCalMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp().toString()).isEqualTo("1982-08-31T10:20:56.000+02:00");
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp.toString()).isEqualTo("2016-08-31T10:20:56.000+02:00");
}
Also used : XmlGregorianCalendarProperty(org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty) DateProperty(org.mapstruct.ap.test.builtin.bean.DateProperty) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 4 with XmlGregorianCalendarProperty

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

the class BuiltInTest method shouldApplyBuiltInOnCalendarToXmlGregCal.

@ProcessorTest
@WithClasses(CalendarToXmlGregCalMapper.class)
public void shouldApplyBuiltInOnCalendarToXmlGregCal() throws ParseException {
    CalendarProperty source = new CalendarProperty();
    source.setProp(createCalendar("02.03.1999"));
    source.publicProp = createCalendar("02.03.2016");
    XmlGregorianCalendarProperty target = CalendarToXmlGregCalMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp().toString()).isEqualTo("1999-03-02T00:00:00.000+01:00");
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp.toString()).isEqualTo("2016-03-02T00:00:00.000+01:00");
}
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 5 with XmlGregorianCalendarProperty

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

the class BuiltInTest method shouldApplyBuiltInOnXmlGregCalToDate.

@ProcessorTest
@WithClasses(XmlGregCalToDateMapper.class)
public void shouldApplyBuiltInOnXmlGregCalToDate() throws DatatypeConfigurationException {
    XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty();
    source.setProp(createXmlCal(1999, 3, 2, 60));
    source.publicProp = createXmlCal(2016, 3, 2, 60);
    DateProperty target = XmlGregCalToDateMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp().toString()).isEqualTo("Tue Mar 02 00:00:00 CET 1999");
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp.toString()).isEqualTo("Wed Mar 02 00:00:00 CET 2016");
}
Also used : XmlGregorianCalendarProperty(org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty) DateProperty(org.mapstruct.ap.test.builtin.bean.DateProperty) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

XmlGregorianCalendarProperty (org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty)6 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)6 WithClasses (org.mapstruct.ap.testutil.WithClasses)6 CalendarProperty (org.mapstruct.ap.test.builtin.bean.CalendarProperty)2 DateProperty (org.mapstruct.ap.test.builtin.bean.DateProperty)2 StringProperty (org.mapstruct.ap.test.builtin.bean.StringProperty)2