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


Java TestObserver.values方法代碼示例

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


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

示例1: testIsPageBookmarked

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void testIsPageBookmarked() {
  when(bookmarksAdapter.getBookmarkId(null, null, 42)).thenReturn(1L);
  when(bookmarksAdapter.getBookmarkId(null, null, 43)).thenReturn(-1L);

  TestObserver<Pair<Integer, Boolean>> testObserver = new TestObserver<>();
  model.getIsBookmarkedObservable(42, 43)
      .subscribe(testObserver);
  testObserver.awaitTerminalEvent();
  testObserver.assertNoErrors();
  testObserver.assertValueCount(2);

  List<Pair<Integer, Boolean>> results = testObserver.values();
  for (int i = 0; i < results.size(); i++) {
    Pair<Integer, Boolean> result = results.get(i);
    assertThat(result.first).isAnyOf(42, 43);
    if (result.first == 42) {
      assertThat(result.second).isTrue();
    } else if (result.first == 43) {
      assertThat(result.second).isFalse();
    }
  }
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:24,代碼來源:BookmarkModelTest.java

示例2: testParseExternalFile

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void testParseExternalFile() throws FileNotFoundException {
  InputStream is = new ByteArrayInputStream(new byte[32]);
  ContentResolver resolver = mock(ContentResolver.class);
  when(resolver.openInputStream(any(Uri.class))).thenReturn(is);
  when(appContext.getContentResolver()).thenReturn(resolver);

  TestObserver<BufferedSource> observer = new TestObserver<>();
  presenter.parseExternalFile(Uri.EMPTY)
      .subscribe(observer);
  observer.awaitTerminalEvent();
  observer.assertValueCount(1);
  observer.assertNoErrors();
  observer.assertComplete();

  List<BufferedSource> events = observer.values();
  assertThat(events).hasSize(1);
  assertThat(events.get(0)).isNotNull();
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:20,代碼來源:QuranImportPresenterTest.java

示例3: onUserQuery_2subsequentQueriesProvided_shouldPost2EventsWithQueryString

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void onUserQuery_2subsequentQueriesProvided_shouldPost2EventsWithQueryString() {
  // given
  TestObserver<UserQueryEvent> userQuery$ = TestObserver.create();
  PublishSubject<String> userQueryIntents = PublishSubject.create();
  given(view.queryInput$()).willReturn(userQueryIntents);
  UserQueryPresenter presenter = new UserQueryPresenter(Sink.of(userQuery$));
  presenter.start(view);

  // when
  userQueryIntents.onNext("foo");
  userQueryIntents.onNext("bar");

  // then
  userQuery$.assertValueCount(2);
  List<UserQueryEvent> events = userQuery$.values();
  assertThat(events)
      .extracting(UserQueryEvent::getQuery)
      .containsExactly("foo", "bar");
}
 
開發者ID:xemantic,項目名稱:github-users,代碼行數:21,代碼來源:UserQueryPresenterTest.java

示例4: testEmployeeDataRx

import io.reactivex.observers.TestObserver; //導入方法依賴的package包/類
@Test
public void testEmployeeDataRx(){
	TestObserver<Employee> testObserver = new TestObserver<>();
	employeeRxJavaServiceImpl.getEmployeesRx().subscribe(testObserver);

	testObserver.assertNoErrors();
	List<Employee> emps = testObserver.values();
	for(Employee emp: emps){
		System.out.println(emp.getFirstName());
	}
}
 
開發者ID:PacktPublishing,項目名稱:Spring-5.0-Cookbook,代碼行數:12,代碼來源:TestEmployeeRxJavaService.java


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