@Test public void testConvertCloudResponseJsonArrayResponse() throws Exception { ParseHttpClient restClient = mock(ParseHttpClient.class); ParseCloudCodeController controller = new ParseCloudCodeController(restClient); JSONArray response = new JSONArray(); response.put(0, "test"); response.put(1, true); response.put(2, 2); Object result = controller.convertCloudResponse(response); assertThat(result, instanceOf(List.class)); List listResult = (List) result; assertEquals(3, listResult.size()); assertEquals("test", listResult.get(0)); assertEquals(true, listResult.get(1)); assertEquals(2, listResult.get(2)); }
Object convertCloudResponse(Object result) { if (result instanceof JSONObject) { JSONObject jsonResult = (JSONObject) result; if (jsonResult.isNull("result")) { return null; } result = jsonResult.opt("result"); } ParseDecoder decoder = ParseDecoder.get(); Object finalResult = decoder.decode(result); if (finalResult != null) { return finalResult; } return result; }
ParseCloudCodeController { Object convertCloudResponse(Object result) { if (result instanceof JSONObject) { JSONObject jsonResult = (JSONObject) result; if (jsonResult.isNull("result")) { return null; } result = jsonResult.opt("result"); } ParseDecoder decoder = ParseDecoder.get(); Object finalResult = decoder.decode(result); if (finalResult != null) { return finalResult; } return result; } }
ParseCloudCodeController { Object convertCloudResponse(Object result) { if (result instanceof JSONObject) { JSONObject jsonResult = (JSONObject) result; if (jsonResult.isNull("result")) { return null; } result = jsonResult.opt("result"); } ParseDecoder decoder = ParseDecoder.get(); Object finalResult = decoder.decode(result); if (finalResult != null) { return finalResult; } return result; } ParseCloudCodeController(ParseHttpClient restClient); }
ParseCloudCodeController { Object convertCloudResponse(Object result) { if (result instanceof JSONObject) { JSONObject jsonResult = (JSONObject) result; if (jsonResult.isNull("result")) { return null; } result = jsonResult.opt("result"); } ParseDecoder decoder = ParseDecoder.get(); Object finalResult = decoder.decode(result); if (finalResult != null) { return finalResult; } return result; } ParseCloudCodeController(ParseHttpClient restClient); Task<T> callFunctionInBackground(final String name,
                                                final Map<String, ?> params, String sessionToken); }
ParseCloudCodeController { Object convertCloudResponse(Object result) { if (result instanceof JSONObject) { JSONObject jsonResult = (JSONObject) result; if (jsonResult.isNull("result")) { return null; } result = jsonResult.opt("result"); } ParseDecoder decoder = ParseDecoder.get(); Object finalResult = decoder.decode(result); if (finalResult != null) { return finalResult; } return result; } ParseCloudCodeController(ParseHttpClient restClient); Task<T> callFunctionInBackground(final String name,
                                                final Map<String, ?> params, String sessionToken);  }