Skip to content

Commit

Permalink
Merge branch 'master' into save-eventually-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Jawnnypoo authored Jul 18, 2018
2 parents 0f5e5af + 2817393 commit 70516c3
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
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());
}
}

0 comments on commit 70516c3

Please sign in to comment.