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.

Revisions

  1. talosdev created this gist Oct 6, 2019.
    16 changes: 16 additions & 0 deletions ObservableToSingle_firstOrError_error2.kt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    @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)
    }
    }