@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); }
@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) { return toAwait.continueWithTask(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> task) { return store.setAsync(installation); } }).continueWithTask(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> task) { installationId.set(installation.getInstallationId()); return task; } }, ParseExecutors.io()); } }); }
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) { return toAwait.continueWithTask(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> task) { return store.setAsync(installation); } }).continueWithTask(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> task) { installationId.set(installation.getInstallationId()); return task; } }, ParseExecutors.io()); } }); } }
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) { return toAwait.continueWithTask(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> task) { return store.setAsync(installation); } }).continueWithTask(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> task) { installationId.set(installation.getInstallationId()); return task; } }, ParseExecutors.io()); } }); } CachedCurrentInstallationController(
            ParseObjectStore<ParseInstallation> store, InstallationId installationId); }
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) { return toAwait.continueWithTask(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> task) { return store.setAsync(installation); } }).continueWithTask(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> task) { 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); }
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) { return toAwait.continueWithTask(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> task) { return store.setAsync(installation); } }).continueWithTask(new Continuation<Void, Task<Void>>() { @Override public Task<Void> then(Task<Void> task) { 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);  }