Java Code Examples for rx.observers.TestObserver#assertReceivedOnNext()
The following examples show how to use
rx.observers.TestObserver#assertReceivedOnNext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileObservableTest.java From newts with Apache License 2.0 | 6 votes |
@Test public void testLines() throws IOException { Path testFile = tempFile("target/testing/lines-test"); List<String> lines = createTestFile(testFile, "line1", "line2", "line3", "", "line5" ); TestObserver<String> testObserver = new TestObserver<>(); Observable<String> contents = FileObservable.lines(testFile); contents.subscribe(testObserver); testObserver.assertReceivedOnNext(lines); testObserver.assertTerminalEvent(); }
Example 2
Source File: DeliverReplayTest.java From FlowGeek with GNU General Public License v2.0 | 4 votes |
@Test public void testPagingCapabilities() { PublishSubject<Object> view = PublishSubject.create(); BehaviorSubject<Integer> nextPageRequests = BehaviorSubject.create(); final TestObserver<Delivery<Object, String>> testObserver = new TestObserver<>(); nextPageRequests .concatMap(new Func1<Integer, Observable<Integer>>() { @Override public Observable<Integer> call(Integer targetPage) { return targetPage <= requestedPageCount ? Observable.<Integer>never() : Observable.range(requestedPageCount, targetPage - requestedPageCount); } }) .doOnNext(new Action1<Integer>() { @Override public void call(Integer it) { requestedPageCount = it + 1; } }) .startWith(Observable.range(0, requestedPageCount)) .concatMap(new Func1<Integer, Observable<String>>() { @Override public Observable<String> call(final Integer page) { return requestPage(page, PAGE_SIZE); } }) .compose(new DeliverReplay<Object, String>(view)) .subscribe(testObserver); ArrayList<Delivery<Object, String>> onNext = new ArrayList<>(); testObserver.assertReceivedOnNext(onNext); view.onNext(999); addOnNext(onNext, 999, 0, 1, 2); testObserver.assertReceivedOnNext(onNext); nextPageRequests.onNext(2); addOnNext(onNext, 999, 3, 4, 5); testObserver.assertReceivedOnNext(onNext); view.onNext(null); assertEquals(0, testObserver.getOnCompletedEvents().size()); testObserver.assertReceivedOnNext(onNext); nextPageRequests.onNext(3); assertEquals(0, testObserver.getOnCompletedEvents().size()); testObserver.assertReceivedOnNext(onNext); view.onNext(9999); addOnNext(onNext, 9999, 0, 1, 2, 3, 4, 5, 6, 7, 8); assertEquals(0, testObserver.getOnCompletedEvents().size()); testObserver.assertReceivedOnNext(onNext); }
Example 3
Source File: DeliverReplayTest.java From nucleus with MIT License | 4 votes |
@Test public void testPagingCapabilities() { PublishSubject<Object> view = PublishSubject.create(); BehaviorSubject<Integer> nextPageRequests = BehaviorSubject.create(); final TestObserver<Delivery<Object, String>> testObserver = new TestObserver<>(); nextPageRequests .concatMap(new Func1<Integer, Observable<Integer>>() { @Override public Observable<Integer> call(Integer targetPage) { return targetPage <= requestedPageCount ? Observable.<Integer>never() : Observable.range(requestedPageCount, targetPage - requestedPageCount); } }) .doOnNext(new Action1<Integer>() { @Override public void call(Integer it) { requestedPageCount = it + 1; } }) .startWith(Observable.range(0, requestedPageCount)) .concatMap(new Func1<Integer, Observable<String>>() { @Override public Observable<String> call(final Integer page) { return requestPage(page, PAGE_SIZE); } }) .compose(new DeliverReplay<Object, String>(view)) .subscribe(testObserver); ArrayList<Delivery<Object, String>> onNext = new ArrayList<>(); testObserver.assertReceivedOnNext(onNext); view.onNext(999); addOnNext(onNext, 999, 0, 1, 2); testObserver.assertReceivedOnNext(onNext); nextPageRequests.onNext(2); addOnNext(onNext, 999, 3, 4, 5); testObserver.assertReceivedOnNext(onNext); view.onNext(null); assertEquals(0, testObserver.getOnCompletedEvents().size()); testObserver.assertReceivedOnNext(onNext); nextPageRequests.onNext(3); assertEquals(0, testObserver.getOnCompletedEvents().size()); testObserver.assertReceivedOnNext(onNext); view.onNext(9999); addOnNext(onNext, 9999, 0, 1, 2, 3, 4, 5, 6, 7, 8); assertEquals(0, testObserver.getOnCompletedEvents().size()); testObserver.assertReceivedOnNext(onNext); }