quarkus: java.lang.IllegalStateException: This method is normally automatically..... in IT tests
I got this Exception running IT tests with ‘mvn test’:
java.lang.IllegalStateException: This method is normally automatically overridden in subclasses: did you forget to annotated your entity with @Entity?
this happen when I call this simple method of OrdiniService injected in the test:
@Path("/ordini")
@Slf4j
@Validating
@Authorizing
@Dependent
public class OrdiniService implements PanacheRepositoryBase<Ordine, String> {
@GET
@NoCache
@Path("{id}")
@Produces(MediaType.APPLICATION_JSON)
public Ordine findOrdineById(@PathParam("id") @NotNull String id) {
return findById(id);
}
All works as expected when I run this method through the JAX-RS interface with the ‘quarkus:dev’ goal.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 12
- Comments: 43 (34 by maintainers)
Commits related to this issue
- TODO: This test will fail until https://github.com/quarkusio/quarkus/issues/1724 has been resolved. — committed to ClaudenirFreitas/quarkus-microservice-test by deleted user 5 years ago
- Test for #1724 — committed to danielpetisme/quarkus by danielpetisme 5 years ago
- Test for #1724 — committed to danielpetisme/quarkus by danielpetisme 5 years ago
I found an interesting, somehow clean workaround:
This is using lombok @Delegate so you call the methods directly from the Wrapper. Once this is fixed, only the type needs to be changed. Alternative, a get method to the UserRepository on the inner class can be exposed and it also seems to work.
That won’t help when running from an IDE.
I will need to look into this. JUnit 5 is actually really restrictive around this, in a lot of ways it is less extensible than JUnit 4.
Yes!
Well sort of, they have not released it yet, but it will be integrated into the new ClassLoader work at https://github.com/stuartwdouglas/quarkus/tree/new-class-loading . Even if the timing does not work we can just document how to work around the double @BeforeAll.
I’ve just hit the same issue (Quarkus version 0.28.1). Basically I have a
BookPanache entity:Manipulated by a transactional service :
And the Quarkus test injects the service:
The test fails and Quarkus complains about the
findByIdmethod (I do not have any@BeforeAll):