0
votes

I have this interface:

interface PageRepository {
  fun findAll(): Flux<Flux<Page>>
}

And I want to test its implementation but I'm getting: java.lang.AssertionError: expectation "expectNext(FluxIterable)" failed (expected value: FluxIterable; actual value: UnicastProcessor)

In the test I'm using expectNext():

 repository
      .findAll()
      .test()
      .expectSubscription()
      .expectNext(listOf(page(PATH_1), page(PATH_2)).toFlux())
      .expectNext(listOf(page(PATH_3), page(PATH_4)).toFlux())
      .expectNext(listOf(page(PATH_5)).toFlux())
      .verifyComplete()

What I'm missing

1

1 Answers

4
votes

expectNext use equals that's why this fail even if both flux contains the same data they are not the same.

What you could do is the following:

repository().findAll()
        .test()
        .expectSubscription()
        .assertNext {
            it.test()
                    .expectNext(page(PATH_1), page(PATH_2))
                    .verifyComplete()
        }.assertNext {
            it.test()
                    .expectNext(page(PATH_3), page(PATH_4))
                    .verifyComplete()
        }.assertNext {
            it.test()
                    .expectNext(page(PATH_5))
                    .verifyComplete()
        }.verifyComplete()

I don't know if there is a better option but this should work.