WIP
authorKai Moritz <kai@juplo.de>
Sat, 21 May 2022 17:58:18 +0000 (19:58 +0200)
committerKai Moritz <kai@juplo.de>
Sat, 21 May 2022 17:58:18 +0000 (19:58 +0200)
spring-consumer/src/test/java/de/juplo/demos/pact/ContractTest.java

index 8193d8b..610957a 100644 (file)
@@ -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();
   }