Introduce @Template and @TemplateCollection annotations

This commit is contained in:
Rick Ossendrijver
2021-12-22 15:28:01 +01:00
parent 00012c6aa8
commit 37dbf0d6ec
2 changed files with 43 additions and 0 deletions

View File

@@ -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();
}

View File

@@ -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.
*
* <p>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();
}