You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2013/03/13 00:32:22 UTC
[14/38] ISIS-233: home page tck testing
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/LinkFollowerTest_follow.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/LinkFollowerTest_follow.java b/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/LinkFollowerTest_follow.java
deleted file mode 100644
index dbb678d..0000000
--- a/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/LinkFollowerTest_follow.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.restfulobjects.rendering;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.util.Parser;
-import org.junit.Test;
-
-public class LinkFollowerTest_follow {
-
- @Test
- public void simple() throws Exception {
- final List<List<String>> links = asListOfLists("a.b.c");
-
- final LinkFollower linkFollower = LinkFollower.create(links);
-
- assertThat(linkFollower.follow("a").isFollowing(), is(true));
- assertThat(linkFollower.follow("a").isTerminated(), is(false));
- }
-
- @Test
- public void notMatching() throws Exception {
- final List<List<String>> links = asListOfLists("a.b.c");
-
- final LinkFollower linkFollower = LinkFollower.create(links);
-
- assertThat(linkFollower.follow("x").isFollowing(), is(false));
- assertThat(linkFollower.follow("x").isTerminated(), is(true));
- }
-
- @Test
- public void create_noCriteria() throws Exception {
- final List<List<String>> links = asListOfLists("a.b.c");
-
- final LinkFollower linkFollower = LinkFollower.create(links);
-
- assertThat(linkFollower.criteria().size(), is(0));
- assertThat(linkFollower.matches(JsonRepresentation.newMap()), is(true));
- }
-
- @Test
- public void follow_noCriteria() throws Exception {
- final List<List<String>> links = asListOfLists("a.b.c");
-
- final LinkFollower linkFollower = LinkFollower.create(links);
-
- final LinkFollower followA = linkFollower.follow("a");
-
- assertThat(followA.criteria().size(), is(0));
- assertThat(linkFollower.matches(JsonRepresentation.newMap()), is(true));
- }
-
- @Test
- public void follow_withSingleCriteria() throws Exception {
- final List<List<String>> links = asListOfLists("a[x=y].b.c");
-
- final LinkFollower linkFollower = LinkFollower.create(links);
-
- assertThat(linkFollower.follow("x").isFollowing(), is(false));
-
- final LinkFollower followA = linkFollower.follow("a");
-
- assertThat(followA.isFollowing(), is(true));
- final Map<String, String> criteria = followA.criteria();
- assertThat(criteria.size(), is(1));
- assertThat(criteria.get("x"), is("y"));
- assertThat(followA.matches(JsonRepresentation.newMap("x", "y")), is(true));
- assertThat(followA.matches(JsonRepresentation.newMap()), is(false));
- assertThat(followA.matches(JsonRepresentation.newMap("x", "z")), is(false));
- }
-
- @Test
- public void follow_withMultipleCriteria() throws Exception {
- final List<List<String>> links = asListOfLists("a[x=y z=w].b.c");
-
- final LinkFollower linkFollower = LinkFollower.create(links);
-
- assertThat(linkFollower.follow("x").isFollowing(), is(false));
-
- final LinkFollower followA = linkFollower.follow("a");
-
- assertThat(followA.isFollowing(), is(true));
- final Map<String, String> criteria = followA.criteria();
- assertThat(criteria.size(), is(2));
-
- assertThat(criteria.get("x"), is("y"));
- assertThat(criteria.get("z"), is("w"));
- assertThat(followA.matches(JsonRepresentation.newMap("x", "y", "z", "w")), is(true));
- assertThat(followA.matches(JsonRepresentation.newMap("x", "y", "z", "w", "foo", "bar")), is(true));
- assertThat(followA.matches(JsonRepresentation.newMap()), is(false));
- assertThat(followA.matches(JsonRepresentation.newMap("x", "y")), is(false));
- assertThat(followA.matches(JsonRepresentation.newMap("x", "y", "foo", "bar")), is(false));
- assertThat(followA.matches(JsonRepresentation.newMap("x", "bad")), is(false));
- assertThat(followA.matches(JsonRepresentation.newMap("x", "y", "z", "bad")), is(false));
- }
-
-
- @Test
- public void simple_multiplePaths() throws Exception {
- final List<List<String>> links = asListOfLists("a.b.c,x.y.z");
-
- final LinkFollower linkFollower = LinkFollower.create(links);
-
- LinkFollower followA = linkFollower.follow("a");
- assertThat(followA.isFollowing(), is(true));
- assertThat(followA.isTerminated(), is(false));
-
- LinkFollower followX = linkFollower.follow("x");
- assertThat(followX.isFollowing(), is(true));
- assertThat(followX.isTerminated(), is(false));
-
- LinkFollower followXY = followX.follow("y");
- assertThat(followXY.isFollowing(), is(true));
- assertThat(followXY.isTerminated(), is(false));
-
- LinkFollower followXYZ = followXY.follow("z");
- assertThat(followXYZ.isFollowing(), is(true));
- assertThat(followXYZ.isTerminated(), is(false));
-
- LinkFollower followXYZQ = followXY.follow("q");
- assertThat(followXYZQ.isFollowing(), is(false));
- assertThat(followXYZQ.isTerminated(), is(true));
- }
-
- @Test
- public void multiplePaths_withCriteria() throws Exception {
- final List<List<String>> links = asListOfLists("links[rel=urn:org.restfulobjects:rels/version].x,links[rel=urn:org.restfulobjects:rels/user].y");
-
- final LinkFollower linkFollower = LinkFollower.create(links);
-
- LinkFollower followRelVersion = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/version]");
- assertThat(followRelVersion.isFollowing(), is(true));
- assertThat(followRelVersion.isTerminated(), is(false));
-
- assertThat(followRelVersion.follow("x").isFollowing(), is(true));
-
- LinkFollower followRelUser = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/user]");
- assertThat(followRelUser.isFollowing(), is(true));
- assertThat(followRelUser.isTerminated(), is(false));
- assertThat(followRelUser.follow("y").isFollowing(), is(true));
- }
-
-
- private List<List<String>> asListOfLists(final String string) {
- return Parser.forListOfListOfStrings().valueOf(string);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainServiceResourceServerside.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainServiceResourceServerside.java b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainServiceResourceServerside.java
index cb2a4b1..8132967 100644
--- a/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainServiceResourceServerside.java
+++ b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainServiceResourceServerside.java
@@ -32,6 +32,7 @@ import javax.ws.rs.core.Response;
import org.apache.isis.applib.annotation.Where;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
import org.apache.isis.viewer.restfulobjects.applib.RestfulMediaType;
import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
@@ -53,7 +54,7 @@ public class DomainServiceResourceServerside extends ResourceAbstract implements
final List<ObjectAdapter> serviceAdapters = getResourceContext().getServiceAdapters();
final ListReprRenderer renderer = new ListReprRenderer(getResourceContext(), null, JsonRepresentation.newMap());
- renderer.usingLinkToBuilder(new DomainServiceLinkTo()).withSelf("services").with(serviceAdapters);
+ renderer.usingLinkToBuilder(new DomainServiceLinkTo()).withLink(Rel.SELF, "services").with(serviceAdapters);
return responseOfOk(renderer, Caching.ONE_DAY).build();
}
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/HomePageReprRenderer.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/HomePageReprRenderer.java b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/HomePageReprRenderer.java
index c5d2da2..09eafb3 100644
--- a/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/HomePageReprRenderer.java
+++ b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/HomePageReprRenderer.java
@@ -28,9 +28,8 @@ import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.Rel;
import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
import org.apache.isis.viewer.restfulobjects.rendering.LinkBuilder;
-import org.apache.isis.viewer.restfulobjects.rendering.LinkFollower;
+import org.apache.isis.viewer.restfulobjects.rendering.LinkFollowSpecs;
import org.apache.isis.viewer.restfulobjects.rendering.RendererContext;
-import org.apache.isis.viewer.restfulobjects.rendering.ReprRenderer;
import org.apache.isis.viewer.restfulobjects.rendering.ReprRendererAbstract;
import org.apache.isis.viewer.restfulobjects.rendering.domainobjects.DomainServiceLinkTo;
import org.apache.isis.viewer.restfulobjects.rendering.domainobjects.ListReprRenderer;
@@ -39,7 +38,7 @@ import org.apache.isis.viewer.restfulobjects.server.ResourceContext;
public class HomePageReprRenderer extends ReprRendererAbstract<HomePageReprRenderer, Void> {
- HomePageReprRenderer(final RendererContext resourceContext, final LinkFollower linkFollower, final JsonRepresentation representation) {
+ HomePageReprRenderer(final RendererContext resourceContext, final LinkFollowSpecs linkFollower, final JsonRepresentation representation) {
super(resourceContext, linkFollower, RepresentationType.HOME_PAGE, representation);
}
@@ -70,11 +69,9 @@ public class HomePageReprRenderer extends ReprRendererAbstract<HomePageReprRende
private void addLinkToSelf(final JsonRepresentation representation) {
final JsonRepresentation link = LinkBuilder.newBuilder(rendererContext, Rel.SELF.getName(), getRepresentationType(), "").build();
- final LinkFollower linkFollower = getLinkFollower().follow("links[rel=" + Rel.SELF.getName() + "]");
+ final LinkFollowSpecs linkFollower = getLinkFollowSpecs().follow("links[rel=" + Rel.SELF.getName() + "]");
if (linkFollower.matches(link)) {
-
final HomePageReprRenderer renderer = new HomePageReprRenderer(getRendererContext(), linkFollower, JsonRepresentation.newMap());
-
link.mapPut("value", renderer.render());
}
getLinks().arrayAdd(link);
@@ -83,11 +80,9 @@ public class HomePageReprRenderer extends ReprRendererAbstract<HomePageReprRende
private void addLinkToVersion() {
final JsonRepresentation link = LinkBuilder.newBuilder(getRendererContext(), Rel.VERSION.getName(), RepresentationType.VERSION, "version").build();
- final LinkFollower linkFollower = getLinkFollower().follow("links[rel=" + Rel.VERSION.getName() + "]");
+ final LinkFollowSpecs linkFollower = getLinkFollowSpecs().follow("links[rel=" + Rel.VERSION.getName() + "]");
if (linkFollower.matches(link)) {
-
final VersionReprRenderer renderer = new VersionReprRenderer(getRendererContext(), linkFollower, JsonRepresentation.newMap());
-
link.mapPut("value", renderer.render());
}
@@ -98,11 +93,11 @@ public class HomePageReprRenderer extends ReprRendererAbstract<HomePageReprRende
final JsonRepresentation link = LinkBuilder.newBuilder(getRendererContext(), Rel.SERVICES.getName(), RepresentationType.LIST, "services").build();
- final LinkFollower linkFollower = getLinkFollower().follow("links[rel=" + Rel.SERVICES.getName() + "]");
- if (linkFollower.matches(link)) {
+ final LinkFollowSpecs linkFollowSpecs = getLinkFollowSpecs().follow("links");
+ if (linkFollowSpecs.matches(link)) {
- final ListReprRenderer renderer = new ListReprRenderer(getRendererContext(), linkFollower, JsonRepresentation.newMap());
- renderer.usingLinkToBuilder(new DomainServiceLinkTo()).withSelf("services").with(serviceAdapters);
+ final ListReprRenderer renderer = new ListReprRenderer(getRendererContext(), linkFollowSpecs, JsonRepresentation.newMap());
+ renderer.usingLinkToBuilder(new DomainServiceLinkTo()).withLink(Rel.SELF, "services").with(serviceAdapters);
link.mapPut("value", renderer.render());
}
@@ -113,11 +108,10 @@ public class HomePageReprRenderer extends ReprRendererAbstract<HomePageReprRende
private void addLinkToUser(AuthenticationSession authenticationSession) {
final JsonRepresentation link = LinkBuilder.newBuilder(getRendererContext(), Rel.USER.getName(), RepresentationType.USER, "user").build();
- final LinkFollower linkFollower = getLinkFollower().follow("links[rel=" + Rel.USER.getName() + "]");
+ final LinkFollowSpecs linkFollower = getLinkFollowSpecs().follow("links");
if (linkFollower.matches(link)) {
final UserReprRenderer renderer = new UserReprRenderer(getRendererContext(), linkFollower, JsonRepresentation.newMap());
renderer.with(authenticationSession);
-
link.mapPut("value", renderer.render());
}
@@ -128,13 +122,10 @@ public class HomePageReprRenderer extends ReprRendererAbstract<HomePageReprRende
final JsonRepresentation link = LinkBuilder.newBuilder(getRendererContext(), Rel.DOMAIN_TYPES.getName(), RepresentationType.TYPE_LIST, "domainTypes").build();
- final LinkFollower linkFollower = getLinkFollower().follow("links[rel=" + Rel.DOMAIN_TYPES.getName() + "]");
+ final LinkFollowSpecs linkFollower = getLinkFollowSpecs().follow("links");
if (linkFollower.matches(link)) {
-
final TypeListReprRenderer renderer = new TypeListReprRenderer(getRendererContext(), linkFollower, JsonRepresentation.newMap());
-
- renderer.withSelf("domainTypes").with(specifications);
-
+ renderer.withLink(Rel.SELF, "domainTypes").with(specifications);
link.mapPut("value", renderer.render());
}
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/UserReprRenderer.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/UserReprRenderer.java b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/UserReprRenderer.java
index 5e22d28..ea3cf1e 100644
--- a/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/UserReprRenderer.java
+++ b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/UserReprRenderer.java
@@ -18,14 +18,15 @@ package org.apache.isis.viewer.restfulobjects.server.resources;
import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.rendering.LinkFollower;
+import org.apache.isis.viewer.restfulobjects.rendering.LinkFollowSpecs;
import org.apache.isis.viewer.restfulobjects.rendering.RendererContext;
import org.apache.isis.viewer.restfulobjects.rendering.ReprRendererAbstract;
public class UserReprRenderer extends ReprRendererAbstract<UserReprRenderer, AuthenticationSession> {
- UserReprRenderer(final RendererContext resourceContext, final LinkFollower linkFollower, final JsonRepresentation representation) {
+ UserReprRenderer(final RendererContext resourceContext, final LinkFollowSpecs linkFollower, final JsonRepresentation representation) {
super(resourceContext, linkFollower, RepresentationType.USER, representation);
}
@@ -43,7 +44,8 @@ public class UserReprRenderer extends ReprRendererAbstract<UserReprRenderer, Aut
@Override
public JsonRepresentation render() {
if (includesSelf) {
- withSelf("user");
+ withLink(Rel.SELF, "user");
+ withLink(Rel.UP, "");
}
getExtensions();
return representation;
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/VersionReprRenderer.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/VersionReprRenderer.java b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/VersionReprRenderer.java
index 34d118a..2849e9b 100644
--- a/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/VersionReprRenderer.java
+++ b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/VersionReprRenderer.java
@@ -21,8 +21,9 @@ package org.apache.isis.viewer.restfulobjects.server.resources;
import java.nio.charset.Charset;
import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.rendering.LinkFollower;
+import org.apache.isis.viewer.restfulobjects.rendering.LinkFollowSpecs;
import org.apache.isis.viewer.restfulobjects.rendering.RendererContext;
import org.apache.isis.viewer.restfulobjects.rendering.ReprRendererAbstract;
import org.apache.isis.viewer.restfulobjects.server.RestfulObjectsApplication;
@@ -33,7 +34,7 @@ public class VersionReprRenderer extends ReprRendererAbstract<VersionReprRendere
private static final String META_INF_POM_PROPERTIES = "/META-INF/maven/org.apache.isis.viewer/restfulobjects-viewer/pom.properties";
- VersionReprRenderer(final RendererContext resourceContext, final LinkFollower linkFollower, final JsonRepresentation representation) {
+ VersionReprRenderer(final RendererContext resourceContext, final LinkFollowSpecs linkFollower, final JsonRepresentation representation) {
super(resourceContext, linkFollower, RepresentationType.VERSION, representation);
}
@@ -46,7 +47,7 @@ public class VersionReprRenderer extends ReprRendererAbstract<VersionReprRendere
public JsonRepresentation render() {
if (includesSelf) {
- withSelf("version/");
+ withLink(Rel.SELF, "version/");
}
representation.mapPut("specVersion", RestfulObjectsApplication.SPEC_VERSION);
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/server/src/test/java/org/apache/isis/viewer/restfulobjects/server/ResourceContextTest_ensureCompatibleAcceptHeader.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/server/src/test/java/org/apache/isis/viewer/restfulobjects/server/ResourceContextTest_ensureCompatibleAcceptHeader.java b/component/viewer/restfulobjects/server/src/test/java/org/apache/isis/viewer/restfulobjects/server/ResourceContextTest_ensureCompatibleAcceptHeader.java
index f5a28b2..ba8e248 100644
--- a/component/viewer/restfulobjects/server/src/test/java/org/apache/isis/viewer/restfulobjects/server/ResourceContextTest_ensureCompatibleAcceptHeader.java
+++ b/component/viewer/restfulobjects/server/src/test/java/org/apache/isis/viewer/restfulobjects/server/ResourceContextTest_ensureCompatibleAcceptHeader.java
@@ -92,7 +92,7 @@ public class ResourceContextTest_ensureCompatibleAcceptHeader {
instantiateResourceContext(representationType);
}
- @Test(expected = ReprRendererException.class)
+ @Test(expected = RestfulObjectsApplicationException.class)
public void nonMatchingProfile() throws Exception {
final RepresentationType representationType = RepresentationType.HOME_PAGE;
givenHttpHeadersGetAcceptableMediaTypesReturns(Arrays.<MediaType> asList(RepresentationType.USER.getMediaType()));
@@ -100,7 +100,7 @@ public class ResourceContextTest_ensureCompatibleAcceptHeader {
instantiateResourceContext(representationType);
}
- @Test(expected = ReprRendererException.class)
+ @Test(expected = RestfulObjectsApplicationException.class)
public void nonMatchingProfile_ignoreGeneric() throws Exception {
final RepresentationType representationType = RepresentationType.HOME_PAGE;
givenHttpHeadersGetAcceptableMediaTypesReturns(Arrays.<MediaType> asList(RepresentationType.USER.getMediaType(), MediaType.APPLICATION_JSON_TYPE));
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/server/src/test/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainResourceHelperTest_readBodyAsMap.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/server/src/test/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainResourceHelperTest_readBodyAsMap.java b/component/viewer/restfulobjects/server/src/test/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainResourceHelperTest_readBodyAsMap.java
index 49d798d..9d1985c 100644
--- a/component/viewer/restfulobjects/server/src/test/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainResourceHelperTest_readBodyAsMap.java
+++ b/component/viewer/restfulobjects/server/src/test/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainResourceHelperTest_readBodyAsMap.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertThat;
import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
import org.apache.isis.viewer.restfulobjects.rendering.ReprRendererException;
+import org.apache.isis.viewer.restfulobjects.server.RestfulObjectsApplicationException;
import org.junit.Test;
public class DomainResourceHelperTest_readBodyAsMap {
@@ -69,7 +70,7 @@ public class DomainResourceHelperTest_readBodyAsMap {
assertThat(representation.size(), is(1));
}
- @Test(expected = ReprRendererException.class)
+ @Test(expected = RestfulObjectsApplicationException.class)
public void whenArray() throws Exception {
DomainResourceHelper.readAsMap("[]");
}
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_get_accept.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_get_accept.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_get_accept.java
index ba2ec96..9879079 100644
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_get_accept.java
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_get_accept.java
@@ -51,9 +51,9 @@ public class HomePageResourceTest_get_accept {
}
@Test
- public void applicationJson_profileHomePage_returns200() throws Exception {
+ public void applicationJson_noProfile_returns200() throws Exception {
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "/").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.HOME_PAGE.getMediaType());
+ final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "/").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
@@ -61,9 +61,9 @@ public class HomePageResourceTest_get_accept {
}
@Test
- public void applicationJson_noProfile_returns200() throws Exception {
+ public void applicationJson_profileHomePage_returns200() throws Exception {
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "/").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
+ final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "/").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.HOME_PAGE.getMediaType());
final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_representation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_representation.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_representation.java
new file mode 100644
index 0000000..acb0c6d
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_representation.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.resources.home;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasMaxAge;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasParameter;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasSubType;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasType;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isFollowableLinkToSelf;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.CacheControl;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status.Family;
+
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.Header;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageResource;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class HomePageResourceTest_templated_representation {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private HomePageResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ resource = client.getHomePageResource();
+ }
+
+ @Test
+ public void representation() throws Exception {
+
+ // given
+ final Response resp = resource.homePage();
+
+ // when
+ final RestfulResponse<HomePageRepresentation> restfulResponse = RestfulResponse.ofT(resp);
+ assertThat(restfulResponse.getStatus().getFamily(), is(Family.SUCCESSFUL));
+
+ // then
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+
+ final HomePageRepresentation repr = restfulResponse.getEntity();
+ assertThat(repr, is(not(nullValue())));
+ assertThat(repr, isMap());
+
+ assertThat(repr.getSelf(), isLink(client)
+ .rel(Rel.SELF)
+ .href(endsWith(":39393/"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.HOME_PAGE.getMediaType())
+ .returning(HttpStatusCode.OK)
+ );
+ assertThat(repr.getUser(), isLink(client)
+ .rel(Rel.USER)
+ .href(endsWith(":39393/user"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.USER.getMediaType())
+ .returning(HttpStatusCode.OK)
+ );
+ assertThat(repr.getServices(), isLink(client)
+ .rel(Rel.SERVICES)
+ .href(endsWith(":39393/services"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.LIST.getMediaType())
+ .returning(HttpStatusCode.OK)
+ );
+ assertThat(repr.getVersion(), isLink(client)
+ .rel(Rel.VERSION)
+ .href(endsWith(":39393/version"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.VERSION.getMediaType())
+ .returning(HttpStatusCode.OK)
+ );
+
+ assertThat(repr.getLinks(), isArray());
+ assertThat(repr.getExtensions(), isMap());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_representationAndHeaders.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_representationAndHeaders.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_representationAndHeaders.java
deleted file mode 100644
index c9c0879..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_representationAndHeaders.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.restfulobjects.tck.resources.home;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasMaxAge;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasParameter;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasSubType;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasType;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isFollowableLinkToSelf;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status.Family;
-
-import org.apache.isis.viewer.restfulobjects.applib.Rel;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulMediaType;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.Header;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageResource;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class HomePageResourceTest_templated_representationAndHeaders {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private HomePageResource resource;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
- resource = client.getHomePageResource();
- }
-
- @Test
- public void representation() throws Exception {
-
- // given
- final Response resp = resource.homePage();
-
- // when
- final RestfulResponse<HomePageRepresentation> restfulResponse = RestfulResponse.ofT(resp);
- assertThat(restfulResponse.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- // then
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
-
- final HomePageRepresentation repr = restfulResponse.getEntity();
- assertThat(repr, is(not(nullValue())));
- assertThat(repr, isMap());
-
- assertThat(repr.getSelf(), isLink(client)
- .rel(Rel.SELF)
- .href(endsWith(":39393/"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.HOME_PAGE.getMediaType())
- .returning(HttpStatusCode.OK)
- );
- assertThat(repr.getUser(), isLink(client)
- .rel(Rel.USER)
- .href(endsWith(":39393/user"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.USER.getMediaType())
- .returning(HttpStatusCode.OK)
- );
- assertThat(repr.getServices(), isLink(client)
- .rel(Rel.SERVICES)
- .href(endsWith(":39393/services"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.LIST.getMediaType())
- .returning(HttpStatusCode.OK)
- );
- assertThat(repr.getVersion(), isLink(client)
- .rel(Rel.VERSION)
- .href(endsWith(":39393/version"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.VERSION.getMediaType())
- .returning(HttpStatusCode.OK)
- );
-
- assertThat(repr.getLinks(), isArray());
- assertThat(repr.getExtensions(), isMap());
- }
-
- @Test
- public void self_isFollowable() throws Exception {
- // given
- final HomePageRepresentation repr = givenRepresentation();
-
- // when, then
- assertThat(repr, isFollowableLinkToSelf(client));
- }
-
- @Test
- public void headers() throws Exception {
- // given
- final Response resp = resource.homePage();
-
- // when
- final RestfulResponse<HomePageRepresentation> restfulResponse = RestfulResponse.ofT(resp);
-
- // then
- final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
- assertThat(contentType, hasType("application"));
- assertThat(contentType, hasSubType("json"));
- assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/homepage"));
- assertThat(contentType, is(RepresentationType.HOME_PAGE.getMediaType()));
-
- // then
- final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
- assertThat(cacheControl, hasMaxAge(24 * 60 * 60));
- assertThat(cacheControl.getMaxAge(), is(24 * 60 * 60));
- }
-
- private HomePageRepresentation givenRepresentation() throws JsonParseException, JsonMappingException, IOException {
- final RestfulResponse<HomePageRepresentation> response = RestfulResponse.ofT(resource.homePage());
- return response.getEntity();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_responseHeaders.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_responseHeaders.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_responseHeaders.java
new file mode 100644
index 0000000..201683e
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_responseHeaders.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.resources.home;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasMaxAge;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasParameter;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasSubType;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasType;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isFollowableLinkToSelf;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.CacheControl;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status.Family;
+
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.Header;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageResource;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class HomePageResourceTest_templated_responseHeaders {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private HomePageResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ resource = client.getHomePageResource();
+ }
+
+
+ @Test
+ public void headers() throws Exception {
+ // given
+ final Response resp = resource.homePage();
+
+ // when
+ final RestfulResponse<HomePageRepresentation> restfulResponse = RestfulResponse.ofT(resp);
+
+ // then
+ final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
+ assertThat(contentType, hasType("application"));
+ assertThat(contentType, hasSubType("json"));
+ assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/homepage"));
+ assertThat(contentType, is(RepresentationType.HOME_PAGE.getMediaType()));
+
+ // then
+ final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
+ assertThat(cacheControl, hasMaxAge(24 * 60 * 60));
+ assertThat(cacheControl.getMaxAge(), is(24 * 60 * 60));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java
index 49ec876..f86249e 100644
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java
@@ -126,7 +126,7 @@ public class HomePageResourceTest_xrofollowlinks {
assertThat(service.getRepresentation("value"), is(not(nullValue())));
}
- @Test // currently failing
+ @Test
public void servicesValuesWithCriteria() throws Exception {
repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SERVICES.getName() + "].value[rel=" + Rel.SERVICE.andParam("serviceId", "WrapperValuedEntities")+"]");
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_accept.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_accept.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_accept.java
deleted file mode 100644
index a083598..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_accept.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.restfulobjects.tck.resources.user;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import javax.ws.rs.core.MediaType;
-
-import org.apache.isis.core.webserver.WebServer;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class UserResourceTest_accept {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
-
- @Before
- public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
- }
-
- @Test
- public void applicationJson() throws Exception {
-
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_profileUser() throws Exception {
-
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_invalid() throws Exception {
-
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.HOME_PAGE.getMediaType());
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_get_accept.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_get_accept.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_get_accept.java
new file mode 100644
index 0000000..7b3677d
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_get_accept.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.resources.user;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class UserResourceTest_get_accept {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ }
+
+ @Test
+ public void applicationJson_noProfile_returns200() throws Exception {
+
+ final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
+ final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ assertThat(restfulResponse.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.USER.getMediaType()));
+ }
+
+ @Test
+ public void applicationJson_profileUser_returns200() throws Exception {
+
+ final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
+ final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ }
+
+ @Test
+ public void missingHeader_returns200() throws Exception {
+ // given
+ final RestfulRequest restfulReq = client.createRequest(RestfulHttpMethod.GET, "user");
+
+ // when
+ final RestfulResponse<UserRepresentation> restfulResp = restfulReq.executeT();
+
+ // then
+ assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
+ }
+
+ @Test
+ public void applicationJson_profileIncorrect_returns406() throws Exception {
+
+ final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.VERSION.getMediaType());
+ final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
+ }
+
+ @Test
+ public void incorrectMediaType_returnsNotAcceptable() throws Exception {
+
+ // given
+ final ClientRequest clientRequest = client.getClientRequestFactory().createRelativeRequest("user");
+ clientRequest.accept(MediaType.APPLICATION_ATOM_XML_TYPE);
+
+ // when
+ final ClientResponse<?> resp = clientRequest.get();
+ final RestfulResponse<JsonRepresentation> restfulResp = RestfulResponse.of(resp);
+
+ // then
+ assertThat(restfulResp.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_representationAndHeaders.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_representationAndHeaders.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_representationAndHeaders.java
deleted file mode 100644
index d65d421..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_representationAndHeaders.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.viewer.restfulobjects.tck.resources.user;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasMaxAge;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasParameter;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasSubType;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasType;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isFollowableLinkToSelf;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status.Family;
-
-import org.apache.isis.core.webserver.WebServer;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.Header;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.user.UserResource;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class UserResourceTest_representationAndHeaders {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private UserResource resource;
-
- @Before
- public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
-
- resource = client.getUserResource();
- }
-
- @Test
- public void representation() throws Exception {
-
- // given
- final Response resp = resource.user();
-
- // when
- final RestfulResponse<UserRepresentation> jsonResp = RestfulResponse.ofT(resp);
- assertThat(jsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- // then
- assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
-
- final UserRepresentation repr = jsonResp.getEntity();
- assertThat(repr, is(not(nullValue())));
- assertThat(repr.isMap(), is(true));
-
- assertThat(repr.getSelf(), isLink(client).httpMethod(RestfulHttpMethod.GET));
- assertThat(repr.getUserName(), is(not(nullValue())));
- assertThat(repr.getFriendlyName(), is(nullValue())); // TODO: change
- // fixture so
- // populated
- assertThat(repr.getEmail(), is(nullValue())); // TODO: change fixture so
- // populated
- assertThat(repr.getRoles(), is(not(nullValue()))); // TODO: change
- // fixture so have
- // non-empty list
-
- assertThat(repr.getLinks(), isArray());
- assertThat(repr.getExtensions(), isMap());
- }
-
- @Test
- public void headers() throws Exception {
-
- // given
- final Response resp = resource.user();
-
- // when
- final RestfulResponse<UserRepresentation> restfulResponse = RestfulResponse.ofT(resp);
-
- // then
- final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
- assertThat(contentType, hasType("application"));
- assertThat(contentType, hasSubType("json"));
- assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/user"));
- assertThat(contentType, is(RepresentationType.USER.getMediaType()));
-
- // then
- final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
- assertThat(cacheControl, hasMaxAge(60 * 60));
- assertThat(cacheControl.getMaxAge(), is(60 * 60));
- }
-
- @Test
- public void self_isFollowable() throws Exception {
- // given
- final UserRepresentation repr = givenRepresentation();
-
- // when, then
- assertThat(repr, isFollowableLinkToSelf(client));
- }
-
- private UserRepresentation givenRepresentation() throws JsonParseException, JsonMappingException, IOException {
- final RestfulResponse<UserRepresentation> jsonResp = RestfulResponse.ofT(resource.user());
- return jsonResp.getEntity();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_representation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_representation.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_representation.java
new file mode 100644
index 0000000..de494de
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_representation.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.resources.user;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasMaxAge;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasParameter;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasSubType;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasType;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isFollowableLinkToSelf;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.CacheControl;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status.Family;
+
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.Header;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.user.UserResource;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class UserResourceTest_templated_representation {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private UserResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ resource = client.getUserResource();
+ }
+
+ @Test
+ public void representation() throws Exception {
+
+ // given
+ final Response resp = resource.user();
+
+ // when
+ final RestfulResponse<UserRepresentation> jsonResp = RestfulResponse.ofT(resp);
+ assertThat(jsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
+
+ // then
+ assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
+
+ final UserRepresentation repr = jsonResp.getEntity();
+ assertThat(repr, is(not(nullValue())));
+ assertThat(repr.isMap(), is(true));
+
+ assertThat(repr.getSelf(), isLink(client)
+ .rel(Rel.SELF)
+ .href(endsWith(":39393/user"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.USER.getMediaType())
+ .returning(HttpStatusCode.OK)
+ );
+ assertThat(repr.getUp(), isLink(client)
+ .rel(Rel.UP)
+ .href(endsWith(":39393/"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.HOME_PAGE.getMediaType())
+ .returning(HttpStatusCode.OK)
+ );
+ assertThat(repr.getUserName(), is(not(nullValue())));
+
+ // TODO: change fixture so populated
+ assertThat(repr.getFriendlyName(), is(nullValue()));
+ assertThat(repr.getEmail(), is(nullValue()));
+ assertThat(repr.getRoles(), is(not(nullValue())));
+
+ assertThat(repr.getLinks(), isArray());
+ assertThat(repr.getExtensions(), isMap());
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/isis/blob/a644bd5b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_responseHeaders.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_responseHeaders.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_responseHeaders.java
new file mode 100644
index 0000000..ea6e6ec
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/user/UserResourceTest_templated_responseHeaders.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.resources.user;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasMaxAge;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasParameter;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasSubType;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasType;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isFollowableLinkToSelf;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
+import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.CacheControl;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status.Family;
+
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.Header;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.user.UserResource;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class UserResourceTest_templated_responseHeaders {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private UserResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ resource = client.getUserResource();
+ }
+
+
+ @Test
+ public void headers() throws Exception {
+
+ // given
+ final Response resp = resource.user();
+
+ // when
+ final RestfulResponse<UserRepresentation> restfulResponse = RestfulResponse.ofT(resp);
+
+ // then
+ final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
+ assertThat(contentType, hasType("application"));
+ assertThat(contentType, hasSubType("json"));
+ assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/user"));
+ assertThat(contentType, is(RepresentationType.USER.getMediaType()));
+
+ // then
+ final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
+ assertThat(cacheControl, hasMaxAge(60 * 60));
+ assertThat(cacheControl.getMaxAge(), is(60 * 60));
+ }
+}