use of org.mapstruct.ap.testutil.ProcessorTest 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();
}
use of org.mapstruct.ap.testutil.ProcessorTest 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);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class DateConversionTest method shouldApplyDateToSqlConversion.
@IssueKey("858")
@ProcessorTest
public void shouldApplyDateToSqlConversion() {
GregorianCalendar time = new GregorianCalendar(2016, Calendar.AUGUST, 24, 20, 30, 30);
GregorianCalendar sqlDate = new GregorianCalendar(2016, Calendar.AUGUST, 23, 21, 35, 35);
GregorianCalendar timestamp = new GregorianCalendar(2016, Calendar.AUGUST, 22, 21, 35, 35);
Source source = new Source();
source.setTime(time.getTime());
source.setSqlDate(sqlDate.getTime());
source.setTimestamp(timestamp.getTime());
Target target = SourceTargetMapper.INSTANCE.sourceToTarget(source);
Time expectedTime = new Time(time.getTime().getTime());
java.sql.Date expectedSqlDate = new java.sql.Date(sqlDate.getTime().getTime());
Timestamp expectedTimestamp = new Timestamp(timestamp.getTime().getTime());
assertThat(target.getTime()).isEqualTo(expectedTime);
assertThat(target.getSqlDate()).isEqualTo(expectedSqlDate);
assertThat(target.getTimestamp()).isEqualTo(expectedTimestamp);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class DateConversionTest method shouldApplySqlToDateConversion.
@IssueKey("858")
@ProcessorTest
public void shouldApplySqlToDateConversion() {
Target target = new Target();
GregorianCalendar time = new GregorianCalendar(2016, Calendar.AUGUST, 24, 20, 30, 30);
GregorianCalendar sqlDate = new GregorianCalendar(2016, Calendar.AUGUST, 23, 21, 35, 35);
GregorianCalendar timestamp = new GregorianCalendar(2016, Calendar.AUGUST, 22, 21, 35, 35);
target.setTime(new Time(time.getTime().getTime()));
target.setSqlDate(new java.sql.Date(sqlDate.getTime().getTime()));
target.setTimestamp(new Timestamp(timestamp.getTime().getTime()));
Source source = SourceTargetMapper.INSTANCE.targetToSource(target);
assertThat(source).isNotNull();
assertThat(source.getTime()).isEqualTo(target.getTime());
assertThat(source.getSqlDate()).isEqualTo(target.getSqlDate());
assertThat(source.getTimestamp()).isEqualTo(target.getTimestamp());
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class DateConversionTest method shouldApplyStringConversionForReverseArrayArrayMethod.
@ProcessorTest
public void shouldApplyStringConversionForReverseArrayArrayMethod() {
Date[] dates = new Date[] { new GregorianCalendar(2013, Calendar.JULY, 6).getTime(), new GregorianCalendar(2013, Calendar.FEBRUARY, 14).getTime(), new GregorianCalendar(2013, Calendar.APRIL, 11).getTime() };
String[] stringDates = SourceTargetMapper.INSTANCE.dateArrayToStringArray(dates);
assertThat(stringDates).isNotNull();
assertThat(stringDates).isEqualTo(new String[] { "06.07.2013", "14.02.2013", "11.04.2013" });
}
Aggregations