AbstractDataServiceVisitor implements ElementVisitor<String, Writer> ,ProcessorConstants { @Override public String visitType(TypeElement typeElement, Writer writer) { String classname = typeElement.getQualifiedName().toString(); try { _visitType(typeElement, writer); } catch (IOException ex) { StringBuilder msg = getStringBuilder().append("Cannot Create service : ").append(classname).append(" cause IOException on writer"); messager.printMessage(Diagnostic.Kind.ERROR, msg); } return null; } AbstractDataServiceVisitor(ProcessingEnvironment environment); @Override String visitType(TypeElement typeElement, Writer writer); @Override String visit(Element e, Writer p); @Override String visit(Element e); @Override String visitPackage(PackageElement e, Writer p); @Override String visitVariable(VariableElement e, Writer p); @Override String visitExecutable(ExecutableElement e, Writer p); @Override String visitTypeParameter(TypeParameterElement e, Writer p); @Override String visitUnknown(Element e, Writer p);  }
@Test public void testVisitType() throws IOException { System.out.println("visitType"); TypeElement typeElement = mock(TypeElement.class); Writer writer = getMockWriter(); Name qname = mock(Name.class); when(typeElement.getQualifiedName()).thenReturn(qname); when(qname.toString()).thenReturn("packageName.ClassName"); doNothing().when(instance)._visitType(eq(typeElement), eq(writer)); String res = instance.visitType(typeElement, writer); assertThat(res).isNull(); }