From: Kai Moritz Date: Sat, 21 May 2022 17:58:18 +0000 (+0200) Subject: WIP X-Git-Tag: wip-umbau-array-contains~1 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=24f70d3bd46e07831e39727f6efa771b89c0d544;p=demos%2Fexample-siren WIP --- 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(); }