### Question:
CachedCurrentInstallationController implements ParseCurrentInstallationController { @Override public Task<Void> setAsync(final ParseInstallation installation) { if (!isCurrent(installation)) { return Task.forResult(null); } return taskQueue.enqueue(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> toAwait) throws Exception { return toAwait.continueWithTask(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> task) throws Exception { return store.setAsync(installation); } }).continueWithTask(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> task) throws Exception { installationId.set(installation.getInstallationId()); return task; } }, ParseExecutors.io()); } }); } CachedCurrentInstallationController(
      ParseObjectStore<ParseInstallation> store, InstallationId installationId); @Override Task<Void> setAsync(final ParseInstallation installation); @Override Task<ParseInstallation> getAsync(); @Override Task<Boolean> existsAsync(); @Override void clearFromMemory(); @Override void clearFromDisk(); @Override boolean isCurrent(ParseInstallation installation);  }### Answer:
@Test public void testSetAsyncWithNotCurrentInstallation() throws Exception { CachedCurrentInstallationController controller = new CachedCurrentInstallationController(null, null); ParseInstallation currentInstallationInMemory = mock(ParseInstallation.class); controller.currentInstallation = currentInstallationInMemory; ParseInstallation testInstallation = mock(ParseInstallation.class); ParseTaskUtils.wait(controller.setAsync(testInstallation)); assertSame(currentInstallationInMemory, controller.currentInstallation); assertNotSame(controller.currentInstallation, testInstallation); }
@Test public void testSetAsyncWithCurrentInstallation() throws Exception { InstallationId installationId = mock(InstallationId.class); ParseObjectStore<ParseInstallation> store = mock(ParseObjectStore.class); CachedCurrentInstallationController controller = new CachedCurrentInstallationController(store, installationId); ParseInstallation currentInstallation = mock(ParseInstallation.class); when(currentInstallation.getInstallationId()).thenReturn("testInstallationId"); controller.currentInstallation = currentInstallation; ParseTaskUtils.wait(controller.setAsync(currentInstallation)); verify(store, times(1)).setAsync(currentInstallation); verify(installationId, times(1)).set("testInstallationId"); }