本文整理汇总了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();
}
}
}
示例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();
}
示例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");
}
示例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());
}
}