Skip to content

Instantly share code, notes, and snippets.

@talosdev
Created October 6, 2019 17:20
Show Gist options
  • Save talosdev/42fa7b09585622a65456cd4bbdffe7fb to your computer and use it in GitHub Desktop.
Save talosdev/42fa7b09585622a65456cd4bbdffe7fb to your computer and use it in GitHub Desktop.
@Throws(UndeliverableException::class)
@Test
fun `observable that throws error after emitting an item to single with firstOrError`() {
RxJavaPlugins.setErrorHandler { System.err.println("An unhandled exception was caught: $it") }
val observable = Observable.create<Int> { emitter ->
emitter.onNext(1)
emitter.onNext(2)
emitter.onError(RuntimeException("Exception while emitting Ints"))
}
assertObservableToSingle(observable, { firstOrError()}) {
assertComplete()
assertValue(1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment