-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Learning Reactive Programming With Java 8
By :
Using the operators and methods learned in the previous two sections, we are able to rework the test we've written to look like this:
@Test
public void testUsingBlockingObservable() {
List<String> result = tested
.toList()
.toBlocking()
.single();
Assert.assertEquals(expected, result);
}There is no boilerplate code here. We retrieve all the items emitted as a list and compare them to the expected list.
Using the BlockingObsevables class and the aggregate operators is pretty useful in most cases. While testing asynchronous Observable instances, which emit long, slow sequences, they are not so useful though. It is not good practice to block the test cases for a long time: slow tests are bad tests.
The source code for the preceding test can be found at https://github.com/meddle0x53/learning-rxjava/blob/master/src/test/java/com/packtpub/reactive/chapter07/SortedObservableTest.java—this is the second...
Change the font size
Change margin width
Change background colour