final Response collectionResp = domainObjectResource.accessCollection("BSRL", "73", "visibleAndEditableCollection");
final RestfulResponse<ObjectCollectionRepresentation> collectionJsonResp = RestfulResponse.ofT(collectionResp);
assertThat(collectionJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
// then
final ObjectCollectionRepresentation collectionRepr = collectionJsonResp.getEntity();
assertThat(collectionRepr.getString("memberType"), is("collection"));
// self link
final LinkRepresentation selfLink = collectionRepr.getLinkWithRel(Rel.SELF);
assertThat(selfLink, isLink(client)
.httpMethod(RestfulHttpMethod.GET)
.href(endsWith("/objects/BSRL/73/collections/visibleAndEditableCollection"))
.returning(HttpStatusCode.OK)
.build());
// up link
final LinkRepresentation upLink = collectionRepr.getLinkWithRel(Rel.UP);
assertThat(upLink, isLink(client)
.httpMethod(RestfulHttpMethod.GET)
.href(endsWith("http://localhost:39393/objects/BSRL/73"))
.returning(HttpStatusCode.OK)
.type(RepresentationType.DOMAIN_OBJECT.getMediaType())
.title("Untitled Bus Rules Entity")
.build());
//addto link
final LinkRepresentation addtoLink = collectionRepr.getLinkWithRel(Rel.ADD_TO);
assertThat(addtoLink, isLink(client)
.httpMethod(RestfulHttpMethod.POST)
.type(RepresentationType.OBJECT_COLLECTION.getMediaType())
.href(endsWith("/objects/BSRL/73/collections/visibleAndEditableCollection"))
.build());
assertThat(addtoLink.getArguments(), is(not(nullValue())));
assertThat(addtoLink.getArguments().isArray(), is(false));
assertThat(addtoLink.getArguments().size(), is(1));
//remove-from link
final LinkRepresentation removeFromLink = collectionRepr.getLinkWithRel(Rel.REMOVE_FROM);
assertThat(removeFromLink, isLink(client)
.httpMethod(RestfulHttpMethod.DELETE)
.type(RepresentationType.OBJECT_COLLECTION.getMediaType())
.href(endsWith("/objects/BSRL/73/collections/visibleAndEditableCollection"))
.build());
assertThat(removeFromLink.getArguments(), is(not(nullValue())));
assertThat(removeFromLink.getArguments().isArray(), is(false));
assertThat(removeFromLink.getArguments().size(), is(1));
// described by link
final LinkRepresentation describedByLink = collectionRepr.getLinkWithRel(Rel.DESCRIBEDBY);
assertThat(describedByLink, isLink(client)
.returning(HttpStatusCode.OK)
.responseEntityWithSelfHref(describedByLink.getHref())
.build());
assertThat(collectionRepr.getArray("value").isArray(),is(true));
assertThat(collectionRepr.getExtensions(), isMap());
assertThat(collectionRepr.getExtensions().getString("collectionSemantics"), is("list"));
assertThat(collectionRepr.getExtensions().getArray("changed").isArray(), is(true));
assertThat(collectionRepr.getExtensions().getArray("disposed").isArray(), is(true));
}