@Test public void testInvokeJavascriptReturnValue_Null() { String arg = "myArg"; Object[] argArray = new Object[] {arg}; String function = "myFunction"; when(mockJsObject.call(function, argArray)).thenReturn(null); String returnValue = testJavascriptObject.invokeJavascriptReturnValue(function, String.class, arg); assertNull( returnValue ); }
protected <T> T invokeJavascriptReturnValue(String function, Class<T> returnType) { Object returnObject = invokeJavascript(function); if (returnObject instanceof JSObject) { try { Constructor<T> constructor = returnType.getConstructor(JSObject.class); return constructor.newInstance((JSObject) returnObject); } catch (Exception ex) { throw new IllegalStateException(ex); } } else { return (T) returnObject; } }
JavascriptObject { protected <T> T invokeJavascriptReturnValue(String function, Class<T> returnType) { Object returnObject = invokeJavascript(function); if (returnObject instanceof JSObject) { try { Constructor<T> constructor = returnType.getConstructor(JSObject.class); return constructor.newInstance((JSObject) returnObject); } catch (Exception ex) { throw new IllegalStateException(ex); } } else { return (T) returnObject; } } }
JavascriptObject { protected <T> T invokeJavascriptReturnValue(String function, Class<T> returnType) { Object returnObject = invokeJavascript(function); if (returnObject instanceof JSObject) { try { Constructor<T> constructor = returnType.getConstructor(JSObject.class); return constructor.newInstance((JSObject) returnObject); } catch (Exception ex) { throw new IllegalStateException(ex); } } else { return (T) returnObject; } } protected  JavascriptObject(); protected  JavascriptObject(String type); protected  JavascriptObject( String type, String stringRepresentation ); protected  JavascriptObject(String type, Object... args); protected  JavascriptObject(String type, Object[] ary, boolean isArray); protected  JavascriptObject(String type, JSObject jsObject); }
JavascriptObject { protected <T> T invokeJavascriptReturnValue(String function, Class<T> returnType) { Object returnObject = invokeJavascript(function); if (returnObject instanceof JSObject) { try { Constructor<T> constructor = returnType.getConstructor(JSObject.class); return constructor.newInstance((JSObject) returnObject); } catch (Exception ex) { throw new IllegalStateException(ex); } } else { return (T) returnObject; } } protected  JavascriptObject(); protected  JavascriptObject(String type); protected  JavascriptObject( String type, String stringRepresentation ); protected  JavascriptObject(String type, Object... args); protected  JavascriptObject(String type, Object[] ary, boolean isArray); protected  JavascriptObject(String type, JSObject jsObject); JSObject getJSObject(); String getVariableName(); }
JavascriptObject { protected <T> T invokeJavascriptReturnValue(String function, Class<T> returnType) { Object returnObject = invokeJavascript(function); if (returnObject instanceof JSObject) { try { Constructor<T> constructor = returnType.getConstructor(JSObject.class); return constructor.newInstance((JSObject) returnObject); } catch (Exception ex) { throw new IllegalStateException(ex); } } else { return (T) returnObject; } } protected  JavascriptObject(); protected  JavascriptObject(String type); protected  JavascriptObject( String type, String stringRepresentation ); protected  JavascriptObject(String type, Object... args); protected  JavascriptObject(String type, Object[] ary, boolean isArray); protected  JavascriptObject(String type, JSObject jsObject); JSObject getJSObject(); String getVariableName();  }