Search in sources :

Example 1 with Source

use of org.mapstruct.ap.test.conversion.java8time.localdatetoxmlgregoriancalendarconversion.Source in project mapstruct by mapstruct.

the class LocalDateToXMLGregorianCalendarConversionTest method shouldNullCheckOnBuiltinAndConversion.

@ProcessorTest
public void shouldNullCheckOnBuiltinAndConversion() {
    Target target = SourceTargetMapper.INSTANCE.toTarget(new Source());
    assertThat(target).isNotNull();
    assertThat(target.getDate()).isNull();
    Source source = SourceTargetMapper.INSTANCE.toSource(new Target());
    assertThat(source).isNotNull();
    assertThat(source.getDate()).isNull();
}
Also used : Target(org.mapstruct.ap.test.conversion.java8time.localdatetoxmlgregoriancalendarconversion.Target) Source(org.mapstruct.ap.test.conversion.java8time.localdatetoxmlgregoriancalendarconversion.Source) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 2 with Source

use of org.mapstruct.ap.test.conversion.java8time.localdatetoxmlgregoriancalendarconversion.Source in project mapstruct by mapstruct.

the class LocalDateToXMLGregorianCalendarConversionTest method shouldMapCorrectlyOnBuiltinAndConversion.

@ProcessorTest
public void shouldMapCorrectlyOnBuiltinAndConversion() throws Exception {
    XMLGregorianCalendar calendarDate = DatatypeFactory.newInstance().newXMLGregorianCalendarDate(2007, 11, 14, DatatypeConstants.FIELD_UNDEFINED);
    LocalDate localDate = LocalDate.of(2007, 11, 14);
    Source s1 = new Source();
    s1.setDate(calendarDate);
    Target target = SourceTargetMapper.INSTANCE.toTarget(s1);
    assertThat(target).isNotNull();
    assertThat(target.getDate()).isEqualTo(localDate);
    Target t1 = new Target();
    t1.setDate(localDate);
    Source source = SourceTargetMapper.INSTANCE.toSource(t1);
    assertThat(source).isNotNull();
    assertThat(source.getDate()).isEqualTo(calendarDate);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Target(org.mapstruct.ap.test.conversion.java8time.localdatetoxmlgregoriancalendarconversion.Target) LocalDate(java.time.LocalDate) Source(org.mapstruct.ap.test.conversion.java8time.localdatetoxmlgregoriancalendarconversion.Source) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Aggregations

Source (org.mapstruct.ap.test.conversion.java8time.localdatetoxmlgregoriancalendarconversion.Source)2 Target (org.mapstruct.ap.test.conversion.java8time.localdatetoxmlgregoriancalendarconversion.Target)2 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)2 LocalDate (java.time.LocalDate)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1