### Question:
JavaSourceVisitor extends ResourceReferenceCollector { public void visit(JavaSource javaSource) { List<Import> imports = javaSource.getImports(); for (Import javaImport : imports) { visit(javaImport); } if (javaSource instanceof Body) { visit((Body) javaSource); } else if (javaSource instanceof JavaAnnotationSource) { visit((JavaAnnotationSource) javaSource); } else if (javaSource instanceof JavaClassSource) { visit((JavaClassSource) javaSource); } else if (javaSource instanceof JavaEnumSource) { visit((JavaEnumSource) javaSource); } else if (javaSource instanceof JavaInterfaceSource) { visit((JavaInterfaceSource) javaSource); } } JavaSourceVisitor(JavaSource javaSource, ClassLoader classLoader, Resource resParts); void visit(JavaSource javaSource); void visit(AnnotationSource<? extends JavaClassSource> annoSource); void visit(Body body); void visit(FieldSource<? extends JavaSource> fieldSource); void visit(JavaAnnotationSource javaAnnoSource); void visit(JavaClassSource javaClassSource); void visit(JavaEnumSource javaEnumSource); void visit(Import javaImport); void visit(JavaInterfaceSource interfaceSource); void visit(MethodSource<? extends JavaClassSource> methodSource); void addJavaResourceReference(String fullyQualifiedName);  }### Answer:
@Test public void visitAnnotationSources() { for ( AnnotationSource annotationSource : javaClassSource.getAnnotations() ) { visitor.visit( annotationSource ); } checkVisitor( Arrays.asList( "ref:java => org.kie.workbench.common.screens.datamodeller.backend.server.indexing.Annotation1" ) ); }
@Test public void visitImports() { for ( Import importSource : javaClassSource.getImports() ) { visitor.visit( importSource ); } checkVisitor( Arrays.asList( "ref:java => java.math.BigDecimal", "ref:java => java.io.Serializable" ) ); }
@Test public void visitFields() { for ( FieldSource fieldSource : javaClassSource.getFields() ) { visitor.visit( fieldSource ); } checkVisitor( Arrays.asList( "ref:java => int", "ref:java => java.math.BigDecimal" ) ); }
@Test public void visitMethods() { for ( MethodSource methodSource : javaClassSource.getMethods() ) { visitor.visit( methodSource ); } checkVisitor( Arrays.asList( "ref:java => int", "ref:java => java.math.BigDecimal", "ref:java => org.kie.workbench.common.screens.datamodeller.backend.server.indexing.Pojo1" ) ); }
@Test public void visitInterface() { visitor.visit( javaInterfaceSource ); checkVisitor( Arrays.asList( "ref:java => int", "ref:java => java.lang.String", "ref:java => org.kie.workbench.common.screens.datamodeller.backend.server.indexing.Annotation1" ) ); }
@Test public void visitEnum() { visitor.visit( javaEnumSource ); checkVisitor( Arrays.asList( "ref:java => int" ) ); }
@Test public void visitJavaClassImplmentingInterfaceWithGenerics() { visitor.visit(javaClassSource2); checkVisitor(Arrays.asList("ref:java => org.kie.workbench.common.screens.datamodeller.backend.server.indexing.Pojo3", "ref:java => java.lang.Object", "ref:java => java.lang.Comparable", "ref:java => int")); }