title: How to create unit tests for methods annotated with @Circuitbreaker
body: <p>I implemented resilience4j in my project using the Spring Boot2 starter (<a href="https://resilience4j.readme.io/docs/getting-started-3" rel="noreferrer">https://resilience4j.readme.io/docs/getting-started-3</a>).</p>
  
  <p>I annotated a method with @CircuitBreaker that uses http client for calling an external service and the circuit breaker is working fine - including its fallback.</p>
  
  <p>I'd like to add unit tests for it but when I run a test trying to simulate the fallback, nothing happens - the exception is thrown but is not handled by the circuit breaker mechanism.</p>
  
  <p>I've found some examples using its metrics but it is not useful in my case.</p>
  
  <p>Any thoughts?</p>
  
  <p>Here is a snippet of my client:</p>
  
  <pre><code>@CircuitBreaker(name = "MY_CICUIT_BREAKER", fallbackMethod = "fallback")
      public ResponseEntity&lt;String&gt; search(String value) {
  
          ResponseEntity&lt;String&gt; responseEntity = restTemplate.exchange(
                  searchURL,
                  HttpMethod.GET,
                  new HttpEntity(new HttpHeaders()),
                  String.class,
                  value);
      }
  
  public ResponseEntity&lt;String&gt; fallback(String value, ResourceAccessException ex) {
          return "fallback executed";
      }
  </code></pre>