WIP
[demos/example-siren] / spring-consumer / src / test / java / de / juplo / demos / pact / ContractTest.java
index 65ff03b..ad2835f 100644 (file)
@@ -32,11 +32,63 @@ public class ContractTest
             .headers(Map.of("Content-Type", "application/vnd.siren+json"))
             .body(LambdaDsl.newJsonBody(body ->
             {
-              body.arrayContaining("actions", actions ->
+              body.array("class", classArray ->
               {
-                actions.object(object ->
+                classArray.stringValue("entity");
+              });
+              body.array("entities", entities ->
+              {
+                entities.eachLike(entity ->
+                {
+                  entity.arrayContaining("actions", actionsArray->
+                  {
+                    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());
+                    });
+                  });
+                  entity.array("class", classArray ->
+                  {
+                    classArray.stringValue("entity");
+                  });
+                  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.stringType("id", "1234");
+                    object.array("rel", relArray ->
+                    {
+                      relArray.stringValue("item");
+                    });
+                  });
+                });
+              });
+              body.array("links", linksArray ->
+              {
+                linksArray.object(object->
                 {
-                  object.stringType("name","update");
+                  object.matchUrl2("href", "orders");
+                  object.array("rel", relArray ->
+                  {
+                    relArray.stringValue("self");
+                  });
                 });
               });
             }).build())