@Test public void testRenderUnknownError() throws JSONException { SelendroidResponse response = new SelendroidResponse("my-session", StatusCode.UNKNOWN_ERROR, new RuntimeException()); JSONObject rendered = new JSONObject(response.render()); assertEquals("my-session", rendered.getString("sessionId")); assertEquals(StatusCode.UNKNOWN_ERROR.getCode(), rendered.getLong("status")); assertEquals("java.lang.RuntimeException", rendered.getJSONObject("value").getString("class")); Assert.assertTrue(rendered.getJSONObject("value").getString("message").startsWith( String.format("java.lang.RuntimeException%n\tat io.selendroid.server.common.SelendroidResponseTest"))); }
@Override public String render() { JSONObject o = new JSONObject(); try { if (sessionId != null) { o.put("sessionId", sessionId); } o.put("status", status); if (value != null) { o.put("value", value); } } catch (JSONException e) { System.out.println("Cannot render response: " + e.getMessage()); } return o.toString(); }
SelendroidResponse implements Response { @Override public String render() { JSONObject o = new JSONObject(); try { if (sessionId != null) { o.put("sessionId", sessionId); } o.put("status", status); if (value != null) { o.put("value", value); } } catch (JSONException e) { System.out.println("Cannot render response: " + e.getMessage()); } return o.toString(); } }
SelendroidResponse implements Response { @Override public String render() { JSONObject o = new JSONObject(); try { if (sessionId != null) { o.put("sessionId", sessionId); } o.put("status", status); if (value != null) { o.put("value", value); } } catch (JSONException e) { System.out.println("Cannot render response: " + e.getMessage()); } return o.toString(); } private  SelendroidResponse(String sessionId, int status, Throwable e); private  SelendroidResponse(String sessionId, int status, Throwable e, String messagePrefix); private  SelendroidResponse(String sessionId, int status, Object value);  SelendroidResponse(String sessionId, Object value);  SelendroidResponse(String sessionId, StatusCode status, JSONObject value);  SelendroidResponse(String sessionId, StatusCode status, Object value);  SelendroidResponse(String sessionId, StatusCode status, Throwable e); }
SelendroidResponse implements Response { @Override public String render() { JSONObject o = new JSONObject(); try { if (sessionId != null) { o.put("sessionId", sessionId); } o.put("status", status); if (value != null) { o.put("value", value); } } catch (JSONException e) { System.out.println("Cannot render response: " + e.getMessage()); } return o.toString(); } private  SelendroidResponse(String sessionId, int status, Throwable e); private  SelendroidResponse(String sessionId, int status, Throwable e, String messagePrefix); private  SelendroidResponse(String sessionId, int status, Object value);  SelendroidResponse(String sessionId, Object value);  SelendroidResponse(String sessionId, StatusCode status, JSONObject value);  SelendroidResponse(String sessionId, StatusCode status, Object value);  SelendroidResponse(String sessionId, StatusCode status, Throwable e); static SelendroidResponse forCatchAllError(String sessionId, Throwable e); @Override String getSessionId(); int getStatus(); Object getValue(); @Override String render(); }
SelendroidResponse implements Response { @Override public String render() { JSONObject o = new JSONObject(); try { if (sessionId != null) { o.put("sessionId", sessionId); } o.put("status", status); if (value != null) { o.put("value", value); } } catch (JSONException e) { System.out.println("Cannot render response: " + e.getMessage()); } return o.toString(); } private  SelendroidResponse(String sessionId, int status, Throwable e); private  SelendroidResponse(String sessionId, int status, Throwable e, String messagePrefix); private  SelendroidResponse(String sessionId, int status, Object value);  SelendroidResponse(String sessionId, Object value);  SelendroidResponse(String sessionId, StatusCode status, JSONObject value);  SelendroidResponse(String sessionId, StatusCode status, Object value);  SelendroidResponse(String sessionId, StatusCode status, Throwable e); static SelendroidResponse forCatchAllError(String sessionId, Throwable e); @Override String getSessionId(); int getStatus(); Object getValue(); @Override String render();  }