in legacy/java/piranha/src/main/java/com/uber/piranha/testannotations/TestAnnotationResolver.java [214:251]
public ImmutableSet<ResolvedTestAnnotation> resolveAllForMethod(
MethodTree tree, VisitorState state) {
ImmutableSet.Builder<ResolvedTestAnnotation> builder = ImmutableSet.builder();
for (String name : testAnnotationSpecs.keySet()) {
AnnotationTree at =
ASTHelpers.getAnnotationWithSimpleName(tree.getModifiers().getAnnotations(), name);
if (at != null) {
// Find all annotations specs with a matching name
ImmutableCollection<TestAnnotationSpecRecord> candidateAnnotations =
testAnnotationSpecs.get(name);
boolean matchFound = false;
for (TestAnnotationSpecRecord spec : candidateAnnotations) {
Optional<ResolvedTestAnnotation> resolvedSpec = attemptResolveSpec(spec, at, tree, state);
if (resolvedSpec.isPresent()) {
matchFound = true;
builder.add(resolvedSpec.get());
// First match found is sufficient, assume specs of the same name are incompatible
break;
}
}
if (!matchFound) {
throw new AnnotationResolutionException(
String.format(
"Found annotation %s at %s, matching the name of a test annotation "
+ "declared in Piranha's config file. However, the annotation can't be matched "
+ "to any of the specified shapes in this configuration. Candidates are:\n\t%s",
state.getSourceForNode(at),
ASTHelpers.getSymbol(tree).flatName().toString(),
candidateAnnotations
.stream()
.map(a -> a.toString())
.collect(Collectors.joining("\n\t"))));
}
}
}
return builder.build();
}