query, to check for the data, and then continue the code execution. @Test void checkEventWithRestriction_Success() { String cpf = "55856777050"; checkForRestriction(cpf); await().atMost(10, SECONDS).until(eventIsFound(cpf)); given().pathParam("cpf", cpf).when().get("/events/{cpf}").then().statusCode(SC_OK); } // 👇 the Callable will do the trick public Callable<Boolean> eventIsFound(String cpf) { return () -> eventRepository.findByCpf(cpf).isPresent(); }