title: spring boot web client and writing pact contracts
body: <p>So im trying to figure out how to write consumer contracts for the following class. I have written junit tests fine using mockwebserver.
  However for pact testing im struggling and cant seem to see how you get the weblient to use the response from server, all the examples tend to be for resttemplate.</p>
  <pre><code>public class OrdersGateway {
  
      public static final String PATH = &quot;/orders&quot;;
      private final WebClient webClient;
  
      @Autowired
      public OrdersGateway(String baseURL) {
  
          this.webClient = WebClient.builder()
                  .baseUrl(baseURL)
                  .defaultHeader(HttpHeaders.ACCEPT, MediaType.ALL_VALUE)
                  .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
                  .build();
      }
  
      @Override
      public Orderresponse findOrders() {
          return this.webClient
                  .post()
                  .uri(PATH)
                  .httpRequest(httpRequest -&gt; {
                      HttpClientRequest reactorRequest = httpRequest.getNativeRequest();
                      reactorRequest.responseTimeout(Duration.ofSeconds(4));
                  })
                  .exchangeToMono(response())
                  .block();
      }
  
      private Function&lt;ClientResponse, Mono&lt;OrderResponse&gt;&gt; response() {
          return result -&gt; {
                  if (result.statusCode().equals(HttpStatus.OK)) {
                      return result.bodyToMono(OrderResponse.class);
                  } else {
                      String exception = String.format(&quot;error&quot;, result.statusCode());
                      return Mono.error(new IllegalStateException(exception));
                  }
              };
      }
  
    
  }
  </code></pre>
  <p>Its the @test method for verification, im not sure how to create that. I cant see how the pact-mock-server can intercept the webcleint call.</p>