Search in sources :

Example 21 with ProcessorTest

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);
}
Also used : OrderType(org.mapstruct.ap.test.value.OrderType) ExternalOrderType(org.mapstruct.ap.test.value.ExternalOrderType) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 22 with ProcessorTest

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);
}
Also used : OrderType(org.mapstruct.ap.test.value.OrderType) ExternalOrderType(org.mapstruct.ap.test.value.ExternalOrderType) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 23 with ProcessorTest

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);
}
Also used : OrderType(org.mapstruct.ap.test.value.OrderType) ExternalOrderType(org.mapstruct.ap.test.value.ExternalOrderType) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 24 with ProcessorTest

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");
}
Also used : ScientistDto(org.mapstruct.ap.test.array._target.ScientistDto) Scientist(org.mapstruct.ap.test.array.source.Scientist) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 25 with ProcessorTest

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");
}
Also used : ScientistDto(org.mapstruct.ap.test.array._target.ScientistDto) Scientist(org.mapstruct.ap.test.array.source.Scientist) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Aggregations

ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)314 WithClasses (org.mapstruct.ap.testutil.WithClasses)118 GeneratedSource (org.mapstruct.ap.testutil.runner.GeneratedSource)51 IssueKey (org.mapstruct.ap.testutil.IssueKey)39 XmlGregorianCalendarBean (org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean)24 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)22 Date (java.util.Date)16 LocalDateTimeBean (org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateTimeBean)16 Calendar (java.util.Calendar)13 LocalDateTime (org.joda.time.LocalDateTime)13 CarDto (org.mapstruct.ap.test.complex._target.CarDto)13 Car (org.mapstruct.ap.test.complex.source.Car)13 PersonDto (org.mapstruct.ap.test.constructor.PersonDto)13 GregorianCalendar (java.util.GregorianCalendar)12 XmlGregorianCalendarProperty (org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty)12 Song (org.mapstruct.ap.test.nestedsourceproperties.source.Song)12 BigDecimal (java.math.BigDecimal)11 ChartEntry (org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntry)11 DriverAndCarDto (org.mapstruct.ap.test.nullvaluemapping._target.DriverAndCarDto)11 DateTime (org.joda.time.DateTime)10