Search in sources :

Example 6 with CalendarProperty

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

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

the class BuiltInTest method shouldApplyBuiltInOnCalendarToString.

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

Example 8 with CalendarProperty

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

Example 9 with CalendarProperty

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

the class BuiltInTest method shouldApplyBuiltInOnStringToCalendar.

@ProcessorTest
@WithClasses(StringToCalendarMapper.class)
public void shouldApplyBuiltInOnStringToCalendar() throws ParseException {
    StringProperty source = new StringProperty();
    source.setProp("02.03.1999");
    source.publicProp = "02.03.2016";
    CalendarProperty target = StringToCalendarMapper.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) StringProperty(org.mapstruct.ap.test.builtin.bean.StringProperty) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

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