use of org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome 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);
}
use of org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome in project mapstruct by mapstruct.
the class MultipleBuilderMapperTest method tooManyBuilderCreationMethods.
@WithClasses({ TooManyBuilderCreationMethodsMapper.class })
@ExpectedCompilationOutcome(value = CompilationResult.SUCCEEDED, diagnostics = { @Diagnostic(type = Case.class, kind = javax.tools.Diagnostic.Kind.WARNING, line = 11, message = "More than one builder creation method for \"org.mapstruct.ap.test.builder.multiple.builder" + ".Case\". Found methods: \"wrongBuilder(), builder()\". Builder will not be used. Consider " + "implementing a custom BuilderProvider SPI.") })
@ProcessorTest
public void tooManyBuilderCreationMethods() {
Case caseTarget = TooManyBuilderCreationMethodsMapper.INSTANCE.map(new Source("test"));
assertThat(caseTarget).isNotNull();
assertThat(caseTarget.getName()).isEqualTo("test");
assertThat(caseTarget.getBuilderCreationMethod()).isNull();
assertThat(caseTarget.getBuildMethod()).isEqualTo("constructor");
}
Aggregations