DataServiceVisitorJsBuilder extends AbstractDataServiceVisitor { @Override void visitMethodElement(String classname, ExecutableElement methodElement, Writer writer) throws IOException { String methodName = methodElement.getSimpleName().toString(); List<String> argumentsType = getArgumentsType(methodElement); List<String> arguments = getArguments(methodElement); TypeMirror returnType = methodElement.getReturnType(); writeMethodComment(getMethodComment(methodElement), argumentsType.iterator(), arguments.iterator(), returnType, writer); writer.append(TAB2).append(methodName).append(SPACEOPTIONAL).append(COLON).append(SPACEOPTIONAL) .append(FUNCTION).append(SPACEOPTIONAL).append(OPENPARENTHESIS); writeArguments(arguments.iterator(), writer); writer.append(CLOSEPARENTHESIS).append(SPACEOPTIONAL).append(OPENBRACE).append(CR); createMethodBody(classname, methodElement, arguments, writer); writer.append(TAB2).append(CLOSEBRACE); } DataServiceVisitorJsBuilder(ProcessingEnvironment environment, FwkWriter fwk);   }
@Test public void visitMethodElement() throws IOException { System.out.println("visitMethodElement"); Writer writer = WriterTest.getMockWriter(); String classname = "packageName.ClassName"; ExecutableElement methodElement = mock(ExecutableElement.class); Name name = mock(Name.class); TypeMirror tm = mock(TypeMirror.class); List<String> argumentsType = new ArrayList<>(); List<String> arguments = new ArrayList<>(); doNothing().when(instance).createMethodBody(eq(classname), any(ExecutableElement.class), anyListOf(String.class), any(Writer.class)); when(methodElement.getSimpleName()).thenReturn(name); when(name.toString()).thenReturn("ClassName"); doReturn(argumentsType).when(instance).getArgumentsType(eq(methodElement)); doReturn(arguments).when(instance).getArguments(eq(methodElement)); doNothing().when(instance).writeArguments(any(Iterator.class), eq(writer)); doReturn("").when(instance).getMethodComment(eq(methodElement)); doNothing().when(instance).writeMethodComment(anyString(), any(Iterator.class), any(Iterator.class), eq(tm), eq(writer)); when(methodElement.getReturnType()).thenReturn(tm); instance.visitMethodElement(classname, methodElement, writer); WriterTest.testBraces(writer); }