コード例 #1
0
ファイル: BuiltInTest.java プロジェクト: bedla/mapstruct
  @Test
  public void shouldApplyBuiltInXmlGregCalToString()
      throws ParseException, DatatypeConfigurationException {

    XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty();
    source.setProp(createXmlCal(1999, 3, 2, 60));
    source.publicProp = createXmlCal(2016, 3, 2, 60);

    StringProperty target = XmlGregCalToStringMapper.INSTANCE.mapAndFormat(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");

    source.setProp(createXmlCal(1999, 3, 2, 60));
    source.publicProp = createXmlCal(2016, 3, 2, 60);

    target = XmlGregCalToStringMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isNotNull();
    assertThat(target.getProp()).isEqualTo("1999-03-02+01:00");
    assertThat(target.publicProp).isNotNull();
    assertThat(target.publicProp).isEqualTo("2016-03-02+01:00");
  }
コード例 #2
0
ファイル: BuiltInTest.java プロジェクト: bedla/mapstruct
  @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();
  }
コード例 #3
0
ファイル: BuiltInTest.java プロジェクト: bedla/mapstruct
  @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");
  }
コード例 #4
0
ファイル: BuiltInTest.java プロジェクト: bedla/mapstruct
  @Test
  public void shouldApplyBuiltInOnXmlGregCalToDate()
      throws ParseException, 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");
  }
コード例 #5
0
ファイル: BuiltInTest.java プロジェクト: bedla/mapstruct
  @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");
  }
コード例 #6
0
ファイル: BuiltInTest.java プロジェクト: bedla/mapstruct
  @Test
  public void shouldApplyBuiltInOnXmlGregCalToCalendar()
      throws ParseException, 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);
  }