NetworkObjectController implements ParseObjectController { @Override public List<Task<Void>> deleteAllAsync( List<ParseObject.State> states, String sessionToken) { int batchSize = states.size(); List<ParseRESTObjectCommand> commands = new ArrayList<>(batchSize); for (int i = 0; i < batchSize; i++) { ParseObject.State state = states.get(i); ParseRESTObjectCommand command = ParseRESTObjectCommand.deleteObjectCommand( state, sessionToken); commands.add(command); } final List<Task<JSONObject>> batchTasks = ParseRESTObjectBatchCommand.executeBatch(client, commands, sessionToken); List<Task<Void>> tasks = new ArrayList<>(batchSize); for (int i = 0; i < batchSize; i++) { tasks.add(batchTasks.get(i).makeVoid()); } return tasks; } NetworkObjectController(ParseHttpClient client); @Override Task<ParseObject.State> fetchAsync(
            final ParseObject.State state, String sessionToken, final ParseDecoder decoder); @Override Task<ParseObject.State> saveAsync(
            final ParseObject.State state,
            final ParseOperationSet operations,
            String sessionToken,
            final ParseDecoder decoder); @Override List<Task<ParseObject.State>> saveAllAsync(
            List<ParseObject.State> states,
            List<ParseOperationSet> operationsList,
            String sessionToken,
            List<ParseDecoder> decoders); @Override Task<Void> deleteAsync(ParseObject.State state, String sessionToken); @Override List<Task<Void>> deleteAllAsync(
            List<ParseObject.State> states, String sessionToken);  }
@Test public void testDeleteAllAsync() throws Exception { JSONObject objectResponse = new JSONObject(); objectResponse.put("success", new JSONObject()); JSONObject objectResponseAgain = new JSONObject(); JSONObject objectDeleteResultAgain = new JSONObject(); objectDeleteResultAgain.put("code", 101); objectDeleteResultAgain.put("error", "Error"); objectResponseAgain.put("error", objectDeleteResultAgain); JSONArray mockResponse = new JSONArray(); mockResponse.put(objectResponse); mockResponse.put(objectResponseAgain); byte[] contentBytes = mockResponse.toString().getBytes(); ParseHttpResponse response = new ParseHttpResponse.Builder() .setContent(new ByteArrayInputStream(contentBytes)) .setStatusCode(200) .setTotalSize(contentBytes.length) .setContentType("application/json") .build(); ParseHttpClient client = mock(ParseHttpClient.class); when(client.execute(any(ParseHttpRequest.class))).thenReturn(response); List<ParseObject.State> states = new ArrayList<>(); ParseObject.State state = new ParseObject.State.Builder("Test") .objectId("testObjectId") .build(); states.add(state); ParseObject.State stateAgain = new ParseObject.State.Builder("Test") .objectId("testObjectIdAgain") .build(); states.add(stateAgain); NetworkObjectController controller = new NetworkObjectController(client); List<Task<Void>> deleteTaskList = controller.deleteAllAsync(states, "sessionToken"); Task.whenAll(deleteTaskList).waitForCompletion(); assertFalse(deleteTaskList.get(0).isFaulted()); assertTrue(deleteTaskList.get(1).isFaulted()); assertTrue(deleteTaskList.get(1).getError() instanceof ParseException); ParseException parseException = (ParseException) deleteTaskList.get(1).getError(); assertEquals(101, parseException.getCode()); assertEquals("Error", parseException.getMessage()); }