diff --git a/processor/src/test/java/org/mapstruct/ap/testutil/compilation/annotation/ProcessorOption.java b/processor/src/test/java/org/mapstruct/ap/testutil/compilation/annotation/ProcessorOption.java index 331c3724c..839f0da98 100644 --- a/processor/src/test/java/org/mapstruct/ap/testutil/compilation/annotation/ProcessorOption.java +++ b/processor/src/test/java/org/mapstruct/ap/testutil/compilation/annotation/ProcessorOption.java @@ -19,6 +19,7 @@ package org.mapstruct.ap.testutil.compilation.annotation; import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @@ -31,6 +32,7 @@ import java.lang.annotation.Target; */ @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.TYPE, ElementType.METHOD }) +@Repeatable( ProcessorOptions.class ) public @interface ProcessorOption { /** diff --git a/processor/src/test/java/org/mapstruct/ap/testutil/compilation/annotation/ProcessorOptions.java b/processor/src/test/java/org/mapstruct/ap/testutil/compilation/annotation/ProcessorOptions.java new file mode 100644 index 000000000..a8b240a95 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/testutil/compilation/annotation/ProcessorOptions.java @@ -0,0 +1,35 @@ +/** + * Copyright 2012-2015 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.testutil.compilation.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Contains multiple {@link ProcessorOption} annotations + * + * @author Andreas Gudian + */ +@Retention( RetentionPolicy.RUNTIME ) +@Target( { ElementType.TYPE, ElementType.METHOD } ) +public @interface ProcessorOptions { + ProcessorOption[] value(); +} diff --git a/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingStatement.java b/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingStatement.java index a3e2bd2b3..5992f1aa6 100644 --- a/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingStatement.java +++ b/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingStatement.java @@ -46,6 +46,7 @@ import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult; import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome; import org.mapstruct.ap.testutil.compilation.annotation.ProcessorOption; +import org.mapstruct.ap.testutil.compilation.annotation.ProcessorOptions; import org.mapstruct.ap.testutil.compilation.model.CompilationOutcomeDescriptor; import org.mapstruct.ap.testutil.compilation.model.DiagnosticDescriptor; @@ -262,14 +263,35 @@ class CompilingStatement extends Statement { * @return A list containing the processor options to be used for this test */ private List getProcessorOptions() { - ProcessorOption processorOption = method.getAnnotation( ProcessorOption.class ); + List processorOptions = + getProcessorOptions( + method.getAnnotation( ProcessorOptions.class ), + method.getAnnotation( ProcessorOption.class ) ); - if ( processorOption == null ) { - processorOption = method.getMethod().getDeclaringClass().getAnnotation( ProcessorOption.class ); + if ( processorOptions.isEmpty() ) { + processorOptions = + getProcessorOptions( + method.getMethod().getDeclaringClass().getAnnotation( ProcessorOptions.class ), + method.getMethod().getDeclaringClass().getAnnotation( ProcessorOption.class ) ); } - return processorOption != null ? Arrays.asList( asOptionString( processorOption ) ) - : Collections.emptyList(); + List result = new ArrayList( processorOptions.size() ); + for ( ProcessorOption option : processorOptions ) { + result.add( asOptionString( option ) ); + } + + return result; + } + + private List getProcessorOptions(ProcessorOptions options, ProcessorOption option) { + if ( options != null ) { + return Arrays.asList( options.value() ); + } + else if ( option != null ) { + return Arrays.asList( option ); + } + + return Collections.emptyList(); } private String asOptionString(ProcessorOption processorOption) {