예제 #1
0
  @Test
  public void shouldApplyBuiltInStringToXmlGregCal()
      throws ParseException, DatatypeConfigurationException {

    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();
  }
예제 #2
0
  @Test
  public void shouldApplyBuiltInOnCalendarToXmlGregCal()
      throws ParseException, DatatypeConfigurationException {

    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");
  }
예제 #3
0
  @Test
  public void shouldApplyBuiltInOnDateToXmlGregCal()
      throws ParseException, DatatypeConfigurationException {

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