@Test public void testGetFunctionLine_JavascriptArg() { JavascriptObject mockObject = Mockito.mock(JavascriptObject.class); JavascriptObject javascriptArg = Mockito.mock(JavascriptObject.class); String method = "myMethod"; List<Object> args = new ArrayList<>(); args.add( javascriptArg ); when(mockObject.getVariableName()).thenReturn("myVar"); when(javascriptArg.getVariableName()).thenReturn("myJavascriptArg"); JavascriptFunctionLine line = new JavascriptFunctionLine(mockObject, method, args); assertEquals( "myVar.myMethod(myJavascriptArg);\n", line.getFunctionLine() ); }
public String getFunctionLine() { StringBuilder sb = new StringBuilder(); sb.append( object.getVariableName() ).append(".").append(method); sb.append("("); for( Object arg : args ) { if( arg instanceof JavascriptObject) { sb.append( ((JavascriptObject) arg).getVariableName() ); } else { sb.append( arg.toString() ); } sb.append(","); } sb.deleteCharAt( sb.length()-1); sb.append(");\n"); return sb.toString(); }
JavascriptFunctionLine { public String getFunctionLine() { StringBuilder sb = new StringBuilder(); sb.append( object.getVariableName() ).append(".").append(method); sb.append("("); for( Object arg : args ) { if( arg instanceof JavascriptObject) { sb.append( ((JavascriptObject) arg).getVariableName() ); } else { sb.append( arg.toString() ); } sb.append(","); } sb.deleteCharAt( sb.length()-1); sb.append(");\n"); return sb.toString(); } }
JavascriptFunctionLine { public String getFunctionLine() { StringBuilder sb = new StringBuilder(); sb.append( object.getVariableName() ).append(".").append(method); sb.append("("); for( Object arg : args ) { if( arg instanceof JavascriptObject) { sb.append( ((JavascriptObject) arg).getVariableName() ); } else { sb.append( arg.toString() ); } sb.append(","); } sb.deleteCharAt( sb.length()-1); sb.append(");\n"); return sb.toString(); } JavascriptFunctionLine(JavascriptObject object, String method, List<Object> args); }
JavascriptFunctionLine { public String getFunctionLine() { StringBuilder sb = new StringBuilder(); sb.append( object.getVariableName() ).append(".").append(method); sb.append("("); for( Object arg : args ) { if( arg instanceof JavascriptObject) { sb.append( ((JavascriptObject) arg).getVariableName() ); } else { sb.append( arg.toString() ); } sb.append(","); } sb.deleteCharAt( sb.length()-1); sb.append(");\n"); return sb.toString(); } JavascriptFunctionLine(JavascriptObject object, String method, List<Object> args); String getFunctionLine(); }
JavascriptFunctionLine { public String getFunctionLine() { StringBuilder sb = new StringBuilder(); sb.append( object.getVariableName() ).append(".").append(method); sb.append("("); for( Object arg : args ) { if( arg instanceof JavascriptObject) { sb.append( ((JavascriptObject) arg).getVariableName() ); } else { sb.append( arg.toString() ); } sb.append(","); } sb.deleteCharAt( sb.length()-1); sb.append(");\n"); return sb.toString(); } JavascriptFunctionLine(JavascriptObject object, String method, List<Object> args); String getFunctionLine();  }