use of com.github.javaparser.symbolsolver.reflectionmodel.ReflectionAnnotationDeclaration in project javaparser by javaparser.
the class AnnotationsResolutionTest method solveReflectionMetaAnnotations.
@Test
void solveReflectionMetaAnnotations() {
// parse compilation unit and get annotation expression
CompilationUnit cu = parseSample("Annotations");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "CA");
MethodDeclaration method = Navigator.demandMethod(clazz, "equals");
MarkerAnnotationExpr annotationExpr = (MarkerAnnotationExpr) method.getAnnotation(0);
// resolve annotation expression @Override
ReflectionAnnotationDeclaration resolved = (ReflectionAnnotationDeclaration) annotationExpr.resolve();
// check that the annotation @Override has the annotations @Target and @Retention, but not @Documented
assertEquals("java.lang.Override", resolved.getQualifiedName());
assertTrue(resolved.hasDirectlyAnnotation("java.lang.annotation.Target"));
assertTrue(resolved.hasDirectlyAnnotation("java.lang.annotation.Retention"));
assertFalse(resolved.hasDirectlyAnnotation("java.lang.annotation.Documented"));
}
Aggregations