### Question:
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();  }### Answer:
@Test public void testGetFunctionLine_StringArg() { JavascriptObject mockObject = Mockito.mock(JavascriptObject.class); String method = "myMethod"; List<Object> args = new ArrayList<>(); args.add( "arg1" ); when(mockObject.getVariableName()).thenReturn("myVar"); JavascriptFunctionLine line = new JavascriptFunctionLine(mockObject, method, args); assertEquals( "myVar.myMethod(arg1);\n", line.getFunctionLine() ); }
@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() ); }