JsCacheRemoveVisitor implements ElementVisitor<Void, Writer> { @Override public Void visitType(TypeElement e, Writer p) { List<ExecutableElement> methodsIn = ElementFilter.methodsIn(e.getEnclosedElements()); for (ExecutableElement executableElement : methodsIn) { visitExecutable(executableElement, p); } return null; } JsCacheRemoveVisitor(ProcessingEnvironment environment); @Override Void visit(Element e, Writer p); @Override Void visit(Element e); @Override Void visitPackage(PackageElement e, Writer p); @Override Void visitType(TypeElement e, Writer p); @Override Void visitVariable(VariableElement e, Writer p); @Override Void visitExecutable(ExecutableElement e, Writer p); @Override Void visitTypeParameter(TypeParameterElement e, Writer p); @Override Void visitUnknown(Element e, Writer p);  }
@Test public void testVisitType() { System.out.println("visitType"); TypeElement te = mock(TypeElement.class); Element elt0 = mock(ExecutableElement.class); when(elt0.getKind()).thenReturn(ElementKind.METHOD); Element elt1 = mock(ExecutableElement.class); when(elt1.getKind()).thenReturn(ElementKind.METHOD); Element elt2 = mock(Element.class); Writer writer = mock(Writer.class); List elts = Arrays.asList(elt0, elt1, elt2); when(te.getEnclosedElements()).thenReturn(elts); doReturn(null).when(instance).visitExecutable(any(ExecutableElement.class), eq(writer)); Void result = instance.visitType(te, writer); verify(instance, times(2)).visitExecutable(any(ExecutableElement.class), eq(writer)); assertThat(result).isNull(); }