import org.springframework.web.client.RestTemplate;
import java.util.Map;
-import java.util.regex.Pattern;
import static org.assertj.core.api.Assertions.fail;
.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 ->
+ 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->
{
- actions.object(object ->
+ object.matchUrl2("href", "orders");
+ object.array("rel", relArray ->
{
- object.stringType("name","update");
- object.stringType("method", "PUT");
- object.matchUrl2("href", Matchers.regexp("\\d+", "1234"));
+ relArray.stringValue("self");
});
});
});