### Question:
OfflineObjectStore implements ParseObjectStore<T> { @Override public Task<T> getAsync() { ParseQuery<T> query = ParseQuery.<T>getQuery(className) .fromPin(pinName) .ignoreACLs(); return query.findInBackground().onSuccessTask(new Continuation<List<T>, Task<T>>() { @Override public Task<T> then(Task<List<T>> task) throws Exception { List<T> results = task.getResult(); if (results != null) { if (results.size() == 1) { return Task.forResult(results.get(0)); } else { return ParseObject.unpinAllInBackground(pinName).cast(); } } return Task.forResult(null); } }).onSuccessTask(new Continuation<T, Task<T>>() { @Override public Task<T> then(Task<T> task) throws Exception { T ldsObject = task.getResult(); if (ldsObject != null) { return task; } return migrate(legacy, OfflineObjectStore.this).cast(); } }); } OfflineObjectStore(Class<T> clazz, String pinName, ParseObjectStore<T> legacy);  OfflineObjectStore(String className, String pinName, ParseObjectStore<T> legacy); @Override Task<Void> setAsync(final T object); @Override Task<T> getAsync(); @Override Task<Boolean> existsAsync(); @Override Task<Void> deleteAsync();  }### Answer:
@Test public void testGetAsyncFromLDS() throws Exception { Parse.enableLocalDatastore(null); ParseUser user = mock(ParseUser.class); ParseQueryController queryController = mock(ParseQueryController.class); when(queryController.findAsync( any(ParseQuery.State.class), any(ParseUser.class), any(Task.class)) ).thenReturn(Task.forResult(Collections.singletonList(user))); ParseCorePlugins.getInstance().registerQueryController(queryController); OfflineObjectStore<ParseUser> store = new OfflineObjectStore<>(ParseUser.class, PIN_NAME, null); ParseUser userAgain = ParseTaskUtils.wait(store.getAsync()); verify(queryController, times(1)) .findAsync(any(ParseQuery.State.class), any(ParseUser.class), any(Task.class)); assertSame(user, userAgain); }
@Test public void testGetAsyncFromLDSWithTooManyObjects() throws Exception { Parse.enableLocalDatastore(null); ParseQueryController queryController = mock(ParseQueryController.class); when(queryController.findAsync( any(ParseQuery.State.class), any(ParseUser.class), any(Task.class)) ).thenReturn(Task.forResult(Arrays.asList(mock(ParseUser.class), mock(ParseUser.class)))); ParseCorePlugins.getInstance().registerQueryController(queryController); OfflineStore lds = mock(OfflineStore.class); when(lds.unpinAllObjectsAsync(anyString())).thenReturn(Task.<Void>forResult(null)); Parse.setLocalDatastore(lds); @SuppressWarnings("unchecked") ParseObjectStore<ParseUser> legacy = mock(ParseObjectStore.class); when(legacy.getAsync()).thenReturn(Task.<ParseUser>forResult(null)); OfflineObjectStore<ParseUser> store = new OfflineObjectStore<>(ParseUser.class, PIN_NAME, legacy); ParseUser user = ParseTaskUtils.wait(store.getAsync()); verify(queryController, times(1)) .findAsync(any(ParseQuery.State.class), any(ParseUser.class), any(Task.class)); verify(lds, times(1)).unpinAllObjectsAsync(PIN_NAME); assertNull(user); }