Search in sources :

Example 1 with DateProperty

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

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

Example 3 with DateProperty

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

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

Example 5 with DateProperty

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

the class BuiltInTest method shouldApplyBuiltInOnDateToCalendar.

@ProcessorTest
@WithClasses(DateToCalendarMapper.class)
public void shouldApplyBuiltInOnDateToCalendar() throws ParseException {
    DateProperty source = new DateProperty();
    source.setProp(new SimpleDateFormat("dd.MM.yyyy").parse("02.03.1999"));
    source.publicProp = new SimpleDateFormat("dd.MM.yyyy").parse("02.03.2016");
    CalendarProperty target = DateToCalendarMapper.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) DateProperty(org.mapstruct.ap.test.builtin.bean.DateProperty) SimpleDateFormat(java.text.SimpleDateFormat) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

DateProperty (org.mapstruct.ap.test.builtin.bean.DateProperty)5 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)5 XmlGregorianCalendarProperty (org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty)4 WithClasses (org.mapstruct.ap.testutil.WithClasses)4 CalendarProperty (org.mapstruct.ap.test.builtin.bean.CalendarProperty)3 SimpleDateFormat (java.text.SimpleDateFormat)1 XmlGregorianCalendarFactorizedProperty (org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarFactorizedProperty)1