"name": "Siren Order Provider"
},
"interactions": [
- {
- "description": "get root",
- "request": {
- "method": "GET",
- "path": "/"
- },
- "response": {
- "body": {
- "class": [
- "representation"
- ],
- "links": [
- {
- "href": "http://localhost:8080/orders",
- "rel": [
- "orders"
- ]
- }
- ]
- },
- "generators": {
- "body": {
- "$.links[0].href": {
- "example": "http://localhost:8080/orders",
- "regex": ".*(\\/orders)$",
- "type": "MockServerURL"
- }
- }
- },
- "headers": {
- "Content-Type": "application/vnd.siren+json"
- },
- "matchingRules": {
- "body": {
- "$.links[0].href": {
- "combine": "AND",
- "matchers": [
- {
- "match": "regex",
- "regex": ".*(\\/orders)$"
- }
- ]
- }
- },
- "header": {}
- },
- "status": 200
- }
- },
{
"description": "get all orders",
"request": {
},
"status": 200
}
- },
- {
- "description": "delete order",
- "request": {
- "matchingRules": {
- "path": {
- "combine": "AND",
- "matchers": [
- {
- "match": "regex",
- "regex": "/orders/\\d+"
- }
- ]
- }
- },
- "method": "DELETE",
- "path": "/orders/1234"
- },
- "response": {
- "status": 200
- }
- }
- ],
- "metadata": {
- "pact-js": {
- "version": "10.0.0-beta.59"
- },
- "pactRust": {
- "ffi": "0.2.4",
- "models": "0.3.1"
- },
- "pactSpecification": {
- "version": "3.0.0"
}
- },
- "provider": {
- "name": "Siren Order Service"
- }
-}
\ No newline at end of file
+}
.headers(Map.of("Content-Type", "application/vnd.siren+json"))
.body(LambdaDsl.newJsonBody(body ->
{
+ body.array("class", classArray ->
+ {
+ classArray.stringValue("entity");
+ });
body.array("entities", entities ->
{
- body.arrayContaining("actions", actions ->
+ body.arrayContaining("actions", actionsArray ->
{
- actions.object(object ->
+ actionsArray.object(object ->
{
object.stringType("name","update");
object.stringType("method", "PUT");
object.matchUrl2("href", Matchers.regexp("\\d+", "1234").getValue());
});
- actions.object(object ->
+ actionsArray.object(object ->
{
object.stringType("name","delete");
object.stringType("method", "DELETE");
object.matchUrl2("href", Matchers.regexp("\\d+", "1234").getValue());
});
});
+ body.array("links", linksArray ->
+ {
+ linksArray.object(object->
+ {
+ object.matchUrl2("href", "orders");
+ object.array("rel", relArray ->
+ {
+ relArray.stringValue("self");
+ });
+ });
+ });
});
}).build())
.toPact();
"name": "delete"
}
],
+ "class": [
+ "entity"
+ ],
"entities": [
+ ],
+ "links": [
+ {
+ "href": "http://localhost:8080/orders",
+ "rel": [
+ "self"
+ ]
+ }
]
},
"generators": {
"body": {
+ "$.links[0].href": {
+ "example": "http://localhost:8080/orders",
+ "regex": ".*\\/(\\Qorders\\E)$",
+ "type": "MockServerURL"
+ },
"$[0].href": {
"example": "http://localhost:8080/1234",
"regex": ".*\\/(\\Q1234\\E)$",
]
}
]
+ },
+ "$.links[0].href": {
+ "combine": "AND",
+ "matchers": [
+ {
+ "match": "regex",
+ "regex": ".*\\/(\\Qorders\\E)$"
+ }
+ ]
}
}
},