use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class SpringDecoratorTest method shouldDelegateNonDecoratedMethodsToDefaultImplementation.
@ProcessorTest
public void shouldDelegateNonDecoratedMethodsToDefaultImplementation() {
// given
Address address = new Address("42 Ocean View Drive");
// when
AddressDto addressDto = personMapper.addressToAddressDto(address);
// then
assertThat(addressDto).isNotNull();
assertThat(addressDto.getAddressLine()).isEqualTo("42 Ocean View Drive");
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class JodaConversionTest method testSourceToTargetMappingForStringsJdk11.
@ProcessorTest
@EnabledForJreRange(min = JRE.JAVA_11)
public // See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+
void testSourceToTargetMappingForStringsJdk11() {
Source src = new Source();
src.setLocalTime(new LocalTime(0, 0));
src.setLocalDate(new LocalDate(2014, 1, 1));
src.setLocalDateTime(new LocalDateTime(2014, 1, 1, 0, 0));
src.setDateTime(new DateTime(2014, 1, 1, 0, 0, 0, DateTimeZone.UTC));
// with given format
Target target = SourceTargetMapper.INSTANCE.sourceToTarget(src);
assertThat(target).isNotNull();
assertThat(target.getDateTime()).isEqualTo("01.01.2014 00:00 UTC");
assertThat(target.getLocalDateTime()).isEqualTo("01.01.2014 00:00");
assertThat(target.getLocalDate()).isEqualTo("01.01.2014");
assertThat(target.getLocalTime()).isEqualTo("00:00");
// and now with default mappings
target = SourceTargetMapper.INSTANCE.sourceToTargetDefaultMapping(src);
assertThat(target).isNotNull();
assertThat(target.getDateTime()).isEqualTo("1. Januar 2014 um 00:00:00 UTC");
assertThat(target.getLocalDateTime()).isEqualTo("1. Januar 2014 um 00:00:00");
assertThat(target.getLocalDate()).isEqualTo("1. Januar 2014");
assertThat(target.getLocalTime()).isEqualTo("00:00:00");
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class JodaConversionTest method testCalendar.
@ProcessorTest
public void testCalendar() {
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("CET"));
DateTime dateTimeWithCalendar = new DateTime(calendar);
Source src = new Source();
src.setDateTimeForCalendarConversion(dateTimeWithCalendar);
Target target = SourceTargetMapper.INSTANCE.sourceToTarget(src);
assertThat(target).isNotNull();
assertThat(target.getDateTimeForCalendarConversion().getTime()).isEqualTo(calendar.getTime());
Source mappedSource = SourceTargetMapper.INSTANCE.targetToSource(target);
assertThat(mappedSource).isNotNull();
assertThat(mappedSource.getDateTimeForCalendarConversion()).isEqualTo(dateTimeWithCalendar);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class JodaConversionTest method testLocalDateTimeToString.
@ProcessorTest
public void testLocalDateTimeToString() {
Source src = new Source();
src.setLocalDateTime(new LocalDateTime(2014, 1, 1, 0, 0));
Target target = SourceTargetMapper.INSTANCE.sourceToTargetLocalDateTimeMapped(src);
assertThat(target).isNotNull();
assertThat(target.getLocalDateTime()).isEqualTo("01.01.2014 00:00");
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class JodaConversionTest method testStringToLocalDateTime.
@ProcessorTest
public void testStringToLocalDateTime() {
String dateTimeAsString = "01.01.2014 00:00";
Target target = new Target();
target.setLocalDateTime(dateTimeAsString);
LocalDateTime sourceDateTime = new LocalDateTime(2014, 1, 1, 0, 0, 0);
Source src = SourceTargetMapper.INSTANCE.targetToSourceLocalDateTimeMapped(target);
assertThat(src).isNotNull();
assertThat(src.getLocalDateTime()).isEqualTo(sourceDateTime);
}
Aggregations