I am using Smallrye Mutiniy in my Quarkus project. One of my function have .emitOn(MutinyHelper.executor(vertx))
appended to the pipeline.
@Inject
private final Vertx vertx;
public Uni<Void> process(int request) {
return repo.findByRequest(countryCode)
.onItem().invoke(Unchecked.consumer(cashbackConfig -> {
if (...) {
throw new DataProcessingException("....");
}
}))
.emitOn(Infrastructure.getDefaultWorkerPool())
// process items, blocking process so I moved to worker thread
.onItem().transformToUni(items -> processPerBatch(items))
// emit back the item to I/O thread
.emitOn(MutinyHelper.executor(vertx));
}
However, when I write unit test for this class, the vertx never seems to finishes:
@Test
void test_process_success() {
// Mock data
// Mock function
// Function call
UniAssertSubscriber<Void> subscriber = testedClass.process(request)
.subscribe().withSubscriber(UniAssertSubscriber.create());
// asserts
subscriber.awaitItem();
}
error:
java.lang.AssertionError: No item (or failure) event received in the last 10000 ms
at io.smallrye.mutiny.helpers.test.UniAssertSubscriber.awaitItem(UniAssertSubscriber.java:159)
at io.smallrye.mutiny.helpers.test.UniAssertSubscriber.awaitItem(UniAssertSubscriber.java:143)
when I try and remove the .emitOn(Infrastructure.getDefaultWorkerPool())
the test finishes
please advice what should I do