Search in sources :

Example 6 with IssueKey

use of org.mapstruct.ap.testutil.IssueKey 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 7 with IssueKey

use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.

the class AdderTest method testWildcardAdderTargetToSource.

@IssueKey("1170")
@ProcessorTest
public void testWildcardAdderTargetToSource() {
    Target target = new Target();
    target.addWithoutWildcard(2L);
    target.addWildcardInTarget(2L);
    target.getWildcardInSources().add(2L);
    target.addWildcardInBoth(2L);
    target.setWildcardAdderToSetters(Arrays.asList(2L));
    Source source = AdderSourceTargetMapper.INSTANCE.toSource(target);
    assertThat(source).isNotNull();
    assertThat(source.getWithoutWildcards()).containsExactly("mouse");
    ((ListAssert<String>) assertThat(source.getWildcardInSources())).containsExactly("mouse");
    assertThat(source.getWildcardInTargets()).containsExactly("mouse");
    ((ListAssert<String>) assertThat(source.getWildcardInBoths())).containsExactly("mouse");
    ((ListAssert<String>) assertThat(source.getWildcardAdderToSetters())).containsExactly("mouse");
}
Also used : Target(org.mapstruct.ap.test.bugs._1170._target.Target) ListAssert(org.assertj.core.api.ListAssert) Source(org.mapstruct.ap.test.bugs._1170.source.Source) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 8 with IssueKey

use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.

the class AdderTest method testWildcardAdder.

@IssueKey("1170")
@ProcessorTest
public void testWildcardAdder() {
    Source source = new Source();
    source.addWithoutWildcard("mouse");
    source.addWildcardInTarget("mouse");
    source.addWildcardInSource("mouse");
    source.addWildcardInBoth("mouse");
    source.addWildcardAdderToSetter("mouse");
    Target target = AdderSourceTargetMapper.INSTANCE.toTarget(source);
    assertThat(target).isNotNull();
    assertThat(target.getWithoutWildcards()).containsExactly(2L);
    assertThat(target.getWildcardInSources()).containsExactly(2L);
    ((ListAssert<Long>) assertThat(target.getWildcardInTargets())).containsExactly(2L);
    ((ListAssert<Long>) assertThat(target.getWildcardInBoths())).containsExactly(2L);
    assertThat(target.getWildcardAdderToSetters()).containsExactly(2L);
}
Also used : Target(org.mapstruct.ap.test.bugs._1170._target.Target) ListAssert(org.assertj.core.api.ListAssert) Source(org.mapstruct.ap.test.bugs._1170.source.Source) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 9 with IssueKey

use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.

the class BuiltInTest method shouldApplyBuiltInOnJAXBElementList.

@ProcessorTest
@WithClasses({ JaxbListMapper.class, JaxbElementListProperty.class })
@WithJavaxJaxb
@IssueKey("141")
public void shouldApplyBuiltInOnJAXBElementList() {
    JaxbElementListProperty source = new JaxbElementListProperty();
    source.setProp(createJaxbList("TEST2"));
    source.publicProp = createJaxbList("PUBLIC TEST2");
    StringListProperty target = JaxbListMapper.INSTANCE.map(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp().get(0)).isEqualTo("TEST2");
    assertThat(target.publicProp.get(0)).isEqualTo("PUBLIC TEST2");
}
Also used : StringListProperty(org.mapstruct.ap.test.builtin.bean.StringListProperty) JaxbElementListProperty(org.mapstruct.ap.test.builtin.bean.JaxbElementListProperty) WithJavaxJaxb(org.mapstruct.ap.testutil.WithJavaxJaxb) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 10 with IssueKey

use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.

the class BuiltInTest method shouldApplyBuiltInOnJAXBElementExtra.

@ProcessorTest
@WithClasses({ JaxbMapper.class, JaxbElementProperty.class })
@WithJavaxJaxb
@IssueKey("1698")
public void shouldApplyBuiltInOnJAXBElementExtra() {
    JaxbElementProperty source = new JaxbElementProperty();
    source.setProp(createJaxb("5"));
    source.publicProp = createJaxb("5");
    BigDecimalProperty target = JaxbMapper.INSTANCE.mapBD(source);
    assertThat(target).isNotNull();
    assertThat(target.getProp()).isEqualTo(new BigDecimal("5"));
    assertThat(target.publicProp).isEqualTo(new BigDecimal("5"));
    JaxbElementProperty source2 = new JaxbElementProperty();
    source2.setProp(createJaxb("5"));
    source2.publicProp = createJaxb("5");
    SomeTypeProperty target2 = JaxbMapper.INSTANCE.mapSomeType(source2);
    assertThat(target2).isNotNull();
    assertThat(target2.publicProp).isNotNull();
    assertThat(target2.getProp()).isNotNull();
}
Also used : BigDecimalProperty(org.mapstruct.ap.test.builtin.bean.BigDecimalProperty) SomeTypeProperty(org.mapstruct.ap.test.builtin.bean.SomeTypeProperty) JaxbElementProperty(org.mapstruct.ap.test.builtin.bean.JaxbElementProperty) BigDecimal(java.math.BigDecimal) WithJavaxJaxb(org.mapstruct.ap.testutil.WithJavaxJaxb) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

IssueKey (org.mapstruct.ap.testutil.IssueKey)38 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)36 WithClasses (org.mapstruct.ap.testutil.WithClasses)14 Date (java.util.Date)6 GeneratedSource (org.mapstruct.ap.testutil.runner.GeneratedSource)6 BigInteger (java.math.BigInteger)4 Target (org.mapstruct.ap.test.collection.adder._target.Target)4 SingleElementSource (org.mapstruct.ap.test.collection.adder.source.SingleElementSource)4 BigDecimal (java.math.BigDecimal)3 HashMap (java.util.HashMap)3 Source (org.mapstruct.ap.test.collection.adder.source.Source)3 OriginalRelease (org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease)3 Time (java.sql.Time)2 Timestamp (java.sql.Timestamp)2 SimpleDateFormat (java.text.SimpleDateFormat)2 GregorianCalendar (java.util.GregorianCalendar)2 List (java.util.List)2 ListAssert (org.assertj.core.api.ListAssert)2 Test (org.junit.Test)2 Target (org.mapstruct.ap.test.bugs._1170._target.Target)2