當前位置: 首頁>>代碼示例>>Java>>正文


Java TestSubscriber.assertNoErrors方法代碼示例

本文整理匯總了Java中rx.observers.TestSubscriber.assertNoErrors方法的典型用法代碼示例。如果您正苦於以下問題:Java TestSubscriber.assertNoErrors方法的具體用法?Java TestSubscriber.assertNoErrors怎麽用?Java TestSubscriber.assertNoErrors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rx.observers.TestSubscriber的用法示例。


在下文中一共展示了TestSubscriber.assertNoErrors方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fetchSuggestionsTransformerTest

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void fetchSuggestionsTransformerTest() throws Exception {
    final Observable<List<String>> listObservable = Observable
            .just("1", "2", "3")
            .concatMap(each -> Observable.just(each).delay(5, TimeUnit.SECONDS))
            .compose(RxSuggestions.suggestionsTransformer());

    final TestSubscriber<List<String>> testSubscriber = TestSubscriber.create();
    listObservable.subscribe(testSubscriber);

    testSubscriber.awaitTerminalEvent();

    if (Util.isOnline()) {
        testSubscriber.assertNoErrors();
        assertTrue(testSubscriber.getOnNextEvents().size() == 3);
        assertAllListContentsNotEmpty(testSubscriber);
    } else {
        testSubscriber.assertValueCount(3);
        assertTrue(testSubscriber.getOnNextEvents().size() == 3);
        testSubscriber.assertNoErrors();
        // Transformer swallows error to continue stream.
        for (List<String> suggestions : testSubscriber.getOnNextEvents()) {
            assertTrue(suggestions.isEmpty());
        }
    }
}
 
開發者ID:arunkumar9t2,項目名稱:rxSuggestions,代碼行數:27,代碼來源:RxSuggestionsTransformerTest.java

示例2: searchUsers_IOExceptionThenSuccess_SearchUsersRetried

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void searchUsers_IOExceptionThenSuccess_SearchUsersRetried() {
    //Given
    when(githubUserRestService.searchGithubUsers(anyString()))
            .thenReturn(getIOExceptionError(), Observable.just(githubUserList()));
    when(githubUserRestService.getUser(anyString()))
            .thenReturn(Observable.just(user1FullDetails()), Observable.just(user2FullDetails()));

    //When
    TestSubscriber<List<User>> subscriber = new TestSubscriber<>();
    userRepository.searchUsers(USER_LOGIN_MOYHEEN).subscribe(subscriber);

    //Then
    subscriber.awaitTerminalEvent();
    subscriber.assertNoErrors();

    verify(githubUserRestService, times(2)).searchGithubUsers(USER_LOGIN_MOYHEEN);
    verify(githubUserRestService).getUser(USER_LOGIN_MOYHEEN);
    verify(githubUserRestService).getUser(USER_LOGIN_2_MOYHEEN);
}
 
開發者ID:moyheen,項目名稱:github-user-search,代碼行數:21,代碼來源:UserRepositoryImplTest.java

示例3: zipTheOutputsOfTwoStreamsAndSubscribeToTheResultingStream

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void zipTheOutputsOfTwoStreamsAndSubscribeToTheResultingStream() {
  String mockItemOne = "mockItemOne";
  String mockItemTwo = "mockItemTwo";

  Observable<String> streamOne = Observable.just(mockItemOne);
  Observable<String> streamTwo = Observable.just(mockItemTwo);

  TestSubscriber<List<String>> testSubscriber = new TestSubscriber<>();

  RxUtils.zipMap(streamOne, streamTwo, (s1, s2) -> Observable.just(Arrays.asList(s1, s2)))
      .toBlocking()
      .subscribe(testSubscriber);

  testSubscriber.assertReceivedOnNext(
      Collections.singletonList(Arrays.asList(mockItemOne, mockItemTwo)));
  testSubscriber.assertNoErrors();
  testSubscriber.assertCompleted();
}
 
開發者ID:philipphager,項目名稱:disclosure-android-app,代碼行數:19,代碼來源:RxUtilsShould.java

示例4: iterateAllFilesInApkDirectory

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void iterateAllFilesInApkDirectory() {
  File locationActivityFolder = getFolder("de/philipphager/disclosure/smali/apkWithSubdirs");
  LibraryParser libraryParser = new LibraryParser(locationActivityFolder);

  TestSubscriber<List<Method>> subscriber = new TestSubscriber<>();

  libraryParser.findMethodInvocations()
      .toBlocking()
      .subscribe(subscriber);

  // The folder apkWithSubdirs contains the LocationActivity two times,
  // but one copy is in a subdirectory. If the subdir was successfully
  // parsed, all methods should be found twice.
  List<Method> expectedMethods = new ArrayList<>(LocationActivity.INVOKED_METHODS);
  expectedMethods.addAll(LocationActivity.INVOKED_METHODS);

  subscriber.assertReceivedOnNext(Collections.singletonList(expectedMethods));
  subscriber.assertNoErrors();
  subscriber.assertCompleted();
}
 
開發者ID:philipphager,項目名稱:disclosure-android-app,代碼行數:22,代碼來源:LibraryParserShould.java

示例5: shouldNotSaveDuplicateLocation

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldNotSaveDuplicateLocation() throws Exception {
    PointOfInterest pointOfInterest = MockModelsUtil.createMockPointOfInterest();
    pointOfInterest.id = POI_DUPLICATE_ID;
    TestSubscriber<PointOfInterest> result = new TestSubscriber<>();
    mDatabaseHelper.saveLocation(pointOfInterest).subscribe(result);
    result.assertNoErrors();
    result.assertValue(pointOfInterest);

    Cursor cursor = mDatabaseHelper.getBriteDb()
            .query("SELECT * FROM " + Db.PointOfInterestTable.TABLE_NAME);
    assertEquals(1, cursor.getCount());
    cursor.moveToNext();
    assertEquals(pointOfInterest, Db.PointOfInterestTable.parseCursor(cursor));

    TestSubscriber<PointOfInterest> secondResult = new TestSubscriber<>();
    mDatabaseHelper.saveLocation(pointOfInterest).subscribe(secondResult);
    result.assertNoErrors();
    result.assertValue(pointOfInterest);

    Cursor duplicateCursor = mDatabaseHelper.getBriteDb()
            .query("SELECT * FROM " + Db.PointOfInterestTable.TABLE_NAME);
    assertEquals(1, duplicateCursor.getCount());
    duplicateCursor.moveToNext();
    assertEquals(pointOfInterest, Db.PointOfInterestTable.parseCursor(duplicateCursor));
}
 
開發者ID:sathishmscict,項目名稱:Pickr,代碼行數:27,代碼來源:DatabaseHelperTest.java

示例6: getAccounts_callsLocalStorageWhenNoCacheInMemory

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void getAccounts_callsLocalStorageWhenNoCacheInMemory() {

    // And memory is empty
    setAccountsNotAvailable(memoryAccountsDataSource);
    // And local has accounts
    setAccountsAvailable(localAccountsDataSource, ACCOUNTS);

    // Ask for accounts list
    TestSubscriber<List<Account>> testSubscriber = new TestSubscriber<>();
    accountsRepository.getAccounts()
            .subscribe(testSubscriber);

    testSubscriber.assertNoErrors();

    // Then the local and memory data source should be called only once
    verify(localAccountsDataSource).getAccounts();
    verify(memoryAccountsDataSource).getAccounts();

    testSubscriber.assertValue(ACCOUNTS);
}
 
開發者ID:przemyslaw-holownia,項目名稱:financial-manager,代碼行數:22,代碼來源:AccountsRepositoryTest.java

示例7: rxCompletableEmptyBody

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void rxCompletableEmptyBody() {
  server.enqueue(new MockResponse());

  TestInterface api = target();

  Completable completable = api.completable();

  assertThat(completable).isNotNull();
  assertThat(server.getRequestCount()).isEqualTo(0);

  TestSubscriber<String> testSubscriber = new TestSubscriber<String>();
  completable.subscribe(testSubscriber);
  testSubscriber.awaitTerminalEvent();

  testSubscriber.assertCompleted();
  testSubscriber.assertNoErrors();
}
 
開發者ID:wenwu315,項目名稱:XXXX,代碼行數:19,代碼來源:HystrixBuilderTest.java

示例8: update

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void update() throws Exception {
    final Job test = createTestJob();
    final String json = gson.toJson(test);
    final String key = SimpleUploadDataStore.jobIdKey(test.id());
    final Set<String> keys = new HashSet<>();
    keys.add(key);

    final SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putStringSet(SimpleUploadDataStore.KEY_JOB_IDS, keys);
    editor.putString(key, json);
    editor.apply();

    final TestSubscriber<Job> ts = TestSubscriber.create();
    dataStore.update(Status.createCompleted(test.id(), null)).subscribe(ts);

    ts.awaitTerminalEvent(1, TimeUnit.SECONDS);
    ts.assertNoErrors();
    ts.assertValueCount(1);
    ts.assertValue(test.withStatus(Status.createCompleted(test.id(), null)));
}
 
開發者ID:jsaund,項目名稱:RxUploader,代碼行數:22,代碼來源:SimpleUploadDataStoreTest.java

示例9: shouldGetTopStories

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldGetTopStories() throws Exception {
    User mockUser = MockModelsUtil.createMockUser();
    Post mockStoryOne = MockModelsUtil.createMockStoryWithId(mockUser.submitted.get(0));
    Post mockStoryTwo = MockModelsUtil.createMockStoryWithId(mockUser.submitted.get(1));
    Post mockStoryThree = MockModelsUtil.createMockStoryWithId(mockUser.submitted.get(2));
    Post mockStoryFour = MockModelsUtil.createMockStoryWithId(mockUser.submitted.get(3));

    when(mMockHackerNewsService.getStoryItem(String.valueOf(mockUser.submitted.get(0))))
            .thenReturn(Observable.just(mockStoryOne));
    when(mMockHackerNewsService.getStoryItem(String.valueOf(mockUser.submitted.get(1))))
            .thenReturn(Observable.just(mockStoryTwo));
    when(mMockHackerNewsService.getStoryItem(String.valueOf(mockUser.submitted.get(2))))
            .thenReturn(Observable.just(mockStoryThree));
    when(mMockHackerNewsService.getStoryItem(String.valueOf(mockUser.submitted.get(3))))
            .thenReturn(Observable.just(mockStoryFour));

    final List<Long> storyIds = new ArrayList<>();
    storyIds.add(mockUser.submitted.get(0));
    storyIds.add(mockUser.submitted.get(1));
    storyIds.add(mockUser.submitted.get(2));
    storyIds.add(mockUser.submitted.get(3));

    List<Post> topStories = new ArrayList<>();
    topStories.add(mockStoryOne);
    topStories.add(mockStoryTwo);
    topStories.add(mockStoryThree);
    topStories.add(mockStoryFour);

    TestSubscriber<Post> result = new TestSubscriber<>();
    mDataManager.getPostsFromIds(storyIds).subscribe(result);
    result.assertNoErrors();
    result.assertReceivedOnNext(topStories);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:35,代碼來源:DataManagerTest.java

示例10: shouldGetUserStories

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void shouldGetUserStories() throws Exception {
    User mockUser = MockModelsUtil.createMockUser();
    when(mMockHackerNewsService.getUser(any(String.class)))
            .thenReturn(Observable.just(mockUser));
    Post mockStoryOne = MockModelsUtil.createMockStoryWithId(mockUser.submitted.get(0));
    Post mockStoryTwo = MockModelsUtil.createMockStoryWithId(mockUser.submitted.get(1));
    Post mockStoryThree = MockModelsUtil.createMockStoryWithId(mockUser.submitted.get(2));
    Post mockStoryFour = MockModelsUtil.createMockStoryWithId(mockUser.submitted.get(3));

    when(mMockHackerNewsService.getStoryItem(String.valueOf(mockUser.submitted.get(0))))
            .thenReturn(Observable.just(mockStoryOne));
    when(mMockHackerNewsService.getStoryItem(String.valueOf(mockUser.submitted.get(1))))
            .thenReturn(Observable.just(mockStoryTwo));
    when(mMockHackerNewsService.getStoryItem(String.valueOf(mockUser.submitted.get(2))))
            .thenReturn(Observable.just(mockStoryThree));
    when(mMockHackerNewsService.getStoryItem(String.valueOf(mockUser.submitted.get(3))))
            .thenReturn(Observable.just(mockStoryFour));

    List<Post> userStories = new ArrayList<>();
    userStories.add(mockStoryOne);
    userStories.add(mockStoryTwo);
    userStories.add(mockStoryThree);
    userStories.add(mockStoryFour);

    TestSubscriber<Post> result = new TestSubscriber<>();
    mDataManager.getUserPosts(mockUser.id).subscribe(result);
    result.assertNoErrors();
    result.assertReceivedOnNext(userStories);

}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:32,代碼來源:DataManagerTest.java

示例11: testListenWithAdvance

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void testListenWithAdvance() {
  TestSubscriber<CSValue> listenSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> writeSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> deleteSubscriber = new TestSubscriber<>();

  CSKey key = CSKey.fromString("tests.android").uuidChild();

  String data = "testing1234";
  app.write(key, data, ACL).subscribe(writeSubscriber);

  writeSubscriber.awaitTerminalEvent();

  app.listen(key).first().subscribe(listenSubscriber);
  listenSubscriber.awaitTerminalEvent();
  listenSubscriber.assertNoErrors();

  List<CSValue> receivedValues = listenSubscriber.getOnNextEvents();
  assertEquals(1, receivedValues.size());

  CSValue receivedValue = receivedValues.get(0);
  assertTrue(receivedValue.key().matches(key));
  assertTrue(receivedValue.acl().rawAcl().equals(ACL.rawAcl()));
  assertTrue(receivedValue.data().equals(data));

  app.delete(key).subscribe(deleteSubscriber);
  deleteSubscriber.awaitTerminalEvent();
}
 
開發者ID:csync,項目名稱:csync-android,代碼行數:28,代碼來源:CSAppTest.java

示例12: testDeliverLatestToViewViewNotReady

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testDeliverLatestToViewViewNotReady() throws Exception {
    mPresenter.create();

    TestSubscriber<Integer> testSubscriber = new TestSubscriber<>();
    Observable.just(1, 2, 3)
            .compose(RxTiPresenterUtils.<Integer>deliverLatestToView(mPresenter))
            .subscribe(testSubscriber);

    mPresenter.attachView(mView);

    testSubscriber.assertCompleted();
    testSubscriber.assertNoErrors();
    testSubscriber.assertReceivedOnNext(Collections.singletonList(3));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:RxTiPresenterUtilsTest.java

示例13: testDeleteWildcard

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void testDeleteWildcard() {
  TestSubscriber<CSValue> listenSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> writeSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> deleteSubscriber = new TestSubscriber<>();
  String uuid = UUID.randomUUID().toString();
  CSKey key = CSKey.fromString("tests.android." + uuid + ".*");
  app.listen(key).take(2).subscribe(listenSubscriber);
  CSKey writeKey = CSKey.fromString("tests.android." + uuid + ".a");
  String data = "helllo";
  app.write(writeKey, data, ACL).subscribe(writeSubscriber);
  writeSubscriber.awaitTerminalEvent();

  app.delete(key).subscribe(deleteSubscriber);
  deleteSubscriber.awaitTerminalEvent();
  listenSubscriber.awaitTerminalEvent();
  listenSubscriber.assertNoErrors();

  assertEquals(true, deleteSubscriber.getOnNextEvents().get(0).booleanValue());

  List<CSValue> receivedValues = listenSubscriber.getOnNextEvents();
  assertEquals(2, receivedValues.size());

  CSValue created = receivedValues.get(0);
  CSValue deleted = receivedValues.get(1);

  //Checked
  assertTrue(created.key().matches(key));
  assertTrue(!created.isKeyDeleted());

  //Check deleted key
  assertTrue(deleted.key().matches(key));
  assertTrue(deleted.isKeyDeleted());
}
 
開發者ID:csync,項目名稱:csync-android,代碼行數:34,代碼來源:CSAppTest.java

示例14: testDelete

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test public void testDelete() {
  TestSubscriber<CSValue> listenSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> writeSubscriber = new TestSubscriber<>();
  TestSubscriber<Boolean> deleteSubscriber = new TestSubscriber<>();

  CSKey key = CSKey.fromString("tests.android").uuidChild();
  app.listen(key).take(2).subscribe(listenSubscriber);

  String apostrophe = "\'";
  app.write(key, apostrophe, ACL).subscribe(writeSubscriber);
  writeSubscriber.awaitTerminalEvent();

  app.delete(key).subscribe(deleteSubscriber);

  deleteSubscriber.awaitTerminalEvent();

  listenSubscriber.awaitTerminalEvent();
  listenSubscriber.assertNoErrors();

  assertEquals(true, deleteSubscriber.getOnNextEvents().get(0).booleanValue());

  List<CSValue> receivedValues = listenSubscriber.getOnNextEvents();
  assertEquals(2, receivedValues.size());

  CSValue deleted = receivedValues.get(1);

  assertTrue(deleted.key().matches(key));
  assertEquals(true, receivedValues.get(1).isKeyDeleted());
}
 
開發者ID:csync,項目名稱:csync-android,代碼行數:30,代碼來源:CSAppTest.java

示例15: testDelete

import rx.observers.TestSubscriber; //導入方法依賴的package包/類
@Test
public void testDelete() throws Exception {
  TestSubscriber<Happy> writeSubscriber = new TestSubscriber<>();
  TestSubscriber<Happy> deleteSubscriber = new TestSubscriber<>();

  CSKey testKey = androidTestKey.uuidChild();

  transport
      .write(testKey, "dataToDelete", CSAcl.PUBLIC_READ_WRITE_CREATE)
      .subscribe(writeSubscriber);

  transport
      .delete(testKey)
      .subscribe(deleteSubscriber);

  writeSubscriber.awaitTerminalEvent(3000, TimeUnit.MILLISECONDS);
  writeSubscriber.assertNoErrors();
  writeSubscriber.assertCompleted();

  deleteSubscriber.awaitTerminalEvent(3000, TimeUnit.MILLISECONDS);
  deleteSubscriber.assertNoErrors();
  deleteSubscriber.assertCompleted();

  assertEquals(1, deleteSubscriber.getOnNextEvents().size());
  Happy happyResponse = deleteSubscriber.getOnNextEvents().get(0);

  assertEquals("OK", happyResponse.msg);
  assertEquals(0, happyResponse.code);
}
 
開發者ID:csync,項目名稱:csync-android,代碼行數:30,代碼來源:CSTransportTest.java


注:本文中的rx.observers.TestSubscriber.assertNoErrors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。