You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Or perhaps it would still be in a @Pact block, but as concise.)
The current pattern is much more verbose, and almost all of the content (ports, content type headers, endpoints, schema for return and input parameters ... ) is in there is already in the RestClient definition:
@Pact(provider = "farmer", consumer = "knitter")
public V4Pact createPact(PactDslWithProvider builder) throws JsonProcessingException {
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
// Here we define our mock, which is also our expectations for the provider
String sweaterBody = "{\"colour\":\"white\"}\n";
return builder.given("test POST")
.uponReceiving("POST REQUEST")
.path("/wool/order")
.method("POST")
.willRespondWith()
.status(200)
.headers(headers)
.body(sweaterBody)
.toPact(V4Pact.class);
}
Things that aren't in the client that would need to be defined in the equivalent of when(contractMock.get()).thenReturn("MockAnswer") are the various states (given), and the response values.
The text was updated successfully, but these errors were encountered:
When we define a rest client mock, the suggested pattern is this:
It would be nice to be able to do something similar for Pact, something like:
(Or perhaps it would still be in a
@Pact
block, but as concise.)The current pattern is much more verbose, and almost all of the content (ports, content type headers, endpoints, schema for return and input parameters ... ) is in there is already in the RestClient definition:
Things that aren't in the client that would need to be defined in the equivalent of
when(contractMock.get()).thenReturn("MockAnswer")
are the various states (given
), and the response values.The text was updated successfully, but these errors were encountered: