use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class EnumToEnumMappingTest method shouldApplyReverseMappings.
@ProcessorTest
public void shouldApplyReverseMappings() {
OrderType result = OrderMapper.INSTANCE.externalOrderTypeToOrderType(ExternalOrderType.SPECIAL);
assertThat(result).isEqualTo(OrderType.EXTRA);
result = OrderMapper.INSTANCE.externalOrderTypeToOrderType(ExternalOrderType.DEFAULT);
assertThat(result).isEqualTo(OrderType.STANDARD);
result = OrderMapper.INSTANCE.externalOrderTypeToOrderType(ExternalOrderType.RETAIL);
assertThat(result).isEqualTo(OrderType.RETAIL);
result = OrderMapper.INSTANCE.externalOrderTypeToOrderType(ExternalOrderType.B2B);
assertThat(result).isEqualTo(OrderType.B2B);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class EnumToEnumMappingTest method shouldApplyDefaultReverseMappings.
@ProcessorTest
public void shouldApplyDefaultReverseMappings() {
OrderType result = SpecialOrderMapper.INSTANCE.externalOrderTypeToOrderType(ExternalOrderType.SPECIAL);
assertThat(result).isEqualTo(OrderType.EXTRA);
result = SpecialOrderMapper.INSTANCE.externalOrderTypeToOrderType(ExternalOrderType.DEFAULT);
assertThat(result).isNull();
result = SpecialOrderMapper.INSTANCE.externalOrderTypeToOrderType(ExternalOrderType.RETAIL);
assertThat(result).isEqualTo(OrderType.RETAIL);
result = SpecialOrderMapper.INSTANCE.externalOrderTypeToOrderType(ExternalOrderType.B2B);
assertThat(result).isEqualTo(OrderType.B2B);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class EnumToEnumThrowExceptionMappingTest method shouldIgnoreThrowExceptionWhenInverseValueMappings.
@IssueKey("2339")
@ProcessorTest
@WithClasses({ OrderThrowExceptionMapper.class, OrderDto.class })
public void shouldIgnoreThrowExceptionWhenInverseValueMappings() {
OrderType target = OrderThrowExceptionMapper.INSTANCE.externalOrderTypeToOrderType(ExternalOrderType.B2B);
assertThat(target).isEqualTo(OrderType.B2B);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class ArrayMappingTest method shouldMapArrayToList.
@ProcessorTest
public void shouldMapArrayToList() {
List<ScientistDto> dtos = ScienceMapper.INSTANCE.scientistsToDtosAsList(new Scientist[] { new Scientist("Bob"), new Scientist("Larry") });
assertThat(dtos).isNotNull();
assertThat(dtos).extracting("name").containsOnly("Bob", "Larry");
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class ArrayMappingTest method shouldMapArrayToArrayExistingSmallerSizedTarget.
@ProcessorTest
public void shouldMapArrayToArrayExistingSmallerSizedTarget() {
ScientistDto[] existingTarget = new ScientistDto[] { new ScientistDto("Jim") };
ScientistDto[] target = ScienceMapper.INSTANCE.scientistsToDtos(new Scientist[] { new Scientist("Bob"), new Scientist("Larry") }, existingTarget);
assertThat(target).isNotNull();
assertThat(target).isEqualTo(existingTarget);
assertThat(target).extracting("name").containsOnly("Bob");
}
Aggregations