I’m using QuarkusComponentTest
and I have some service methods that I need to do unit tests.
Since we moved to hibernate reactive we introduce the Panache.withTransaction
like on the method below:
public Uni<List<Owner>> listOwnerObjects() {
return Panache.withTransaction(() -> ownerRepository.findWithPagination())
.onItem().transform(
list -> list.stream().map(i -> joinMapper.mapOwnerEntityToDto(i, joinMapperContext)).toList());
}
I’m using @InjectMock
to inject the repository and PanacheQuery
.
But I don’t know how to deal with this error:
java.lang.IllegalStateException: No current Vertx context found
at io.quarkus.hibernate.reactive.panache.common.runtime.SessionOperations.vertxContext(SessionOperations.java:191)
at io.quarkus.hibernate.reactive.panache.common.runtime.SessionOperations.withSession(SessionOperations.java:110)
at io.quarkus.hibernate.reactive.panache.common.runtime.SessionOperations.withTransaction(SessionOperations.java:88)
at io.quarkus.hibernate.reactive.panache.Panache.withTransaction(Panache.java:52)
3