DataServiceVisitorJsBuilder extends AbstractDataServiceVisitor { @Override void _visitType(TypeElement typeElement, Writer writer) throws IOException { String jsclsname = getJsClassname(typeElement); String instanceName = getJsInstancename(jsclsname); fwk.writeHeaderService(writer, instanceName); String classname = typeElement.getQualifiedName().toString(); writer.append(TAB).append("var _ds").append(SPACEOPTIONAL).append(EQUALS).append(SPACEOPTIONAL).append(QUOTE).append(classname).append(QUOTE).append(SEMICOLON).append(CR); writer.append(TAB).append("return").append(SPACEOPTIONAL).append(OPENBRACE).append(CR); browseAndWriteMethods(getOrderedMethods(typeElement, new MethodComparator()), classname, writer); writer.append(CR); writer.append(TAB).append(CLOSEBRACE).append(SEMICOLON).append(CR); fwk.writeFooterService(writer); } DataServiceVisitorJsBuilder(ProcessingEnvironment environment, FwkWriter fwk);   }
@Test public void test_VisitType() throws IOException { System.out.println("_visitType"); TypeElement typeElement = mock(TypeElement.class); Writer writer = WriterTest.getMockWriter(); doNothing().when(instance).browseAndWriteMethods(anyListOf(ExecutableElement.class), anyString(), eq(writer)); doReturn(null).when(instance).getOrderedMethods(eq(typeElement), any(Comparator.class)); doReturn("ClassName").when(instance).getJsClassname(eq(typeElement)); Name qname = mock(Name.class); List methodElements = new ArrayList(); when(typeElement.getQualifiedName()).thenReturn(qname); when(qname.toString()).thenReturn("packageName.ClassName"); when(typeElement.getEnclosedElements()).thenReturn(methodElements); instance._visitType(typeElement, writer); verify(writer).append(eq("className")); verify(writer).append(eq("packageName.ClassName")); }