user11720939
user11720939

Reputation:

Testing @Retryable and @Recover methods in Spring Boot + Mockito

For one class e.g. called Class A, I call an external api (with exceptions and I have mocked the class). In Class B, I have a method that calls Class A's method with the potential exceptions that could occur. Class B has the @Retryable and @Recover method. I have Class A as a mock object and Class B as a spy. When I mock Class A to throw an exception and I verify the times it has been called - I get the correct maxAttempts called. However, when I try to check and verify the method for recover or retryable I get:

UnfinishedVerificationException
..
Missing method call for verify....

Does anyone know if it is possible to verify these method calls?

Upvotes: 0

Views: 1215

Answers (1)

Gary Russell
Gary Russell

Reputation: 174564

Those methods can't be mocked because they they are final methods created by spring-retry using a CGLIB proxy.

Upvotes: 1

Related Questions