diff --git a/refaster-support/src/main/java/tech/picnic/errorprone/annotations/Template.java b/refaster-support/src/main/java/tech/picnic/errorprone/annotations/Template.java new file mode 100644 index 00000000..8a89ac3c --- /dev/null +++ b/refaster-support/src/main/java/tech/picnic/errorprone/annotations/Template.java @@ -0,0 +1,20 @@ +package tech.picnic.errorprone.annotations; + +import java.lang.annotation.ElementType; +import javax.annotation.meta.TypeQualifierDefault; + +/** + * Links the test method to the Refaster template under test. This allows for more extensive + * automatic verification of the tests. For instance, verify that every template has a test and the + * provided Refaster template _does_ change the content of the test method when it is applied. + */ +@TypeQualifierDefault(ElementType.METHOD) +public @interface Template { + /** + * The class of the Refaster template that should be applied to the method body of the test + * method. + * + * @return class of the Refaster template + */ + Class value(); +} diff --git a/refaster-support/src/main/java/tech/picnic/errorprone/annotations/TemplateCollection.java b/refaster-support/src/main/java/tech/picnic/errorprone/annotations/TemplateCollection.java new file mode 100644 index 00000000..4f6e21bd --- /dev/null +++ b/refaster-support/src/main/java/tech/picnic/errorprone/annotations/TemplateCollection.java @@ -0,0 +1,23 @@ +package tech.picnic.errorprone.annotations; + +import java.lang.annotation.ElementType; +import javax.annotation.meta.TypeQualifierDefault; + +/** + * Links the `*TemplatesTest{Input,Output} file to the collection of Refaster templates that are + * tested in the class annotated with this annotation. As a value it should reference a class that + * contains a collection of Refaster templates. + * + *

As a result of this annotation, we can perform additional validations. For instance, make sure + * that the order of the templates matches the order in which the Refaster templates are defined. + */ +@TypeQualifierDefault(ElementType.TYPE) +public @interface TemplateCollection { + /** + * The class of the Refaster template that should be applied to the method body of the test + * method. + * + * @return class of the Refaster template + */ + Class value(); +}