How to test retryExceptionPredicate or resultPredicate #2083
Unanswered
BaruchDavid
asked this question in
Q&A
Replies: 1 comment
-
I would usually use Wiremock to test it in a SpringBootTest. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hallo, ich habe erfolgreich den Retry implementiert und dabei den resultPredicate bzw. retryExceptionPredicate verwendet.
Mein Ziel dabei ist, dass ich nur bei einem 500 StatusCode den Retry ausführen möchte.
Nun möchte ich das testen (SpringBoot) und würde gerne verifizieren, dass mein Predicat 3 Mal aufgerufen würde.
Wie kann ich das tun?
Mein Code ist:
`public class MyAdapter {
}`
and my Predicat is:
` @slf4j
public class ErrorPredicat implements Predicate {
}`
and my Config is:
resilience4j: retry: instances: throwingFeignException: maxAttempts: 3 waitDuration: 1s exponentialBackoffMultiplier: 2 resultPredicate: com.my.ErrorPredicat retryExceptionPredicate: com.my.ErrorPredicat failAfterMaxAttempts: true
and now my Test, where i would like check that ErrorPredicat.test() was called three times:
`
@SpringBootTest
@activeprofiles("test")
class EaziAdapterRetryTest {
}
`
Beta Was this translation helpful? Give feedback.
All reactions