Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Parse/src/main/java/com/parse/EventuallyPin.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public static Task<List<EventuallyPin>> findAllPinned(Collection<String> exclude

// We need pass in a null user because we don't want the query to fetch the current user
// from LDS.
return query.findInBackground().continueWithTask(new Continuation<List<EventuallyPin>, Task<List<EventuallyPin>>>() {
return query.findInBackground().onSuccessTask(new Continuation<List<EventuallyPin>, Task<List<EventuallyPin>>>() {
@Override
public Task<List<EventuallyPin>> then(Task<List<EventuallyPin>> task) throws Exception {
final List<EventuallyPin> pins = task.getResult();
Expand Down
59 changes: 59 additions & 0 deletions Parse/src/test/java/com/parse/EventuallyPinTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.parse;

import android.database.sqlite.SQLiteException;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import bolts.Task;

import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = TestHelper.ROBOLECTRIC_SDK_VERSION)
public class EventuallyPinTest {

@Rule
public ExpectedException thrown = ExpectedException.none();

@Before
public void setUp() throws Exception {
ParseObject.registerSubclass(EventuallyPin.class);
ParseObject.registerSubclass(ParsePin.class);
}

@After
public void tearDown() throws Exception {
ParseObject.unregisterSubclass(EventuallyPin.class);
ParseObject.unregisterSubclass(ParsePin.class);
Parse.setLocalDatastore(null);
ParsePlugins.reset();
}

@Test
public void testFailingFindAllPinned() throws Exception {
OfflineStore offlineStore = mock(OfflineStore.class);
Parse.setLocalDatastore(offlineStore);
when(offlineStore.findFromPinAsync(eq(EventuallyPin.PIN_NAME),
any(ParseQuery.State.class),
any(ParseUser.class)))
.thenReturn(Task.forError(new SQLiteException()));

ParsePlugins plugins = mock(ParsePlugins.class);
ParsePlugins.set(plugins);
when(plugins.restClient()).thenReturn(ParseHttpClient.createClient(null));

thrown.expect(SQLiteException.class);

ParseTaskUtils.wait(EventuallyPin.findAllPinned());
}
}