当前位置: 首页>>代码示例>>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;未经允许,请勿转载。