Search in sources :

Example 6 with Target

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

the class AdderTest method testShouldFallBackToDaliSingularInAbsenceOfHumanSingular.

@ProcessorTest
public void testShouldFallBackToDaliSingularInAbsenceOfHumanSingular() {
    AdderUsageObserver.setUsed(false);
    SourceTeeth source = new SourceTeeth();
    source.setTeeth(Arrays.asList("moler"));
    TargetDali target = SourceTargetMapper.INSTANCE.toTargetDali(source);
    assertThat(target).isNotNull();
    assertThat(target.getTeeth().size()).isEqualTo(1);
    assertThat(target.getTeeth().get(0)).isEqualTo(3);
    assertTrue(AdderUsageObserver.isUsed());
}
Also used : TargetDali(org.mapstruct.ap.test.collection.adder._target.TargetDali) SourceTeeth(org.mapstruct.ap.test.collection.adder.source.SourceTeeth) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 7 with Target

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

the class AdderTest method testSingleElementSource.

@IssueKey("242")
@ProcessorTest
public void testSingleElementSource() {
    AdderUsageObserver.setUsed(false);
    SingleElementSource source = new SingleElementSource();
    source.setPet("mouse");
    Target target = SourceTargetMapper.INSTANCE.fromSingleElementSource(source);
    assertThat(target).isNotNull();
    assertThat(target.getPets().size()).isEqualTo(1);
    assertThat(target.getPets().get(0)).isEqualTo(2L);
    assertTrue(AdderUsageObserver.isUsed());
}
Also used : SingleElementSource(org.mapstruct.ap.test.collection.adder.source.SingleElementSource) Target(org.mapstruct.ap.test.collection.adder._target.Target) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 8 with Target

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

the class AdderTest method testshouldFallBackToDaliSingularInAbsenseOfHumanSingular.

@Test
public void testshouldFallBackToDaliSingularInAbsenseOfHumanSingular() {
    AdderUsageObserver.setUsed(false);
    SourceTeeth source = new SourceTeeth();
    source.setTeeth(Arrays.asList("moler"));
    TargetDali target = SourceTargetMapper.INSTANCE.toTargetDali(source);
    assertThat(target).isNotNull();
    assertThat(target.getTeeth().size()).isEqualTo(1);
    assertThat(target.getTeeth().get(0)).isEqualTo(3);
    assertTrue(AdderUsageObserver.isUsed());
}
Also used : TargetDali(org.mapstruct.ap.test.collection.adder._target.TargetDali) SourceTeeth(org.mapstruct.ap.test.collection.adder.source.SourceTeeth) Test(org.junit.Test)

Example 9 with Target

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

the class AdderTest method testAddViaTargetType.

@ProcessorTest
public void testAddViaTargetType() {
    AdderUsageObserver.setUsed(false);
    Source source = new Source();
    source.setPets(Arrays.asList("mouse"));
    TargetViaTargetType target = SourceTargetMapper.INSTANCE.toTargetViaTargetType(source);
    assertThat(target).isNotNull();
    assertThat(target.getPets().size()).isEqualTo(1);
    assertThat(target.getPets().get(0)).isNotNull();
    assertThat(target.getPets().get(0).getValue()).isEqualTo(2L);
    assertTrue(AdderUsageObserver.isUsed());
}
Also used : TargetViaTargetType(org.mapstruct.ap.test.collection.adder._target.TargetViaTargetType) 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)

Example 10 with Target

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

the class AdderTest method testAdd.

@IssueKey("241")
@ProcessorTest
public void testAdd() throws DogException {
    AdderUsageObserver.setUsed(false);
    Source source = new Source();
    source.setPets(Arrays.asList("mouse"));
    Target target = SourceTargetMapper.INSTANCE.toTarget(source);
    assertThat(target).isNotNull();
    assertThat(target.getPets().size()).isEqualTo(1);
    assertThat(target.getPets().get(0)).isEqualTo(2L);
    assertTrue(AdderUsageObserver.isUsed());
}
Also used : Target(org.mapstruct.ap.test.collection.adder._target.Target) 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) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Aggregations

ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)14 SingleElementSource (org.mapstruct.ap.test.collection.adder.source.SingleElementSource)9 Source (org.mapstruct.ap.test.collection.adder.source.Source)8 IssueKey (org.mapstruct.ap.testutil.IssueKey)8 GeneratedSource (org.mapstruct.ap.testutil.runner.GeneratedSource)8 Target (org.mapstruct.ap.test.collection.adder._target.Target)6 SourceTeeth (org.mapstruct.ap.test.collection.adder.source.SourceTeeth)3 ListAssert (org.assertj.core.api.ListAssert)2 Test (org.junit.Test)2 Target (org.mapstruct.ap.test.bugs._1170._target.Target)2 Source (org.mapstruct.ap.test.bugs._1170.source.Source)2 TargetDali (org.mapstruct.ap.test.collection.adder._target.TargetDali)2 Target2 (org.mapstruct.ap.test.collection.adder._target.Target2)1 TargetHuman (org.mapstruct.ap.test.collection.adder._target.TargetHuman)1 TargetOnlyGetter (org.mapstruct.ap.test.collection.adder._target.TargetOnlyGetter)1 TargetViaTargetType (org.mapstruct.ap.test.collection.adder._target.TargetViaTargetType)1 TargetWithAnimals (org.mapstruct.ap.test.collection.adder._target.TargetWithAnimals)1 TargetWithoutSetter (org.mapstruct.ap.test.collection.adder._target.TargetWithoutSetter)1 Foo (org.mapstruct.ap.test.collection.adder.source.Foo)1 Source2 (org.mapstruct.ap.test.collection.adder.source.Source2)1