Search in sources :

Example 1 with Target

use of org.mapstruct.ap.test.unmappedtarget.Target in project mapstruct by mapstruct.

the class UnmappedSourceTest method shouldLeaveUnmappedSourcePropertyUnset.

@ProcessorTest
@WithClasses({ Source.class, Target.class, SourceTargetMapper.class })
@ExpectedCompilationOutcome(value = CompilationResult.SUCCEEDED, diagnostics = { @Diagnostic(type = SourceTargetMapper.class, kind = Kind.WARNING, line = 20, message = "Unmapped source property: \"qux\"."), @Diagnostic(type = SourceTargetMapper.class, kind = Kind.WARNING, line = 22, message = "Unmapped source property: \"bar\".") })
public void shouldLeaveUnmappedSourcePropertyUnset() {
    Source source = new Source();
    source.setFoo(42L);
    Target target = SourceTargetMapper.INSTANCE.sourceToTarget(source);
    assertThat(target).isNotNull();
    assertThat(target.getFoo()).isEqualTo(42L);
    assertThat(target.getBar()).isEqualTo(0);
}
Also used : Target(org.mapstruct.ap.test.unmappedtarget.Target) Source(org.mapstruct.ap.test.unmappedtarget.Source) ExpectedCompilationOutcome(org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Aggregations

Source (org.mapstruct.ap.test.unmappedtarget.Source)1 Target (org.mapstruct.ap.test.unmappedtarget.Target)1 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)1 WithClasses (org.mapstruct.ap.testutil.WithClasses)1 ExpectedCompilationOutcome (org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome)1