Java 类org.robolectric.shadows.ShadowContentResolver 实例源码

项目:JobSchedulerCompat    文件:AlarmContentObserverServiceTest.java   
@Test
public void testObserversRegistered() {
    Uri uri = Uri.parse("doist.com");

    ShadowContentResolver contentResolver = shadowOf(context.getContentResolver());
    assertEquals(0, contentResolver.getContentObservers(uri).size());

    jobStore.add(JobStatus.createFromJobInfo(
            JobCreator.create(context, 0)
                      .addTriggerContentUri(new JobInfo.TriggerContentUri(uri, 0))
                      .build(),
            AlarmScheduler.TAG));
    service.startCommand(0, 0);

    assertEquals(1, contentResolver.getContentObservers(uri).size());
    assertThat(contentResolver.getContentObservers(uri), hasItem(isA(ContentObserverService.Observer.class)));
}
项目:JobSchedulerCompat    文件:AlarmContentObserverServiceTest.java   
@Test
public void testObserversFire() {
    Uri[] uris = new Uri[]{Uri.parse("doist.com"), Uri.parse("todoist.com"), Uri.parse("twistapp.com")};

    for (int i = 0; i < uris.length; i++) {
        jobStore.add(JobStatus.createFromJobInfo(
                JobCreator.create(context, i, 5000)
                          .addTriggerContentUri(new JobInfo.TriggerContentUri(uris[i], 0))
                          .build(),
                AlarmScheduler.TAG));
    }
    service.startCommand(0, 0);

    ShadowApplication application = ShadowApplication.getInstance();
    ShadowContentResolver contentResolver = shadowOf(context.getContentResolver());
    for (Uri uri : uris) {
        assertEquals(0, application.getBoundServiceConnections().size());
        assertEquals(1, contentResolver.getContentObservers(uri).size());
        contentResolver.notifyChange(uri, null);
        DeviceTestUtils.advanceTime(JobStatus.DEFAULT_TRIGGER_MAX_DELAY);
        assertEquals(1, contentResolver.getContentObservers(uri).size());
        assertEquals(AlarmJobService.class.getCanonicalName(),
                     application.getNextStartedService().getComponent().getClassName());
    }
}
项目:mobile-store    文件:Assert.java   
public static void assertIsInstalledVersionInDb(ShadowContentResolver resolver,
                                                String appId, int versionCode, String versionName) {
    Uri uri = InstalledAppProvider.getAppUri(appId);

    String[] projection = {
            InstalledAppTable.Cols.Package.NAME,
            InstalledAppTable.Cols.VERSION_CODE,
            InstalledAppTable.Cols.VERSION_NAME,
            InstalledAppTable.Cols.APPLICATION_LABEL,
    };

    Cursor cursor = resolver.query(uri, projection, null, null, null);

    assertNotNull(cursor);
    assertEquals("App \"" + appId + "\" not installed", 1, cursor.getCount());

    cursor.moveToFirst();

    assertEquals(appId, cursor.getString(cursor.getColumnIndex(InstalledAppTable.Cols.Package.NAME)));
    assertEquals(versionCode, cursor.getInt(cursor.getColumnIndex(InstalledAppTable.Cols.VERSION_CODE)));
    assertEquals(versionName, cursor.getString(cursor.getColumnIndex(InstalledAppTable.Cols.VERSION_NAME)));
    cursor.close();
}
项目:materialistic    文件:ItemSyncAdapterTest.java   
@Test
public void testWifiChange() {
    setNetworkType(ConnectivityManager.TYPE_MOBILE);
    new ItemSyncWifiReceiver()
            .onReceive(service, new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
    assertFalse(ShadowContentResolver.isSyncActive(createSyncAccount(),
            MaterialisticProvider.PROVIDER_AUTHORITY));

    setNetworkType(ConnectivityManager.TYPE_WIFI);
    new ItemSyncWifiReceiver().onReceive(service, new Intent());
    assertFalse(ShadowContentResolver.isSyncActive(createSyncAccount(),
            MaterialisticProvider.PROVIDER_AUTHORITY));

    setNetworkType(ConnectivityManager.TYPE_WIFI);
    new ItemSyncWifiReceiver()
            .onReceive(service, new Intent(ConnectivityManager.CONNECTIVITY_ACTION));
    assertTrue(ShadowContentResolver.isSyncActive(createSyncAccount(),
            MaterialisticProvider.PROVIDER_AUTHORITY));
}
项目:grocery-reminder    文件:ReminderContentProviderTest.java   
@Test
public void whenNoRemindersAreDeletedThenNoObserversAreNotified() {
    String testDescription = "test";
    ContentValues values = new ReminderValuesBuilder().createDefaultReminderValues().withDescription(testDescription).build();

    ShadowContentResolver contentResolver = Shadows.shadowOf(provider.getContext().getContentResolver());
    provider.insert(ReminderContract.Reminders.CONTENT_URI, values);
    List<ShadowContentResolver.NotifiedUri> notifiedUriList = contentResolver.getNotifiedUris();
    assertEquals(1, notifiedUriList.size());

    String selection = ReminderContract.Reminders.DESCRIPTION + " = ? ";
    String[] selectionArgs = new String[] {"wrong name"};
    provider.delete(ReminderContract.Reminders.CONTENT_URI, selection, selectionArgs);

    notifiedUriList = contentResolver.getNotifiedUris();
    assertEquals(1, notifiedUriList.size());
}
项目:grocery-reminder    文件:GroceryStoreLocationContentProviderTest.java   
@Test
public void whenNoLocationsAreDeletedThenNoObserversAreNotified() {
    String testName = "test";
    ContentValues values = locationValuesBuilder.createDefaultLocationValues().withName(testName).build();

    ShadowContentResolver contentResolver = Shadows.shadowOf(provider.getContext().getContentResolver());
    provider.insert(ReminderContract.Locations.CONTENT_URI, values);
    List<ShadowContentResolver.NotifiedUri> notifiedUriList = contentResolver.getNotifiedUris();
    assertEquals(1, notifiedUriList.size());

    String selection = ReminderContract.Locations.NAME + " = ? ";
    String[] selectionArgs = new String[] {"wrong name"};
    provider.delete(ReminderContract.Locations.CONTENT_URI, selection, selectionArgs);

    notifiedUriList = contentResolver.getNotifiedUris();
    assertEquals(1, notifiedUriList.size());
}
项目:fdroidclient    文件:Assert.java   
public static void assertIsInstalledVersionInDb(ShadowContentResolver resolver,
                                                String appId, int versionCode, String versionName) {
    Uri uri = InstalledAppProvider.getAppUri(appId);

    String[] projection = {
            InstalledAppTable.Cols.Package.NAME,
            InstalledAppTable.Cols.VERSION_CODE,
            InstalledAppTable.Cols.VERSION_NAME,
            InstalledAppTable.Cols.APPLICATION_LABEL,
    };

    Cursor cursor = resolver.query(uri, projection, null, null, null);

    assertNotNull(cursor);
    assertEquals("App \"" + appId + "\" not installed", 1, cursor.getCount());

    cursor.moveToFirst();

    assertEquals(appId, cursor.getString(cursor.getColumnIndex(InstalledAppTable.Cols.Package.NAME)));
    assertEquals(versionCode, cursor.getInt(cursor.getColumnIndex(InstalledAppTable.Cols.VERSION_CODE)));
    assertEquals(versionName, cursor.getString(cursor.getColumnIndex(InstalledAppTable.Cols.VERSION_NAME)));
    cursor.close();
}
项目:TruckMuncher-Android    文件:MenuItemDiffServiceTest.java   
@Test
public void onHandleIntentPerformsBulkInsertWithSyncToNetworkDirective() {
    VerifiableContentProvider provider = new VerifiableContentProvider();
    ShadowContentResolver.registerProvider(PublicContract.CONTENT_AUTHORITY, provider);
    provider.enqueue(new VerifiableContentProvider.ApplyBatchEvent() {
        @NonNull
        @Override
        public ContentProviderResult[] onApplyBatch(@NonNull ArrayList<ContentProviderOperation> operations) throws OperationApplicationException {
            assertThat(operations).hasSize(1);
            assertThat(Contract.isSyncToNetwork(operations.get(0).getUri())).isTrue();
            return new ContentProviderResult[0];
        }
    });

    Intent intent = MenuItemDiffService.newIntent(Robolectric.application, new ContentValues[]{new ContentValues()});
    MenuItemDiffService service = new MenuItemDiffService();
    service.onHandleIntent(intent);

    provider.assertThatCursorsAreClosed();
    provider.assertThatQueuesAreEmpty();
}
项目:spicio    文件:DatabaseProviderTest.java   
@Before
public void setUp() throws Exception {
    mProvider = new DatabaseProvider();
    mContentResolver = RuntimeEnvironment.application.getContentResolver();
    ShadowContentResolver.registerProvider(DatabaseContract.CONTENT_AUTHORITY, mProvider);
    mProvider.onCreate();
    mShadowContentResolver = Shadows.shadowOf(mContentResolver);

    deleteAllRecords(SeriesEntry.CONTENT_URI);
    deleteAllRecords(EpisodesEntry.CONTENT_URI);
    deleteAllRecords(FeedEntry.CONTENT_URI);
    deleteAllRecords(FriendsEntry.CONTENT_URI);
}
项目:loadie    文件:CursorLoaderTest.java   
@Before
public void setup() {
    background = ShadowApplication.getInstance().getBackgroundThreadScheduler();
    resolver = RuntimeEnvironment.application.getContentResolver();
    ShadowContentResolver shadowResolver = shadowOf(resolver);
    MyRoboCursor cursor = new MyRoboCursor();
    cursor.setNotificationUri(resolver, CONTENT_URI);
    shadowResolver.setCursor(CONTENT_URI, cursor);
    this.cursor = cursor;
}
项目:Capstone-Project    文件:BacklogProviderTest.java   
@Before
public void setUp() {
    final BacklogProvider backlogProvider = new BacklogProvider();
    final ContentResolver contentResolver = RuntimeEnvironment.application.getContentResolver();
    this.shadowContentResolver = Shadows.shadowOf(contentResolver);
    backlogProvider.onCreate();
    ShadowContentResolver.registerProvider(CONTENT_AUTHORITY, backlogProvider);
}
项目:materialistic    文件:ItemSyncAdapterTest.java   
@Test
public void testSyncDisabled() {
    PreferenceManager.getDefaultSharedPreferences(service)
            .edit().clear().apply();
    syncScheduler.scheduleSync(service, "1");
    assertNull(ShadowContentResolver.getStatus(createSyncAccount(),
            MaterialisticProvider.PROVIDER_AUTHORITY));
}
项目:materialistic    文件:ItemSyncAdapterTest.java   
@Test
public void testSyncDeferred() throws IOException {
    Call<HackerNewsItem> call = mock(Call.class);
    when(call.execute()).thenThrow(IOException.class);
    when(TestRestServiceFactory.hnRestService.cachedItem(any())).thenReturn(call);
    when(TestRestServiceFactory.hnRestService.networkItem(any())).thenReturn(call);

    syncPreferences.edit().putBoolean("1", true).putBoolean("2", true).apply();
    syncScheduler.scheduleSync(service, null);
    adapter.onPerformSync(mock(Account.class), getLastSyncExtras(), null, null, null);
    ShadowContentResolver.Status syncStatus = ShadowContentResolver.getStatus(
            new Account("Materialistic", BuildConfig.APPLICATION_ID),
            MaterialisticProvider.PROVIDER_AUTHORITY);
    assertThat(syncStatus.syncRequests).isEqualTo(3); // original + 2 deferred
}
项目:materialistic    文件:FavoriteManagerTest.java   
@Config(sdk = 18)
@Test
public void testAdd() {
    PreferenceManager.getDefaultSharedPreferences(RuntimeEnvironment.application)
            .edit()
            .putBoolean(RuntimeEnvironment.application
                    .getString(R.string.pref_saved_item_sync), true)
            .putBoolean(RuntimeEnvironment.application
                    .getString(R.string.pref_offline_article), true)
            .apply();
    shadowOf((ConnectivityManager) RuntimeEnvironment.application
            .getSystemService(Context.CONNECTIVITY_SERVICE))
            .setActiveNetworkInfo(ShadowNetworkInfo.newInstance(null,
                    ConnectivityManager.TYPE_WIFI, 0, true, true));
    manager.add(RuntimeEnvironment.application, new TestWebItem() {
        @Override
        public String getId() {
            return "3";
        }

        @Override
        public String getUrl() {
            return "http://newitem.com";
        }

        @Override
        public String getDisplayedTitle() {
            return "new title";
        }
    });
    assertThat(resolver.getNotifiedUris()).isNotEmpty();
    assertTrue(ShadowContentResolver.isSyncActive(new Account("Materialistic", BuildConfig.APPLICATION_ID),
            MaterialisticProvider.PROVIDER_AUTHORITY));
}
项目:grocery-reminder    文件:ReminderContentProviderTest.java   
@Test
public void givenAReminderContentTypeAndContentValuesWhenARecordIsInsertedThenObserversAreNotified()
{
    ContentValues values = createDefaultReminderValues();
    ShadowContentResolver contentResolver = Shadows.shadowOf(provider.getContext().getContentResolver());
    Uri expectedUri = provider.insert(ReminderContract.Reminders.CONTENT_URI, values);

    List<ShadowContentResolver.NotifiedUri> notifiedUriList = contentResolver.getNotifiedUris();
    assertThat(notifiedUriList.get(0).uri, is(expectedUri));
}
项目:grocery-reminder    文件:ReminderContentProviderTest.java   
@Test
public void whenAReminderIsDeletedThenObserversAreNotified() {
    ContentValues values = createDefaultReminderValues();
    Uri expectedUri = provider.insert(ReminderContract.Reminders.CONTENT_URI, values);

    ShadowContentResolver contentResolver = Shadows.shadowOf(provider.getContext().getContentResolver());
    provider.delete(expectedUri, "", null);

    List<ShadowContentResolver.NotifiedUri> notifiedUriList = contentResolver.getNotifiedUris();
    assertThat(notifiedUriList.get(1).uri, is(expectedUri));
}
项目:grocery-reminder    文件:GroceryStoreLocationContentProviderTest.java   
@Test
public void givenALocationContentTypeAndContentValuesWhenARecordIsInsertedThenObserversAreNotified()
{
    ContentValues values = createDefaultLocationValues();
    ShadowContentResolver contentResolver = Shadows.shadowOf(provider.getContext().getContentResolver());
    Uri expectedUri = provider.insert(ReminderContract.Locations.CONTENT_URI, values);

    List<ShadowContentResolver.NotifiedUri> notifiedUriList = contentResolver.getNotifiedUris();
    assertThat(notifiedUriList.get(0).uri, is(expectedUri));
}
项目:grocery-reminder    文件:GroceryStoreLocationContentProviderTest.java   
@Test
public void whenALocationIsDeletedThenObserversAreNotified() {
    ContentValues values = createDefaultLocationValues();
    Uri expectedUri = provider.insert(ReminderContract.Locations.CONTENT_URI, values);

    ShadowContentResolver contentResolver = Shadows.shadowOf(provider.getContext().getContentResolver());
    provider.delete(expectedUri, "", null);

    List<ShadowContentResolver.NotifiedUri> notifiedUriList = contentResolver.getNotifiedUris();
    assertThat(notifiedUriList.get(1).uri, is(expectedUri));
}
项目:retain-state    文件:CursorLoaderTest.java   
@Before
public void setup() {
    background = ShadowApplication.getInstance().getBackgroundThreadScheduler();
    resolver = RuntimeEnvironment.application.getContentResolver();
    ShadowContentResolver shadowResolver = shadowOf(resolver);
    MyRoboCursor cursor = new MyRoboCursor();
    cursor.setNotificationUri(resolver, CONTENT_URI);
    shadowResolver.setCursor(CONTENT_URI, cursor);
    this.cursor = cursor;
}
项目:FullRobolectricTestSample    文件:SimpleTestCursorTest.java   
@Before
public void setup() throws Exception {
  contentResolver = Robolectric.application.getContentResolver();
  ShadowContentResolver shadowContentResolver = shadowOf(contentResolver);
  uri = Uri.parse("http://foo");
  cursor = new SimpleTestCursor();
  shadowContentResolver.setCursor(uri, cursor);
  ArrayList<String> columnNames = new ArrayList<String>();
  columnNames.add("stringColumn");
  columnNames.add("longColumn");
  cursor.setColumnNames(columnNames);
}
项目:Ollie    文件:OllieTest.java   
@Before
public void initialize() {
    ContentProvider contentProvider = new OllieSampleProvider();
    contentProvider.onCreate();

    ShadowLog.stream = System.out;
    ShadowContentResolver.registerProvider("com.example.ollie", contentProvider);

    Ollie.with(Robolectric.application)
            .setName("OllieSample.db")
            .setLogLevel(LogLevel.FULL)
            .init();
}
项目:UnofficialHendrixApp    文件:StaffProviderTest.java   
@Before
public void setup() {
    ShadowApplication app = Shadows.shadowOf(RuntimeEnvironment.application);
    mContentResolver = Shadows.shadowOf(app.getContentResolver());
    mProvider = new HendrixProvider();
    mProvider.onCreate();
    ShadowContentResolver.registerProvider(HendrixContract.CONTENT_AUTHORITY, mProvider);
}
项目:droitatedDB    文件:ContentProviderTest.java   
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    CommentContentProvider provider = new CommentContentProvider();
    provider.onCreate();
    ShadowContentResolver.registerProvider("org.droitateddb.test.data.generated.provider.comment", provider);
    SingleContentProvider p = new SingleContentProvider();
    p.onCreate();
    ShadowContentResolver.registerProvider("org.droitateddb.test.data.generated.provider.single", p);

}
项目:TruckMuncher-Android    文件:TruckMuncherContentProviderTest.java   
@Before
public void setUp() {
    ContentProvider provider = new TruckMuncherContentProvider();
    provider.onCreate();
    ShadowContentResolver.registerProvider(PublicContract.CONTENT_AUTHORITY, provider);
    resolver = Robolectric.application.getContentResolver();
}
项目:android-db-commons    文件:ComposedCursorLoaderTest.java   
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  ShadowContentResolver.registerProvider(FAKE_AUTHORITY, providerMock);
  cursor = buildCursor();
  makeProviderReturn(cursor);
  Robolectric.getBackgroundScheduler().pause();
}
项目:simpleprovider    文件:SimpleProviderTest.java   
@Before
public void setUp() {
    // fetch references to all the stuff we need like ContentProvider
    mProvider = new TestProvider();
    mContentResolver = Robolectric.application.getContentResolver();
    mPostsUri = Uri.parse("content://" + TestProvider.AUTHORITY + "/posts");

    // create and register the provider
    mProvider.onCreate();
    ShadowContentResolver.registerProvider(TestProvider.AUTHORITY, mProvider);
}
项目:mobile-store    文件:Assert.java   
public static void assertInvalidUri(ShadowContentResolver resolver, String uri) {
    assertInvalidUri(resolver, Uri.parse(uri));
}
项目:mobile-store    文件:Assert.java   
public static void assertValidUri(ShadowContentResolver resolver, String uri, String[] projection) {
    assertValidUri(resolver, Uri.parse(uri), projection);
}
项目:mobile-store    文件:Assert.java   
public static void assertInvalidUri(ShadowContentResolver resolver, Uri uri) {
    Cursor cursor = resolver.query(uri, new String[]{}, null, null, null);
    assertNull(cursor);
}
项目:mobile-store    文件:Assert.java   
public static void assertValidUri(ShadowContentResolver resolver, Uri uri, String[] projection) {
    Cursor cursor = resolver.query(uri, projection, null, null, null);
    assertNotNull(cursor);
    cursor.close();
}
项目:mobile-store    文件:Assert.java   
public static void assertValidUri(ShadowContentResolver resolver, Uri actualUri, String expectedUri,
                                  String[] projection) {
    assertValidUri(resolver, actualUri, projection);
    assertEquals(expectedUri, actualUri.toString());
}
项目:mobile-store    文件:Assert.java   
public static void assertResultCount(ShadowContentResolver resolver, int expectedCount, Uri uri) {
    assertResultCount(resolver, expectedCount, uri, new String[]{});
}
项目:mobile-store    文件:Assert.java   
public static void assertResultCount(ShadowContentResolver resolver, int expectedCount, Uri uri,
                                     String[] projection) {
    Cursor cursor = resolver.query(uri, projection, null, null, null);
    assertResultCount(expectedCount, cursor);
    cursor.close();
}
项目:mobile-store    文件:AppProviderTest.java   
public static App insertApp(ShadowContentResolver contentResolver, Context context, String id, String name, ContentValues additionalValues) {
    return insertApp(contentResolver, context, id, name, additionalValues, 1);
}
项目:mobile-store    文件:AppProviderTest.java   
public static App insertApp(ShadowContentResolver contentResolver, Context context, String id, String name, ContentValues additionalValues, long repoId) {

        ContentValues values = new ContentValues();
        values.put(Cols.Package.PACKAGE_NAME, id);
        values.put(Cols.REPO_ID, repoId);
        values.put(Cols.NAME, name);

        // Required fields (NOT NULL in the database).
        values.put(Cols.SUMMARY, "test summary");
        values.put(Cols.DESCRIPTION, "test description");
        values.put(Cols.LICENSE, "GPL?");
        values.put(Cols.IS_COMPATIBLE, 1);

        values.put(Cols.PREFERRED_SIGNER, "eaa1d713b9c2a0475234a86d6539f910");

        values.putAll(additionalValues);

        Uri uri = AppProvider.getContentUri();

        contentResolver.insert(uri, values);

        AppProvider.Helper.recalculatePreferredMetadata(context);

        return AppProvider.Helper.findSpecificApp(context.getContentResolver(), id, repoId, Cols.ALL);
    }
项目:spicio    文件:SeriesDaoTest.java   
@Before
public void setUp() throws Exception {
    DatabaseProvider provider = new DatabaseProvider();
    mContentResolver = RuntimeEnvironment.application.getContentResolver();
    ShadowContentResolver.registerProvider(DatabaseContract.CONTENT_AUTHORITY, provider);
    provider.onCreate();
    mShadowContentResolver = Shadows.shadowOf(mContentResolver);

    deleteAllRecords(SeriesEntry.CONTENT_URI);

    Application mockApplication = mock(Application.class);
    when(mockApplication.getContentResolver()).thenReturn(mContentResolver);

    StorageComponent storageComponent = DaggerStorageComponent.builder()
            .spicioAppModule(new FakeAppModule(mockApplication))
            .storageModule(new FakeStorageModule())
            .build();

    ((SpicioApplication) RuntimeEnvironment.application).setStorageComponent(storageComponent);

    mSeriesDao = new SeriesDaoImpl((SpicioApplication) RuntimeEnvironment.application);


    Images images = new Images();
    images.setPoster(new Image());
    images.getPoster().setFull("test_poster_full");
    images.getPoster().setThumb("test_poster_thumb");
    images.setThumb(new Image());
    images.getThumb().setFull("test_thumb_full");

    InputStream is = getClass().getClassLoader().getResourceAsStream("trakt_series_details_mock.json");
    String dummyResponse = TestUtils.convertStreamToString(is);
    Gson gson = new Gson();
    TraktSeries traktSeries = gson.fromJson(dummyResponse, TraktSeries.class);
    mSeries = TraktModelConverter.convertToSeries(traktSeries);
    mSeries.setImages(images);

    Uri uri = mSeriesDao.insertSeries(mSeries);
    assertNotNull(uri);


    is = getClass().getClassLoader().getResourceAsStream("trakt_series_details_mock2.json");
    dummyResponse = TestUtils.convertStreamToString(is);
    traktSeries = gson.fromJson(dummyResponse, TraktSeries.class);
    mAnotherSeries = TraktModelConverter.convertToSeries(traktSeries);
    mAnotherSeries.setImages(images);

    uri = mSeriesDao.insertSeries(mAnotherSeries);
    assertNotNull(uri);
}
项目:spicio    文件:EpisodeDaoTest.java   
@Before
public void setUp() throws Exception {
    DatabaseProvider provider = new DatabaseProvider();
    mContentResolver = RuntimeEnvironment.application.getContentResolver();
    ShadowContentResolver.registerProvider(DatabaseContract.CONTENT_AUTHORITY, provider);
    provider.onCreate();
    mShadowContentResolver = Shadows.shadowOf(mContentResolver);

    deleteAllRecords(EpisodesEntry.CONTENT_URI);

    StorageComponent storageComponent = DaggerStorageComponent.builder()
            .spicioAppModule(new FakeAppModule(RuntimeEnvironment.application))
            .storageModule(new FakeStorageModule())
            .build();

    ((SpicioApplication) RuntimeEnvironment.application).setStorageComponent(storageComponent);

    mEpisodeDao = new EpisodeDaoImpl((SpicioApplication) RuntimeEnvironment.application);

    InputStream is = getClass().getClassLoader().getResourceAsStream("trakt_episode_detail_mock.json");
    String dummyResponse = TestUtils.convertStreamToString(is);
    Gson gson = new Gson();

    TraktEpisode traktEpisode = gson.fromJson(dummyResponse, TraktEpisode.class);
    mEpisode = TraktModelConverter.convertToEpisode(traktEpisode);


    is = getClass().getClassLoader().getResourceAsStream("trakt_episode_detail_mock2.json");
    dummyResponse = TestUtils.convertStreamToString(is);

    traktEpisode = gson.fromJson(dummyResponse, TraktEpisode.class);
    mAnotherEpisode = TraktModelConverter.convertToEpisode(traktEpisode);

    List<Episode> episodes = new LinkedList<>();

    episodes.add(mEpisode);
    episodes.add(mAnotherEpisode);

    int rowsInserted = mEpisodeDao.insertAllEpisodes(episodes);
    assertEquals(2, rowsInserted);

    Season season = new Season();
    season.setSeriesId(mEpisode.getSeriesId());
    season.setNumber(mEpisode.getSeason());

    List<Season> seasons = new LinkedList<>();
    seasons.add(season);

    rowsInserted = mEpisodeDao.insertAllSeasons(seasons);
    assertEquals(1, rowsInserted);
}
项目:materialistic    文件:ItemSyncAdapterTest.java   
private Bundle getLastSyncExtras() {
    return ShadowContentResolver.getStatus(createSyncAccount(),
            MaterialisticProvider.PROVIDER_AUTHORITY).syncExtras;
}
项目:FullRobolectricTestSample    文件:Robolectric.java   
public static ShadowContentResolver shadowOf(ContentResolver instance) {
  return (ShadowContentResolver) shadowOf_(instance);
}
项目:android-autoprovider    文件:ProviderMock.java   
public static TestProvider provide() {
  final TestProvider provider = new TestProvider();
  provider.onCreate();
  ShadowContentResolver.registerProvider(TestModels.AUTHORITY, provider);
  return provider;
}