Can someone please explain me why PublishSubject
is not working nicely with firstOrError()
?
I'm expecting firstOrError
to return a NoSuchElementException
when the PublishSubject
is created without any value.
I wrote some tests in order to better explain the problem:
@Test
fun `test one`() {
// THIS TEST FAILS
val publishSubject = PublishSubject.create<Boolean>()
val testSubscriber = publishSubject
// .toFlowable(BackpressureStrategy.LATEST) // With or without this doesn't make any difference
.firstOrError()
.test()
testSubscriber
.assertNotComplete()
.assertError(NoSuchElementException::class.java)
}
@Test
fun `test two`() {
// THIS TEST PASSES
val flowable = Flowable.empty<Boolean>()
val testSubscriber = flowable
.firstOrError()
.test()
testSubscriber
.assertNotComplete()
.assertError(NoSuchElementException::class.java)
}