Search in sources :

Example 1 with TargetWithoutSetter

use of org.mapstruct.ap.test.collection.adder._target.TargetWithoutSetter in project mapstruct by mapstruct.

the class AdderTest method testShouldPreferSetterStrategyButThereIsNone.

@ProcessorTest
public void testShouldPreferSetterStrategyButThereIsNone() throws DogException {
    AdderUsageObserver.setUsed(false);
    Source source = new Source();
    source.setPets(Arrays.asList("mouse"));
    TargetWithoutSetter target = SourceTargetMapperStrategySetterPreferred.INSTANCE.toTargetDontUseAdder(source);
    assertThat(target).isNotNull();
    assertThat(target.getPets().size()).isEqualTo(1);
    assertThat(target.getPets().get(0)).isEqualTo(2L);
    assertTrue(AdderUsageObserver.isUsed());
}
Also used : TargetWithoutSetter(org.mapstruct.ap.test.collection.adder._target.TargetWithoutSetter) GeneratedSource(org.mapstruct.ap.testutil.runner.GeneratedSource) Source(org.mapstruct.ap.test.collection.adder.source.Source) SingleElementSource(org.mapstruct.ap.test.collection.adder.source.SingleElementSource) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Aggregations

TargetWithoutSetter (org.mapstruct.ap.test.collection.adder._target.TargetWithoutSetter)1 SingleElementSource (org.mapstruct.ap.test.collection.adder.source.SingleElementSource)1 Source (org.mapstruct.ap.test.collection.adder.source.Source)1 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)1 GeneratedSource (org.mapstruct.ap.testutil.runner.GeneratedSource)1