AssertJ extensions for Mono and Flux.
Assertions extend from AssertJ core so a single import statement is enough to get both standard AssertJ methods as well as the reactive additions:
import static pl.rzrz.assertj.reactor.Assertions.assertThat;
Mono<Void> mono = Mono.error(new Exception());
assertThat(mono).sendsError();
Inspect the exception:
Mono<Void> mono = Mono.error(new RuntimeException("oops"));
assertThat(mono).sendsError(error -> {
assertThat(error).isInstanceOf(RuntimeException.class);
assertThat(error).hasMessage("oops");
});
Mono<Void> mono = Mono.just("this");
assertThat(mono).completes();
Flux<String> flux = Flux.just("one", "two", "three");
assertThat(flux).emitsCount(3);
Flux<String> flux = Flux.just("one", "two", "three");
assertThat(flux).emits("two");
Flux<String> flux = Flux.just("one", "two", "three");
assertThat(flux).emitsExactly("one", "two", "three");