The following function:
private Boolean canDoIt(Parameter param) {
return myService
.getMyObjectInReactiveWay(param)
.map(myObject -> myService.checkMyObjectInImperativeWay(myObject))
.block();
}
is working fine at runtime, but when testing a flow which uses it using WebTestClient I get the following error:
java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread parallel-1
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83) ~[reactor-core-3.4.1.jar:3.4.1]
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Assembly trace from producer [reactor.core.publisher.MonoFlatMap] :
reactor.core.publisher.Mono.flatMap
I know I am not supposed to use block() but I have not other choice: the function has to return a Boolean (not a Mono<Boolean>). Perhaps there is an alternative way to write it which doesn't use block().
Is there a way I can make WebTestClient not throw that error?
Using Reactor Core version 3.4.6.