Skip to content

Commit 70516c3

Browse files
authored
Merge branch 'master' into save-eventually-issue
2 parents 0f5e5af + 2817393 commit 70516c3

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

Parse/src/main/java/com/parse/EventuallyPin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static Task<List<EventuallyPin>> findAllPinned(Collection<String> exclude
166166

167167
// We need pass in a null user because we don't want the query to fetch the current user
168168
// from LDS.
169-
return query.findInBackground().continueWithTask(new Continuation<List<EventuallyPin>, Task<List<EventuallyPin>>>() {
169+
return query.findInBackground().onSuccessTask(new Continuation<List<EventuallyPin>, Task<List<EventuallyPin>>>() {
170170
@Override
171171
public Task<List<EventuallyPin>> then(Task<List<EventuallyPin>> task) throws Exception {
172172
final List<EventuallyPin> pins = task.getResult();
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.parse;
2+
3+
import android.database.sqlite.SQLiteException;
4+
5+
import org.junit.After;
6+
import org.junit.Before;
7+
import org.junit.Rule;
8+
import org.junit.Test;
9+
import org.junit.rules.ExpectedException;
10+
import org.junit.runner.RunWith;
11+
import org.robolectric.RobolectricTestRunner;
12+
import org.robolectric.annotation.Config;
13+
14+
import bolts.Task;
15+
16+
import static org.mockito.Matchers.any;
17+
import static org.mockito.Matchers.eq;
18+
import static org.mockito.Mockito.mock;
19+
import static org.mockito.Mockito.when;
20+
21+
@RunWith(RobolectricTestRunner.class)
22+
@Config(constants = BuildConfig.class, sdk = TestHelper.ROBOLECTRIC_SDK_VERSION)
23+
public class EventuallyPinTest {
24+
25+
@Rule
26+
public ExpectedException thrown = ExpectedException.none();
27+
28+
@Before
29+
public void setUp() throws Exception {
30+
ParseObject.registerSubclass(EventuallyPin.class);
31+
ParseObject.registerSubclass(ParsePin.class);
32+
}
33+
34+
@After
35+
public void tearDown() throws Exception {
36+
ParseObject.unregisterSubclass(EventuallyPin.class);
37+
ParseObject.unregisterSubclass(ParsePin.class);
38+
Parse.setLocalDatastore(null);
39+
ParsePlugins.reset();
40+
}
41+
42+
@Test
43+
public void testFailingFindAllPinned() throws Exception {
44+
OfflineStore offlineStore = mock(OfflineStore.class);
45+
Parse.setLocalDatastore(offlineStore);
46+
when(offlineStore.findFromPinAsync(eq(EventuallyPin.PIN_NAME),
47+
any(ParseQuery.State.class),
48+
any(ParseUser.class)))
49+
.thenReturn(Task.forError(new SQLiteException()));
50+
51+
ParsePlugins plugins = mock(ParsePlugins.class);
52+
ParsePlugins.set(plugins);
53+
when(plugins.restClient()).thenReturn(ParseHttpClient.createClient(null));
54+
55+
thrown.expect(SQLiteException.class);
56+
57+
ParseTaskUtils.wait(EventuallyPin.findAllPinned());
58+
}
59+
}

0 commit comments

Comments
 (0)