本文整理汇总了Java中io.reactivex.observers.TestObserver.assertValues方法的典型用法代码示例。如果您正苦于以下问题:Java TestObserver.assertValues方法的具体用法?Java TestObserver.assertValues怎么用?Java TestObserver.assertValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.reactivex.observers.TestObserver
的用法示例。
在下文中一共展示了TestObserver.assertValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapToOneOrDefaultReturnsDefaultWhenNullCursor
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test public void mapToOneOrDefaultReturnsDefaultWhenNullCursor() {
Employee defaultEmployee = new Employee("bob", "Bob Bobberson");
Query nully = new Query() {
@Nullable @Override public Cursor run() {
return null;
}
};
TestObserver<Employee> observer = new TestObserver<>();
Observable.just(nully)
.lift(Query.mapToOneOrDefault(MAPPER, defaultEmployee))
.subscribe(observer);
observer.assertValues(defaultEmployee);
observer.assertComplete();
}
示例2: debugWalkthrough
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void debugWalkthrough() {
//Declare TestObserver
TestObserver<String> testObserver = new TestObserver<>();
//Source pushing three strings
Observable<String> items =
Observable.just("521934/2342/Foxtrot",
"Bravo/12112/78886/Tango",
"283242/4542/Whiskey/2348562");
//Split and concatMap() on "/"
items.concatMap(s ->
Observable.fromArray(s.split("/"))
)
//filter for only alphabetic Strings using regex
.filter(s -> s.matches("[A-Za-z]+"))
//Subscribe the TestObserver
.subscribe(testObserver);
//This succeeds
testObserver.assertValues("Foxtrot","Bravo","Tango","Whiskey");
}
示例3: testLifecycle
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
private void testLifecycle(LifecycleProvider<FragmentEvent> provider) {
Fragment fragment = (Fragment) provider;
FragmentTestUtil.startFragment(fragment);
TestObserver<FragmentEvent> testObserver = provider.lifecycle().skip(1).test();
fragment.onAttach(null);
fragment.onCreate(null);
fragment.onViewCreated(null, null);
fragment.onStart();
fragment.onResume();
fragment.onPause();
fragment.onStop();
fragment.onDestroyView();
fragment.onDestroy();
fragment.onDetach();
testObserver.assertValues(
FragmentEvent.ATTACH,
FragmentEvent.CREATE,
FragmentEvent.CREATE_VIEW,
FragmentEvent.START,
FragmentEvent.RESUME,
FragmentEvent.PAUSE,
FragmentEvent.STOP,
FragmentEvent.DESTROY_VIEW,
FragmentEvent.DESTROY,
FragmentEvent.DETACH
);
}
示例4: testLifecycle
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void testLifecycle() {
NaviEmitter activity = NaviEmitter.createActivityEmitter();
LifecycleProvider<ActivityEvent> provider = NaviLifecycle.createActivityLifecycleProvider(activity);
TestObserver<ActivityEvent> testObserver = provider.lifecycle().test();
activity.onCreate(null);
activity.onStart();
activity.onResume();
activity.onPause();
activity.onStop();
activity.onDestroy();
testObserver.assertValues(
ActivityEvent.CREATE,
ActivityEvent.START,
ActivityEvent.RESUME,
ActivityEvent.PAUSE,
ActivityEvent.STOP,
ActivityEvent.DESTROY
);
}
示例5: noEvents
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void noEvents() {
TestObserver<String> testObserver = stream
.compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, "stop"))
.test();
stream.onNext("1");
stream.onNext("2");
testObserver.assertValues("1", "2");
testObserver.assertNotTerminated();
}
示例6: testIsViewReady_AttachView_ShouldCallValueFalseTrue
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void testIsViewReady_AttachView_ShouldCallValueFalseTrue() throws Exception {
mPresenter.create();
final TestObserver<Boolean> test = RxTiPresenterUtils.isViewReady(mPresenter).test();
mPresenter.attachView(mView);
test.assertValues(false, true);
}
示例7: testNotifyModelChanged
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void testNotifyModelChanged() throws Exception {
TestObserver testSubscriber = flaxModel.getObservable().test();
flaxModel.notifyModelChanged();
flaxModel.notifyModelChanged();
// 3 values because the constructor of FlaxModel will call notifyModelChanged
testSubscriber.assertValueCount(3);
testSubscriber.assertValues(flaxModel, flaxModel, flaxModel);
}
示例8: noEvent
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void noEvent() {
TestObserver<String> testObserver = stream
.compose(RxLifecycle.<String, String>bind(lifecycle))
.test();
stream.onNext("1");
stream.onNext("2");
testObserver.assertValues("1", "2");
testObserver.assertNotTerminated();
}
示例9: oneStartEvent
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void oneStartEvent() {
TestObserver<String> testObserver = stream
.compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))
.test();
lifecycle.onNext("create");
stream.onNext("1");
stream.onNext("2");
testObserver.assertValues("1", "2");
testObserver.assertNotTerminated();
}
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:14,代码来源:UntilCorrespondingEventTransformerObservableTest.java
示例10: testReadWithDefault
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void testReadWithDefault() throws Exception {
RxPaperBook book = RxPaperBook.with("READ_WITH_DEFAULT", Schedulers.trampoline());
final String key = "hello";
final ComplexObject value = ComplexObject.random();
book.write(key, value).subscribe();
final TestObserver<ComplexObject> testSubscriber = book.<ComplexObject> read(key).test();
testSubscriber.awaitTerminalEvent();
testSubscriber.assertNoErrors();
testSubscriber.assertValueCount(1);
testSubscriber.assertValues(value);
// notFoundSubscriber
String noKey = ":(";
final ComplexObject defaultValue = ComplexObject.random();
final TestObserver<ComplexObject> notFoundSubscriber = book.read(noKey, defaultValue).test();
notFoundSubscriber.awaitTerminalEvent();
notFoundSubscriber.assertNoErrors();
notFoundSubscriber.assertValueCount(1);
notFoundSubscriber.assertValues(defaultValue);
// incorrectTypeSubscriber
book.<Integer> read(key).subscribe(new SingleObserver<Integer>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onSuccess(Integer integer) {
Assert.fail("Expected ClassCastException");
}
@Override
public void onError(Throwable e) {
if (!(e instanceof ClassCastException)) {
Assert.fail(e.getMessage());
}
}
});
}
示例11: oneEvent
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void oneEvent() {
TestObserver<String> testObserver = stream
.compose(RxLifecycle.<String, String>bind(lifecycle))
.test();
stream.onNext("1");
lifecycle.onNext("stop");
stream.onNext("2");
testObserver.assertValues("1");
testObserver.assertComplete();
}
示例12: postedObjectsAreReceived
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void postedObjectsAreReceived() {
TestObserver<Object> testSubscriber = new TestObserver<>();
mEventBus.observable().subscribe(testSubscriber);
Object event1 = new Object();
Object event2 = new Object();
mEventBus.post(event1);
mEventBus.post(event2);
testSubscriber.assertValues(event1, event2);
}
示例13: test_skip
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void test_skip() {
String[] fruits = { "mango", "pineapple", "apple", "mango", "papaya" };
Observable<String> observable = Observable.fromArray(fruits).skip(3);
TestObserver<String> testObserver = new TestObserver<>();
observable.subscribe(testObserver);
testObserver.assertComplete();
testObserver.assertValueCount(2);
testObserver.assertNoErrors();
testObserver.assertValues("mango", "papaya");
}
示例14: noEvents
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void noEvents() {
TestObserver<String> testObserver = stream
.compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))
.test();
stream.onNext("1");
stream.onNext("2");
testObserver.assertValues("1", "2");
testObserver.assertNotTerminated();
}
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:12,代码来源:UntilCorrespondingEventTransformerObservableTest.java
示例15: twoOpenEvents
import io.reactivex.observers.TestObserver; //导入方法依赖的package包/类
@Test
public void twoOpenEvents() {
TestObserver<String> testObserver = stream
.compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))
.test();
lifecycle.onNext("create");
stream.onNext("1");
lifecycle.onNext("start");
stream.onNext("2");
testObserver.assertValues("1", "2");
testObserver.assertNotTerminated();
}
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:15,代码来源:UntilCorrespondingEventTransformerObservableTest.java