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());
}
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");
}
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");
}
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");
}
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"));
}
Aggregations