diff --git a/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java b/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java index 8fdf845c8..bd316ca13 100644 --- a/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java +++ b/processor/src/main/java/org/mapstruct/ap/processor/MapperCreationProcessor.java @@ -173,6 +173,15 @@ public class MapperCreationProcessor implements ModelElementProcessor mappingMethods = new ArrayList( methods.size() ); for ( SourceMethod mappingMethod : methods ) { diff --git a/processor/src/test/java/org/mapstruct/ap/test/decorator/DecoratorTest.java b/processor/src/test/java/org/mapstruct/ap/test/decorator/DecoratorTest.java index a425a0939..c49831cc2 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/decorator/DecoratorTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/decorator/DecoratorTest.java @@ -19,10 +19,14 @@ package org.mapstruct.ap.test.decorator; import java.util.Calendar; +import javax.tools.Diagnostic.Kind; import org.mapstruct.ap.testutil.IssueKey; import org.mapstruct.ap.testutil.MapperTestBase; import org.mapstruct.ap.testutil.WithClasses; +import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult; +import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic; +import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome; import org.testng.annotations.Test; import static org.fest.assertions.Assertions.assertThat; @@ -120,4 +124,22 @@ public class DecoratorTest extends MapperTestBase { assertThat( personDto.getAddress() ).isNotNull(); assertThat( personDto.getAddress().getAddressLine() ).isEqualTo( "42 Ocean View Drive" ); } + + @Test + @WithClasses({ + ErroneousPersonMapper.class, + ErroneousPersonMapperDecorator.class + }) + @ExpectedCompilationOutcome( + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = ErroneousPersonMapper.class, + kind = Kind.ERROR, + line = 27, + messageRegExp = "Specified decorator type is no subtype of the annotated mapper type") + } + ) + public void shouldRaiseErrorInCaseWrongDecoratorTypeIsGiven() { + + } } diff --git a/processor/src/test/java/org/mapstruct/ap/test/decorator/ErroneousPersonMapper.java b/processor/src/test/java/org/mapstruct/ap/test/decorator/ErroneousPersonMapper.java new file mode 100644 index 000000000..46f7a0f2a --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/decorator/ErroneousPersonMapper.java @@ -0,0 +1,35 @@ +/** + * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.decorator; + +import org.mapstruct.DecoratedWith; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; +import org.mapstruct.factory.Mappers; + +@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE) +@DecoratedWith(ErroneousPersonMapperDecorator.class) +public interface ErroneousPersonMapper { + + ErroneousPersonMapper INSTANCE = Mappers.getMapper( ErroneousPersonMapper.class ); + + PersonDto personToPersonDto(Person person); + + AddressDto addressToAddressDto(Address address); +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/decorator/ErroneousPersonMapperDecorator.java b/processor/src/test/java/org/mapstruct/ap/test/decorator/ErroneousPersonMapperDecorator.java new file mode 100644 index 000000000..abedc4ea2 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/decorator/ErroneousPersonMapperDecorator.java @@ -0,0 +1,22 @@ +/** + * Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.decorator; + +public abstract class ErroneousPersonMapperDecorator { +}