From 24f70d3bd46e07831e39727f6efa771b89c0d544 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sat, 21 May 2022 19:58:18 +0200 Subject: [PATCH] WIP --- .../de/juplo/demos/pact/ContractTest.java | 56 ++++++++++++++----- 1 file changed, 41 insertions(+), 15 deletions(-) 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 8193d8b..610957a 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 @@ -38,33 +38,59 @@ public class ContractTest }); body.array("entities", entities -> { - body.arrayContaining("actions", actionsArray -> + entities.eachLike(entity -> { - actionsArray.object(object -> + entity.arrayContaining("action", actionsArray-> { - object.stringType("name","update"); - object.stringType("method", "PUT"); - object.matchUrl2("href", Matchers.regexp("\\d+", "1234").getValue()); + actionsArray.object(object -> + { + object.stringType("name","update"); + object.stringType("method", "PUT"); + object.matchUrl2("href", Matchers.regexp("\\d+", "1234").getValue()); + }); + actionsArray.object(object -> + { + object.stringType("name","delete"); + object.stringType("method", "DELETE"); + object.matchUrl2("href", Matchers.regexp("\\d+", "1234").getValue()); + }); }); - actionsArray.object(object -> + entity.array("class", classArray -> { - object.stringType("name","delete"); - object.stringType("method", "DELETE"); - object.matchUrl2("href", Matchers.regexp("\\d+", "1234").getValue()); + classArray.stringValue("entity"); }); - }); - body.array("links", linksArray -> - { - linksArray.object(object-> + entity.array("links", linksArray -> + { + linksArray.object(object-> + { + object.matchUrl2("href", "orders", Matchers.regexp("\\d+", "1234")); + object.array("rel", relArray -> + { + relArray.stringValue("self"); + }); + }); + }); + entity.object("properties", object-> { - object.matchUrl2("href", "orders"); + object.stringType("id", "1234"); object.array("rel", relArray -> { - relArray.stringValue("self"); + relArray.stringValue("item"); }); }); }); }); + body.array("links", linksArray -> + { + linksArray.object(object-> + { + object.matchUrl2("href", "orders"); + object.array("rel", relArray -> + { + relArray.stringValue("self"); + }); + }); + }); }).build()) .toPact(); } -- 2.20.1