Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
RxJava: Flowable to Single
@Test
public void testEmptyFlowableToSingle() {
Flowable.empty()
.flatMapSingle(o -> Single.just("result"))
.test()
.assertValueCount(0)
.assertNoErrors();
//There should have been an error
}
@Test
public void testFlowableToSingle() {
Flowable.just("item1", "item2")
.single("result")
.test()
.assertError(IllegalArgumentException.class)
.assertErrorMessage("Sequence contains more than one element!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment