WIP
authorKai Moritz <kai@juplo.de>
Sat, 21 May 2022 15:49:15 +0000 (17:49 +0200)
committerKai Moritz <kai@juplo.de>
Sat, 21 May 2022 15:49:15 +0000 (17:49 +0200)
spring-consumer/src/test/java/de/juplo/demos/pact/ContractTest.java
spring-consumer/target/pacts/SpringConsumer-Siren Order Provider.json

index 9486001..0e62c48 100644 (file)
@@ -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())
index 9356980..a325ecb 100644 (file)
         "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"
         },
                   "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": [