From: Kai Moritz Date: Sat, 21 May 2022 15:11:30 +0000 (+0200) Subject: Beispiel von der klassischen DSL auf die Lambda-DSL umgestellt X-Git-Tag: wip-umbau-array-contains~14 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=7a8c1cc6f0ff8a7cc3e1778574310a094c7e9688;p=demos%2Fexample-siren Beispiel von der klassischen DSL auf die Lambda-DSL umgestellt --- 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 d7358d8..8db0dbc 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 @@ -1,7 +1,9 @@ package de.juplo.demos.pact; import au.com.dius.pact.consumer.MockServer; +import au.com.dius.pact.consumer.dsl.LambdaDsl; import au.com.dius.pact.consumer.dsl.PactDslJsonBody; +import au.com.dius.pact.consumer.dsl.PactDslJsonRootValue; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; @@ -24,13 +26,6 @@ public class ContractTest @Pact(consumer="SpringConsumer") public RequestResponsePact getOrders(PactDslWithProvider builder) { - PactDslJsonBody body = new PactDslJsonBody() - .stringType("name") - .booleanType("happy") - .hexValue("hexCode") - .id() - .ipAddress("localAddress") - .numberValue("age", 100); return builder .uponReceiving("get all orders") .path("/orders") @@ -38,7 +33,15 @@ public class ContractTest .willRespondWith() .status(200) .headers(Map.of("Content-Type", "application/vnd.siren+json")) - .body(body) + .body(LambdaDsl.newJsonBody(body -> + { + body.stringType("name"); + body.booleanType("happy"); + // body.hexValue("hexCode"); + body.id(); + body.ipV4Address("localAddress"); + body.numberValue("age", 100); + }).build()) .toPact(); } diff --git a/spring-consumer/target/pacts/SpringConsumer-Siren Order Provider.json b/spring-consumer/target/pacts/SpringConsumer-Siren Order Provider.json index 953d4e6..2ae8cea 100644 --- a/spring-consumer/target/pacts/SpringConsumer-Siren Order Provider.json +++ b/spring-consumer/target/pacts/SpringConsumer-Siren Order Provider.json @@ -13,17 +13,12 @@ "body": { "age": 100, "happy": true, - "hexCode": "1234a", "id": 1234567890, "localAddress": "127.0.0.1", "name": "string" }, "generators": { "body": { - "$.hexCode": { - "digits": 10, - "type": "RandomHexadecimal" - }, "$.id": { "max": 2147483647, "min": 0, @@ -48,15 +43,6 @@ } ] }, - "$.hexCode": { - "combine": "AND", - "matchers": [ - { - "match": "regex", - "regex": "[0-9a-fA-F]+" - } - ] - }, "$.id": { "combine": "AND", "matchers": [