-
-
Notifications
You must be signed in to change notification settings - Fork 735
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into save-eventually-issue
- Loading branch information
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |