@Test public void testSendInBackgroundFailWithIOException() throws Exception { ParseRequest.setDefaultInitialRetryDelay(1L); ParseHttpClient restClient = mock(ParseHttpClient.class); when(restClient.execute(any(ParseHttpRequest.class))).thenThrow(new IOException()); ParsePushController controller = new ParsePushController(restClient); JSONObject data = new JSONObject(); data.put(ParsePush.KEY_DATA_MESSAGE, "hello world"); ParsePush.State state = new ParsePush.State.Builder() .data(data) .build(); Task<Void> pushTask = controller.sendInBackground(state, "sessionToken"); pushTask.waitForCompletion(); verify(restClient, times(5)).execute(any(ParseHttpRequest.class)); assertTrue(pushTask.isFaulted()); Exception error = pushTask.getError(); assertThat(error, instanceOf(ParseException.class)); assertEquals(ParseException.CONNECTION_FAILED, ((ParseException) error).getCode()); }
public Task<Void> sendInBackground(ParsePush.State state, String sessionToken) { return buildRESTSendPushCommand(state, sessionToken).executeAsync(restClient).makeVoid(); }
ParsePushController { public Task<Void> sendInBackground(ParsePush.State state, String sessionToken) { return buildRESTSendPushCommand(state, sessionToken).executeAsync(restClient).makeVoid(); } }
ParsePushController { public Task<Void> sendInBackground(ParsePush.State state, String sessionToken) { return buildRESTSendPushCommand(state, sessionToken).executeAsync(restClient).makeVoid(); } ParsePushController(ParseHttpClient restClient); }
ParsePushController { public Task<Void> sendInBackground(ParsePush.State state, String sessionToken) { return buildRESTSendPushCommand(state, sessionToken).executeAsync(restClient).makeVoid(); } ParsePushController(ParseHttpClient restClient); Task<Void> sendInBackground(ParsePush.State state, String sessionToken); }
ParsePushController { public Task<Void> sendInBackground(ParsePush.State state, String sessionToken) { return buildRESTSendPushCommand(state, sessionToken).executeAsync(restClient).makeVoid(); } ParsePushController(ParseHttpClient restClient); Task<Void> sendInBackground(ParsePush.State state, String sessionToken);  }