Skip to content

Instantly share code, notes, and snippets.

@deepakazad
Last active June 28, 2017 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deepakazad/0d1836a30b2885e71e42fb6185c62d78 to your computer and use it in GitHub Desktop.
Save deepakazad/0d1836a30b2885e71e42fb6185c62d78 to your computer and use it in GitHub Desktop.
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