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/02/26 00:28:30 UTC
[10/24] ISIS-233: working toward RO spec 1.0.0
http://git-wip-us.apache.org/repos/asf/isis/blob/b5041f0b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/AnyResourceTest_serverSideException_exceptionHandling.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/AnyResourceTest_serverSideException_exceptionHandling.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/AnyResourceTest_serverSideException_exceptionHandling.java
deleted file mode 100644
index 8aa79ff..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/AnyResourceTest_serverSideException_exceptionHandling.java
+++ /dev/null
@@ -1,72 +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;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jboss.resteasy.client.ClientRequest;
-import org.jboss.resteasy.client.ClientResponse;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.webserver.WebServer;
-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.RestfulRequest.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.util.Parser;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-
-public class AnyResourceTest_serverSideException_exceptionHandling {
-
- @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 runtimeException_isMapped() throws Exception {
-
- // given
- final RestfulRequest restfulReq = client.createRequest(RestfulHttpMethod.GET, "version");
- final Header<Boolean> header = new Header<Boolean>("X-FAIL", Parser.forBoolean());
- restfulReq.withHeader(header, true);
-
- // when
- final RestfulResponse<JsonRepresentation> jsonResp = restfulReq.execute();
-
- // then
- assertThat(jsonResp.getStatus(), is(HttpStatusCode.METHOD_FAILURE));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/b5041f0b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/errorhandling/AnyResourceTest_serverSideException_exceptionHandling.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/errorhandling/AnyResourceTest_serverSideException_exceptionHandling.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/errorhandling/AnyResourceTest_serverSideException_exceptionHandling.java
new file mode 100644
index 0000000..2ffc14a
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/errorhandling/AnyResourceTest_serverSideException_exceptionHandling.java
@@ -0,0 +1,72 @@
+/*
+ * 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.errorhandling;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.client.ClientResponse;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.webserver.WebServer;
+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.RestfulRequest.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.util.Parser;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+public class AnyResourceTest_serverSideException_exceptionHandling {
+
+ @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 runtimeException_isMapped() throws Exception {
+
+ // given
+ final RestfulRequest restfulReq = client.createRequest(RestfulHttpMethod.GET, "version");
+ final Header<Boolean> header = new Header<Boolean>("X-FAIL", Parser.forBoolean());
+ restfulReq.withHeader(header, true);
+
+ // when
+ final RestfulResponse<JsonRepresentation> jsonResp = restfulReq.execute();
+
+ // then
+ assertThat(jsonResp.getStatus(), is(HttpStatusCode.METHOD_FAILURE));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/b5041f0b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_accept.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_accept.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_accept.java
deleted file mode 100644
index 7af3617..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_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.home;
-
-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 HomePageResourceTest_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, "/").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_profileHomePage() throws Exception {
-
- 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));
- }
-
- @Test
- public void applicationJson_invalid() throws Exception {
-
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "/").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/b5041f0b/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
new file mode 100644
index 0000000..ba2ec96
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_get_accept.java
@@ -0,0 +1,107 @@
+/*
+ * 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.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.homepage.HomePageRepresentation;
+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 HomePageResourceTest_get_accept {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ }
+
+ @Test
+ public void applicationJson_profileHomePage_returns200() throws Exception {
+
+ 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));
+ assertThat(restfulResponse.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.HOME_PAGE.getMediaType()));
+ }
+
+ @Test
+ public void applicationJson_noProfile_returns200() throws Exception {
+
+ 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));
+ }
+
+ @Test
+ public void missingHeader_returns200() throws Exception {
+ // given
+ final RestfulRequest restfulReq = client.createRequest(RestfulHttpMethod.GET, "/");
+
+ // when
+ final RestfulResponse<HomePageRepresentation> 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, "/").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
+ final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
+ }
+
+ @Test
+ public void incorrectMediaType_returnsNotAcceptable() throws Exception {
+
+ // given
+ final ClientRequest clientRequest = client.getClientRequestFactory().createRelativeRequest("/");
+ 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/b5041f0b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_representationAndHeaders.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_representationAndHeaders.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_representationAndHeaders.java
deleted file mode 100644
index 40639ad..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_representationAndHeaders.java
+++ /dev/null
@@ -1,146 +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.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.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_representationAndHeaders {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private HomePageResource resource;
-
- @Before
- public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
-
- 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).httpMethod(RestfulHttpMethod.GET));
- assertThat(repr.getUser(), isLink(client).httpMethod(RestfulHttpMethod.GET));
- assertThat(repr.getServices(), isLink(client).httpMethod(RestfulHttpMethod.GET));
- assertThat(repr.getVersion(), isLink(client).httpMethod(RestfulHttpMethod.GET));
-
- assertThat(repr.getLinks(), isArray());
- assertThat(repr.getExtensions(), isMap());
- }
-
- @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));
- }
-
- @Test
- public void self_isFollowable() throws Exception {
- // given
- final HomePageRepresentation repr = givenRepresentation();
-
- // when, then
- assertThat(repr, isFollowableLinkToSelf(client));
- }
-
- @Test
- public void links() throws Exception {
- // given
- final HomePageRepresentation repr = givenRepresentation();
-
- // when, then
- assertThat(repr.getServices(), isLink(client).returning(HttpStatusCode.OK));
- assertThat(repr.getUser(), isLink(client).returning(HttpStatusCode.OK));
- assertThat(repr.getVersion(), isLink(client).returning(HttpStatusCode.OK));
- }
-
- 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/b5041f0b/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
new file mode 100644
index 0000000..c9c0879
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_templated_representationAndHeaders.java
@@ -0,0 +1,159 @@
+/*
+ * 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/b5041f0b/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 f29646b..49ec876 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
@@ -27,22 +27,20 @@ import static org.junit.Assert.assertThat;
import java.io.IOException;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.webserver.WebServer;
import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
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.RestfulRequest.RequestParameter;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
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_xrofollowlinks {
@@ -57,8 +55,7 @@ public class HomePageResourceTest_xrofollowlinks {
@Before
public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
+ client = webServerRule.getClient();
request = client.createRequest(RestfulHttpMethod.GET, "");
restfulResponse = request.executeT();
@@ -73,7 +70,7 @@ public class HomePageResourceTest_xrofollowlinks {
@Test
public void canFollowUser() throws Exception {
- repr = whenExecuteAndFollowLinksUsing("/", "links[rel=user]");
+ repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.USER.getName() + "]");
assertThat(repr.getUser().getValue(), is(not(nullValue())));
}
@@ -81,7 +78,7 @@ public class HomePageResourceTest_xrofollowlinks {
@Test
public void canFollowServices() throws Exception {
- repr = whenExecuteAndFollowLinksUsing("/", "links[rel=services]");
+ repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SERVICES.getName() + "]");
assertThat(repr.getServices().getValue(), is(not(nullValue())));
}
@@ -89,65 +86,64 @@ public class HomePageResourceTest_xrofollowlinks {
@Test
public void canFollowVersion() throws Exception {
- repr = whenExecuteAndFollowLinksUsing("/", "links[rel=version]");
+ repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.VERSION.getName() + "]");
assertThat(repr.getVersion().getValue(), is(not(nullValue())));
}
- @Ignore("broken... (did this ever work, not sure)")
@Test
public void canFollowAll() throws Exception {
- repr = whenExecuteAndFollowLinksUsing("/", "links[rel=user],links[rel=services],links[rel=version]");
+ repr = whenExecuteAndFollowLinksUsing("/",
+ "links[rel=" + Rel.USER.getName() + "]," +
+ "links[rel=" + Rel.SERVICES.getName() + "]," +
+ "links[rel=" + Rel.VERSION.getName() + "]");
+ assertThat(repr.getServices().getValue(), is(not(nullValue())));
assertThat(repr.getUser().getValue(), is(not(nullValue())));
assertThat(repr.getVersion().getValue(), is(not(nullValue())));
- assertThat(repr.getServices().getValue(), is(not(nullValue())));
}
@Test
public void servicesValues() throws Exception {
- repr = whenExecuteAndFollowLinksUsing("/", "links[rel=services].values");
+ repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SERVICES.getName() + "].value");
final JsonRepresentation servicesValue = repr.getServices().getValue();
assertThat(servicesValue, is(not(nullValue())));
assertThat(servicesValue, isMap());
- final JsonRepresentation serviceLinkList = servicesValue.getArray("values");
+ final JsonRepresentation serviceLinkList = servicesValue.getArray("value");
assertThat(serviceLinkList, isArray());
JsonRepresentation service;
- service = serviceLinkList.getRepresentation("[id=%s]", "simples");
+ service = serviceLinkList.getRepresentation("[rel=%s;serviceId=\"%s\"]", Rel.SERVICE.getName(), "JdkValuedEntities");
assertThat(service, isMap());
- assertThat(service.getString("id"), is("simples"));
assertThat(service.getRepresentation("value"), is(not(nullValue())));
- service = serviceLinkList.getRepresentation("[id=%s]", "applibValuedEntities");
+ service = serviceLinkList.getRepresentation("[rel=%s;serviceId=\"%s\"]", Rel.SERVICE.getName(), "WrapperValuedEntities");
assertThat(service, isMap());
- assertThat(service.getString("id"), is("applibValuedEntities"));
assertThat(service.getRepresentation("value"), is(not(nullValue())));
}
- @Test
+ @Test // currently failing
public void servicesValuesWithCriteria() throws Exception {
- repr = whenExecuteAndFollowLinksUsing("/", "links[rel=services].values[id=simples]");
+ repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SERVICES.getName() + "].value[rel=" + Rel.SERVICE.andParam("serviceId", "WrapperValuedEntities")+"]");
final JsonRepresentation servicesValue = repr.getServices().getValue();
assertThat(servicesValue, is(not(nullValue())));
assertThat(servicesValue, isMap());
- final JsonRepresentation serviceLinkList = servicesValue.getArray("values");
+ final JsonRepresentation serviceLinkList = servicesValue.getArray("value");
assertThat(serviceLinkList, isArray());
JsonRepresentation service;
- service = serviceLinkList.getRepresentation("[id=%s]", "simples");
+ service = serviceLinkList.getRepresentation("[rel=%s;serviceId=\"%s\"]", Rel.SERVICE.getName(), "WrapperValuedEntities");
assertThat(service, isMap());
- assertThat(service.getString("id"), is("simples"));
assertThat(service.getRepresentation("value"), is(not(nullValue())));
- service = serviceLinkList.getRepresentation("[id=%s]", "applibValuedEntities");
+ service = serviceLinkList.getRepresentation("[rel=%s;serviceId=\"%s\"]", Rel.SERVICE.getName(), "JdkValuedEntities");
assertThat(service.getRepresentation("value"), is(nullValue()));
}
http://git-wip-us.apache.org/repos/asf/isis/blob/b5041f0b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/object/DomainObjectResourceTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/object/DomainObjectResourceTest.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/object/DomainObjectResourceTest.java
index 6fcf9f0..23df8f8 100644
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/object/DomainObjectResourceTest.java
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/object/DomainObjectResourceTest.java
@@ -80,7 +80,7 @@ public class DomainObjectResourceTest {
final DomainObjectResource domainObjectResource = client.getDomainObjectResource();
// when
- final Response domainObjectResp = domainObjectResource.object("OID:6");
+ final Response domainObjectResp = domainObjectResource.object("OID","6");
final RestfulResponse<DomainObjectRepresentation> domainObjectJsonResp = RestfulResponse.ofT(domainObjectResp);
assertThat(domainObjectJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
@@ -93,11 +93,11 @@ public class DomainObjectResourceTest {
public void domainObjectRepresentationForPersistentObject_hasSelfAndOid() throws Exception {
// given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID:32");
+ final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
// then
final LinkRepresentation self = domainObjectRepr.getSelf();
- assertThat(self, isLink().rel(Rel.SELF).href(matches(".+objects/OID:32")).httpMethod(RestfulHttpMethod.GET).type(MediaType.APPLICATION_JSON_TYPE).typeParameter("profile", "urn:org.restfulobjects/domainobject"));
+ assertThat(self, isLink().rel(Rel.SELF).href(matches(".+objects/OID/32")).httpMethod(RestfulHttpMethod.GET).type(MediaType.APPLICATION_JSON_TYPE).typeParameter("profile", "urn:org.restfulobjects/domainobject"));
assertThat(domainObjectRepr.getLinkWithRel(Rel.DESCRIBEDBY), isLink().href(matches(".+" + BidirWithSetChildEntity.class.getName())).httpMethod(RestfulHttpMethod.GET).type(MediaType.APPLICATION_JSON_TYPE).typeParameter("profile", "urn:org.restfulobjects/domaintype"));
assertThat(domainObjectRepr.getTitle(), is("parent 4 - child 2"));
@@ -131,7 +131,7 @@ public class DomainObjectResourceTest {
public void domainObjectRepresentation_hasTitle() throws Exception {
// given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID:32");
+ final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
// then
assertThat(domainObjectRepr.getTitle(), is("parent 4 - child 2"));
@@ -141,7 +141,7 @@ public class DomainObjectResourceTest {
public void domainObjectRepresentation_hasDescribedByLink() throws Exception {
// given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID:32");
+ final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
// then
assertThat(domainObjectRepr.getLinkWithRel(Rel.DESCRIBEDBY), isLink().href(matches(".+" + BidirWithSetChildEntity.class.getName())).httpMethod(RestfulHttpMethod.GET).type(MediaType.APPLICATION_JSON_TYPE).typeParameter("profile", "urn:org.restfulobjects/domaintype"));
@@ -151,7 +151,7 @@ public class DomainObjectResourceTest {
public void domainObjectRepresentation_noIcon() throws Exception {
// given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID:32");
+ final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
// then
final LinkRepresentation selfIcon = domainObjectRepr.getLinkWithRel(Rel.ICON);
@@ -163,7 +163,7 @@ public class DomainObjectResourceTest {
public void domainObjectWithIcon() throws Exception {
// given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID:xxx");
+ final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","xxx");
// icon
final LinkRepresentation selfIcon = domainObjectRepr.getLinkWithRel(Rel.ICON);
@@ -175,7 +175,7 @@ public class DomainObjectResourceTest {
public void domainObjectRepresentationContent_Properties() throws Exception {
// given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID:32");
+ final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
final LinkRepresentation self = domainObjectRepr.getSelf();
// then properties
@@ -198,7 +198,7 @@ public class DomainObjectResourceTest {
public void domainObjectRepresentationContent_Collections() throws Exception {
// given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID:32");
+ final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
// then collections
@@ -209,7 +209,7 @@ public class DomainObjectResourceTest {
public void domainObjectRepresentationContent() throws Exception {
// given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID:32");
+ final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
final LinkRepresentation self = domainObjectRepr.getSelf();
// then actions
@@ -253,7 +253,7 @@ public class DomainObjectResourceTest {
public void domainObjectWithDisabledMembers() throws Exception {
// given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID:xxx");
+ final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","xxx");
// property ('name')
final JsonRepresentation properties = domainObjectRepr.getProperties();
@@ -268,7 +268,7 @@ public class DomainObjectResourceTest {
final DomainObjectResource domainObjectResource = client.getDomainObjectResource();
// when
- final Response idPropertyResp = domainObjectResource.propertyDetails("OID:1", "id");
+ final Response idPropertyResp = domainObjectResource.propertyDetails("OID","1", "id");
final RestfulResponse<ObjectPropertyRepresentation> idPropertyJsonResp = RestfulResponse.ofT(idPropertyResp);
assertThat(idPropertyJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
@@ -305,7 +305,7 @@ public class DomainObjectResourceTest {
final DomainObjectResource domainObjectResource = client.getDomainObjectResource();
// when
- final Response actionPromptResp = domainObjectResource.actionPrompt("OID:1", "list");
+ final Response actionPromptResp = domainObjectResource.actionPrompt("OID","1", "list");
final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp);
assertThat(actionPromptJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
@@ -360,7 +360,7 @@ public class DomainObjectResourceTest {
final JsonRepresentation body = JsonRepresentation.newArray();
// when
- final Response actionInvokeResp = domainObjectResource.invokeAction("OID:1", "list", body.asInputStream());
+ final Response actionInvokeResp = domainObjectResource.invokeAction("OID","1", "list", body.asInputStream());
final RestfulResponse<ScalarValueRepresentation> actionInvokeJsonResp = RestfulResponse.ofT(actionInvokeResp);
assertThat(actionInvokeJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
@@ -387,10 +387,10 @@ public class DomainObjectResourceTest {
assertThat(domainObjectIconLink.getHref(), matches("http://localhost:\\d+/images/null.png")); // TODO
}
- private DomainObjectRepresentation givenDomainObjectRepresentationFor(final String oidStr) throws JsonParseException, JsonMappingException, IOException {
+ private DomainObjectRepresentation givenDomainObjectRepresentationFor(final String domainType, String instanceId) throws JsonParseException, JsonMappingException, IOException {
final DomainObjectResource domainObjectResource = client.getDomainObjectResource();
- final Response domainObjectResp = domainObjectResource.object(oidStr);
+ final Response domainObjectResp = domainObjectResource.object(domainType, instanceId);
final RestfulResponse<DomainObjectRepresentation> domainObjectJsonResp = RestfulResponse.ofT(domainObjectResp);
assertThat(domainObjectJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
http://git-wip-us.apache.org/repos/asf/isis/blob/b5041f0b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/OidMarshaller.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/OidMarshaller.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/OidMarshaller.java
index 56654c0..459ace9 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/OidMarshaller.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/oid/OidMarshaller.java
@@ -114,8 +114,22 @@ public class OidMarshaller {
////////////////////////////////////////////////////////////////
public OidMarshaller() {}
+
////////////////////////////////////////////////////////////////
+ // join, split
+ ////////////////////////////////////////////////////////////////
+
+ public String joinAsOid(String domainType, String instanceId) {
+ return domainType + SEPARATOR + instanceId;
+ }
+
+ public String splitInstanceId(String oidStr) {
+ final int indexOfSeperator = oidStr.indexOf(SEPARATOR);
+ return indexOfSeperator > 0? oidStr.substring(indexOfSeperator+1): null;
+ }
+
+ ////////////////////////////////////////////////////////////////
// unmarshal
////////////////////////////////////////////////////////////////
@@ -258,4 +272,8 @@ public class OidMarshaller {
}
+
+
+
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/b5041f0b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/PolyInterfaceIdentityStrategySubtype3Entity.java
----------------------------------------------------------------------
diff --git a/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/PolyInterfaceIdentityStrategySubtype3Entity.java b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/PolyInterfaceIdentityStrategySubtype3Entity.java
index 531a009..fcad3cd 100644
--- a/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/PolyInterfaceIdentityStrategySubtype3Entity.java
+++ b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/PolyInterfaceIdentityStrategySubtype3Entity.java
@@ -32,7 +32,7 @@ import org.apache.isis.applib.annotation.Title;
@javax.jdo.annotations.Discriminator("PIS3")
@javax.jdo.annotations.DatastoreIdentity(strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY)
@Inheritance(strategy=InheritanceStrategy.NEW_TABLE)
-@ObjectType("PIS3")
+@ObjectType("PIIS3")
public class PolyInterfaceIdentityStrategySubtype3Entity extends BaseEntity implements PolyInterfaceIdentityStrategy {
http://git-wip-us.apache.org/repos/asf/isis/blob/b5041f0b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/PolyInterfaceParentEntityRepository.java
----------------------------------------------------------------------
diff --git a/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/PolyInterfaceParentEntityRepository.java b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/PolyInterfaceParentEntityRepository.java
index 2a9ea8b..9005a78 100644
--- a/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/PolyInterfaceParentEntityRepository.java
+++ b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/PolyInterfaceParentEntityRepository.java
@@ -25,12 +25,12 @@ import org.apache.isis.applib.annotation.Named;
import org.apache.isis.applib.annotation.ObjectType;
import org.apache.isis.core.tck.dom.AbstractEntityRepository;
-@Named("PolyClassParentEntities")
-@ObjectType("PolyClassParentEntities")
+@Named("PolyInterfaceParentEntities")
+@ObjectType("PolyInterfaceParentEntities")
public class PolyInterfaceParentEntityRepository extends AbstractEntityRepository<PolyInterfaceParentEntity> {
public PolyInterfaceParentEntityRepository() {
- super(PolyInterfaceParentEntity.class, "PolyClassParentEntities");
+ super(PolyInterfaceParentEntity.class, "PolyInterfaceParentEntities");
}
@MemberOrder(sequence = "2")
http://git-wip-us.apache.org/repos/asf/isis/blob/b5041f0b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/UnidirFkParentEntityRepository.java
----------------------------------------------------------------------
diff --git a/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/UnidirFkParentEntityRepository.java b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/UnidirFkParentEntityRepository.java
index e8fb038..fcbcadd 100644
--- a/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/UnidirFkParentEntityRepository.java
+++ b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/UnidirFkParentEntityRepository.java
@@ -24,8 +24,8 @@ import org.apache.isis.applib.annotation.Named;
import org.apache.isis.applib.annotation.ObjectType;
import org.apache.isis.core.tck.dom.AbstractEntityRepository;
-@Named("UnidirParentEntities")
-@ObjectType("UnidirParentEntities")
+@Named("UnidirFkParentEntities")
+@ObjectType("UnidirFkParentEntities")
public class UnidirFkParentEntityRepository extends AbstractEntityRepository<UnidirFkParentEntity> {
public UnidirFkParentEntityRepository() {
http://git-wip-us.apache.org/repos/asf/isis/blob/b5041f0b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/UnidirJoinParentEntityRepository.java
----------------------------------------------------------------------
diff --git a/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/UnidirJoinParentEntityRepository.java b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/UnidirJoinParentEntityRepository.java
index dc02cf7..47fd53c 100644
--- a/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/UnidirJoinParentEntityRepository.java
+++ b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/refs/UnidirJoinParentEntityRepository.java
@@ -24,8 +24,8 @@ import org.apache.isis.applib.annotation.Named;
import org.apache.isis.applib.annotation.ObjectType;
import org.apache.isis.core.tck.dom.AbstractEntityRepository;
-@Named("UnidirParentEntities")
-@ObjectType("UnidirParentEntities")
+@Named("UnidirJoinParentEntities")
+@ObjectType("UnidirJoinParentEntities")
public class UnidirJoinParentEntityRepository extends AbstractEntityRepository<UnidirJoinParentEntity> {
public UnidirJoinParentEntityRepository() {