@Test public void testCallFunctionWithNullResult() throws Exception { String content = "{ result: null }"; ParseHttpResponse mockResponse = new ParseHttpResponse.Builder() .setStatusCode(200) .setTotalSize((long) content.length()) .setContent(new ByteArrayInputStream(content.getBytes())) .build(); ParseHttpClient restClient = mockParseHttpClientWithReponse(mockResponse); ParseCloudCodeController controller = new ParseCloudCodeController(restClient); Task<String> cloudCodeTask = controller.callFunctionInBackground( "test", new HashMap<String, Object>(), "sessionToken"); ParseTaskUtils.wait(cloudCodeTask); verify(restClient, times(1)).execute(any(ParseHttpRequest.class)); String result = cloudCodeTask.getResult(); assertEquals(null, result); }
public <T> Task<T> callFunctionInBackground(final String name, final Map<String, ?> params, String sessionToken) { ParseRESTCommand command = ParseRESTCloudCommand.callFunctionCommand( name, params, sessionToken); return command.executeAsync(restClient).onSuccess(new Continuation<JSONObject, T>() { @Override public T then(Task<JSONObject> task) { @SuppressWarnings("unchecked") T result = (T) convertCloudResponse(task.getResult()); return result; } }); }
ParseCloudCodeController { public <T> Task<T> callFunctionInBackground(final String name, final Map<String, ?> params, String sessionToken) { ParseRESTCommand command = ParseRESTCloudCommand.callFunctionCommand( name, params, sessionToken); return command.executeAsync(restClient).onSuccess(new Continuation<JSONObject, T>() { @Override public T then(Task<JSONObject> task) { @SuppressWarnings("unchecked") T result = (T) convertCloudResponse(task.getResult()); return result; } }); } }
ParseCloudCodeController { public <T> Task<T> callFunctionInBackground(final String name, final Map<String, ?> params, String sessionToken) { ParseRESTCommand command = ParseRESTCloudCommand.callFunctionCommand( name, params, sessionToken); return command.executeAsync(restClient).onSuccess(new Continuation<JSONObject, T>() { @Override public T then(Task<JSONObject> task) { @SuppressWarnings("unchecked") T result = (T) convertCloudResponse(task.getResult()); return result; } }); } ParseCloudCodeController(ParseHttpClient restClient); }
ParseCloudCodeController { public <T> Task<T> callFunctionInBackground(final String name, final Map<String, ?> params, String sessionToken) { ParseRESTCommand command = ParseRESTCloudCommand.callFunctionCommand( name, params, sessionToken); return command.executeAsync(restClient).onSuccess(new Continuation<JSONObject, T>() { @Override public T then(Task<JSONObject> task) { @SuppressWarnings("unchecked") T result = (T) convertCloudResponse(task.getResult()); return result; } }); } ParseCloudCodeController(ParseHttpClient restClient); Task<T> callFunctionInBackground(final String name,
                                                final Map<String, ?> params, String sessionToken); }
ParseCloudCodeController { public <T> Task<T> callFunctionInBackground(final String name, final Map<String, ?> params, String sessionToken) { ParseRESTCommand command = ParseRESTCloudCommand.callFunctionCommand( name, params, sessionToken); return command.executeAsync(restClient).onSuccess(new Continuation<JSONObject, T>() { @Override public T then(Task<JSONObject> task) { @SuppressWarnings("unchecked") T result = (T) convertCloudResponse(task.getResult()); return result; } }); } ParseCloudCodeController(ParseHttpClient restClient); Task<T> callFunctionInBackground(final String name,
                                                final Map<String, ?> params, String sessionToken);  }