fail("Unexpected exception", e);
}
}
+
+ @Pact(consumer="SpringConsumer")
+ public RequestResponsePact deleteOrder(PactDslWithProvider builder)
+ {
+ return builder
+ .uponReceiving("delete order")
+ .matchPath("/orders/\\d+", "/orders/1234")
+ .method("DELETE")
+ .willRespondWith()
+ .status(200)
+ .toPact();
+ }
+
+ @Test
+ @PactTestFor(pactMethod = "deleteOrder")
+ public void testDeleteOrder(MockServer mockServer)
+ {
+ RestTemplate restTemplate =
+ new RestTemplateBuilder()
+ .rootUri(mockServer.getUrl())
+ .build();
+ try
+ {
+ restTemplate.delete("/orders/1234");
+ }
+ catch (Exception e)
+ {
+ fail("Unexpected exception", e);
+ }
+ }
}
"name": "SpringConsumer"
},
"interactions": [
+ {
+ "description": "delete order",
+ "request": {
+ "matchingRules": {
+ "path": {
+ "combine": "AND",
+ "matchers": [
+ {
+ "match": "regex",
+ "regex": "/orders/\\d+"
+ }
+ ]
+ }
+ },
+ "method": "DELETE",
+ "path": "/orders/1234"
+ },
+ "response": {
+ "status": 200
+ }
+ },
{
"description": "get all orders",
"request": {