@Override public Task<Void> then(Task<Void> task) { return getCurrentInstallationController().setAsync(ParseInstallation.this); } });
@Override public Task<Void> then(Task<Void> task) { return getCurrentInstallationController().setAsync(ParseInstallation.this); } });
@Test public void testHandleFetchResultAsync() throws Exception { // Mock currentInstallationController to make setAsync work ParseCurrentInstallationController controller = mock(ParseCurrentInstallationController.class); when(controller.setAsync(any(ParseInstallation.class))).thenReturn(Task.<Void>forResult(null)); ParseCorePlugins.getInstance().registerCurrentInstallationController(controller); // Mock return state ParseInstallation.State state = new ParseInstallation.State.Builder("_Installation") .put("key", "value") .isComplete(true) .build(); ParseInstallation installation = new ParseInstallation(); ParseTaskUtils.wait(installation.handleFetchResultAsync(state)); // Make sure the installation data is correct assertEquals("value", installation.get("key")); // Make sure we set the currentInstallation verify(controller, times(1)).setAsync(installation); }
@Test public void testHandleSaveResultAsync() throws Exception { // Mock currentInstallationController to make setAsync work ParseCurrentInstallationController controller = mock(ParseCurrentInstallationController.class); when(controller.setAsync(any(ParseInstallation.class))).thenReturn(Task.<Void>forResult(null)); ParseCorePlugins.getInstance().registerCurrentInstallationController(controller); // Mock return state ParseInstallation.State state = new ParseInstallation.State.Builder("_Installation") .put("key", "value") .build(); ParseInstallation installation = new ParseInstallation(); installation.put("keyAgain", "valueAgain"); ParseOperationSet operationSet = installation.startSave(); ParseTaskUtils.wait(installation.handleSaveResultAsync(state, operationSet)); // Make sure the installation data is correct assertEquals("value", installation.get("key")); assertEquals("valueAgain", installation.get("keyAgain")); // Make sure we set the currentInstallation verify(controller, times(1)).setAsync(installation); }