Skip to content

Instantly share code, notes, and snippets.

Created December 22, 2022 14:00
What would you like to do?
Pact definition with matching dsl
@Pact(provider = "UserServiceJUnit5", consumer = "UserConsumer")
public V4Pact getAllUsers(PactBuilder builder) {
return builder
.given("A running user service")
.uponReceiving("A request for a user list")
.headers(Map.of("Content-Type", "application/json"))
.body(new PactDslJsonArray()
.integerMatching("id", "[0-9]*", 1)
.stringMatcher("name", "[a-zA-Z ]*", "Jane Doe")
.integerMatching("id", "[0-9]*", 2)
.stringMatcher("name", "[a-zA-Z ]*", "John Doe")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment