Search in sources :

Example 1 with Source

use of org.mapstruct.ap.test.bugs._1170.source.Source 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 2 with Source

use of org.mapstruct.ap.test.bugs._1170.source.Source 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 3 with Source

use of org.mapstruct.ap.test.bugs._1170.source.Source in project mapstruct by mapstruct.

the class Issue1269Test method shouldMapNestedPropertiesCorrectly.

@ProcessorTest
public void shouldMapNestedPropertiesCorrectly() {
    VehicleTypeInfo sourceTypeInfo = new VehicleTypeInfo("Opel", "Corsa", 3);
    List<VehicleImage> sourceImages = Arrays.asList(new VehicleImage(100, "something"), new VehicleImage(150, "somethingElse"));
    Vehicle source = new Vehicle(sourceTypeInfo, sourceImages);
    VehicleDto target = VehicleMapper.INSTANCE.map(source);
    assertThat(target.getVehicleInfo()).isNotNull();
    assertThat(target.getVehicleInfo().getDoors()).isEqualTo(3);
    assertThat(target.getVehicleInfo().getType()).isEqualTo("Opel");
    assertThat(target.getVehicleInfo().getName()).isEqualTo("Corsa");
    assertThat(target.getVehicleInfo().getImages()).hasSize(2);
    assertThat(target.getVehicleInfo().getImages().get(0)).isEqualToComparingFieldByField(sourceImages.get(0));
    assertThat(target.getVehicleInfo().getImages().get(1)).isEqualToComparingFieldByField(sourceImages.get(1));
}
Also used : Vehicle(org.mapstruct.ap.test.bugs._1269.model.Vehicle) VehicleDto(org.mapstruct.ap.test.bugs._1269.dto.VehicleDto) VehicleImage(org.mapstruct.ap.test.bugs._1269.model.VehicleImage) VehicleTypeInfo(org.mapstruct.ap.test.bugs._1269.model.VehicleTypeInfo) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 4 with Source

use of org.mapstruct.ap.test.bugs._1170.source.Source in project mapstruct by mapstruct.

the class Issue892Test method compiles.

@ProcessorTest
public void compiles() {
    Source src = new Source();
    src.setType(42);
    Target target = Mappers.getMapper(Issue892Mapper.class).toTarget(src);
    assertThat(target.getType()).isEqualTo(42);
}
Also used : Target(org.mapstruct.ap.test.bugs._892.Issue892Mapper.Target) Source(org.mapstruct.ap.test.bugs._892.Issue892Mapper.Source) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 5 with Source

use of org.mapstruct.ap.test.bugs._1170.source.Source in project mapstruct by mapstruct.

the class Issue2195Test method test.

@ProcessorTest
@WithClasses(Issue2195Mapper.class)
public void test() {
    Source source = new Source();
    source.setName("JohnDoe");
    TargetBase target = Issue2195Mapper.INSTANCE.map(source);
    assertThat(target).isInstanceOf(Target.class);
}
Also used : TargetBase(org.mapstruct.ap.test.bugs._2195.dto.TargetBase) Source(org.mapstruct.ap.test.bugs._2195.dto.Source) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)7 ListAssert (org.assertj.core.api.ListAssert)2 Target (org.mapstruct.ap.test.bugs._1170._target.Target)2 Source (org.mapstruct.ap.test.bugs._1170.source.Source)2 IssueKey (org.mapstruct.ap.testutil.IssueKey)2 WithClasses (org.mapstruct.ap.testutil.WithClasses)2 VehicleDto (org.mapstruct.ap.test.bugs._1269.dto.VehicleDto)1 Vehicle (org.mapstruct.ap.test.bugs._1269.model.Vehicle)1 VehicleImage (org.mapstruct.ap.test.bugs._1269.model.VehicleImage)1 VehicleTypeInfo (org.mapstruct.ap.test.bugs._1269.model.VehicleTypeInfo)1 Source (org.mapstruct.ap.test.bugs._2195.dto.Source)1 TargetBase (org.mapstruct.ap.test.bugs._2195.dto.TargetBase)1 SourceChild (org.mapstruct.ap.test.bugs._2318.Issue2318Mapper.SourceChild)1 TargetChild (org.mapstruct.ap.test.bugs._2318.Issue2318Mapper.TargetChild)1 Car (org.mapstruct.ap.test.bugs._581.source.Car)1 Source (org.mapstruct.ap.test.bugs._892.Issue892Mapper.Source)1 Target (org.mapstruct.ap.test.bugs._892.Issue892Mapper.Target)1