NetworkQueryController extends AbstractQueryController { @Override public <T extends ParseObject> Task<Integer> countAsync( ParseQuery.State<T> state, ParseUser user, Task<Void> cancellationToken) { String sessionToken = user != null ? user.getSessionToken() : null; return countAsync(state, sessionToken, cancellationToken); } NetworkQueryController(ParseHttpClient restClient); @Override Task<List<T>> findAsync(
            ParseQuery.State<T> state, ParseUser user, Task<Void> cancellationToken); @Override Task<Integer> countAsync(
            ParseQuery.State<T> state, ParseUser user, Task<Void> cancellationToken);  }
@Test public void testCountAsyncWithSessionToken() throws Exception { JSONObject mockResponse = new JSONObject(); mockResponse.put("count", 2); ParseHttpClient restClient = ParseTestUtils.mockParseHttpClientWithResponse(mockResponse, 200, "OK"); ParseQuery.State mockState = mock(ParseQuery.State.class); when(mockState.className()).thenReturn("Test"); when(mockState.selectedKeys()).thenReturn(null); when(mockState.constraints()).thenReturn(new ParseQuery.QueryConstraints()); NetworkQueryController controller = new NetworkQueryController(restClient); Task<Integer> countTask = controller.countAsync(mockState, "sessionToken", null); ParseTaskUtils.wait(countTask); int count = countTask.getResult(); assertEquals(2, count); }