From 338294ec4a33a6da926d6ef11980720ce0b7739c Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 21 May 2022 17:49:15 +0200 Subject: [PATCH] WIP --- .../de/juplo/demos/pact/ContractTest.java | 2 ++ .../SpringConsumer-Siren Order Provider.json | 25 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/spring-consumer/src/test/java/de/juplo/demos/pact/ContractTest.java b/spring-consumer/src/test/java/de/juplo/demos/pact/ContractTest.java index 9486001..0e62c48 100644 --- a/spring-consumer/src/test/java/de/juplo/demos/pact/ContractTest.java +++ b/spring-consumer/src/test/java/de/juplo/demos/pact/ContractTest.java @@ -12,6 +12,7 @@ import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.web.client.RestTemplate; import java.util.Map; +import java.util.regex.Pattern; import static org.assertj.core.api.Assertions.fail; @@ -38,6 +39,7 @@ public class ContractTest { object.stringType("name","update"); object.stringType("method", "PUT"); + object.matchUrl2("href", Matchers.regexp("\\d+", "1234")); }); }); }).build()) diff --git a/spring-consumer/target/pacts/SpringConsumer-Siren Order Provider.json b/spring-consumer/target/pacts/SpringConsumer-Siren Order Provider.json index 9356980..a325ecb 100644 --- a/spring-consumer/target/pacts/SpringConsumer-Siren Order Provider.json +++ b/spring-consumer/target/pacts/SpringConsumer-Siren Order Provider.json @@ -13,11 +13,21 @@ "body": { "actions": [ { + "href": "http://localhost:8080/RegexpMatcher(regex=\\d+, value=1234)", "method": "PUT", "name": "update" } ] }, + "generators": { + "body": { + "$[0].href": { + "example": "http://localhost:8080/RegexpMatcher(regex=\\d+, value=1234)", + "regex": ".*\\/(\\QRegexpMatcher(regex=\\d+, value=1234)\\E)$", + "type": "MockServerURL" + } + } + }, "headers": { "Content-Type": "application/vnd.siren+json" }, @@ -31,10 +41,23 @@ "variants": [ { "generators": { - + "$.href": { + "example": "http://localhost:8080/RegexpMatcher(regex=\\d+, value=1234)", + "regex": ".*\\/(\\QRegexpMatcher(regex=\\d+, value=1234)\\E)$", + "type": "MockServerURL" + } }, "index": 0, "rules": { + "$.href": { + "combine": "AND", + "matchers": [ + { + "match": "regex", + "regex": ".*\\/(\\QRegexpMatcher(regex=\\d+, value=1234)\\E)$" + } + ] + }, "$.method": { "combine": "AND", "matchers": [ -- 2.20.1