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/04/11 16:37:25 UTC
[6/9] ISIS-233: adding new test stubs (TODOs)
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenValidationRuleForSingleArg_whenArgFails_bad.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenValidationRuleForSingleArg_whenArgFails_bad.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenValidationRuleForSingleArg_whenArgFails_bad.java
new file mode 100644
index 0000000..a7d9f49
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenValidationRuleForSingleArg_whenArgFails_bad.java
@@ -0,0 +1,134 @@
+/*
+ * 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.domainobjectorservice.id.action.invoke;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasProfile;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasStatus;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+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.domainobjects.ActionResultRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ActionResultRepresentation.ResultType;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.util.UrlEncodingUtils;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers;
+import org.apache.isis.viewer.restfulobjects.tck.Util;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.hamcrest.Matchers;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class Get_givenValidationRuleForSingleArg_whenArgFails_bad {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ private DomainServiceResource serviceResource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+
+ serviceResource = client.getDomainServiceResource();
+ }
+
+ @Test
+ public void usingClientFollow() throws Exception {
+
+ // given
+ final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "subList");
+ final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
+
+ final LinkRepresentation invokeLink = actionRepr.getInvoke();
+
+ assertThat(invokeLink, isLink(client)
+ .rel(Rel.INVOKE)
+ .httpMethod(RestfulHttpMethod.GET)
+ .href(Matchers.endsWith(":39393/services/ActionsEntities/actions/subList/invoke"))
+ .build());
+
+ JsonRepresentation args =invokeLink.getArguments();
+ assertThat(args.size(), is(2));
+ assertThat(args, RestfulMatchers.mapHas("from"));
+ assertThat(args, RestfulMatchers.mapHas("to"));
+
+ // when
+ args.mapPut("from.value", -1);
+ args.mapPut("to.value", 2);
+
+ final RestfulResponse<ActionResultRepresentation> restfulResponse = client.followT(invokeLink, args);
+
+ // then
+ thenResponseIsAValidationError(restfulResponse);
+ }
+
+
+ @Test
+ public void usingResourceProxy() throws Exception {
+
+ // given, when
+ JsonRepresentation args = JsonRepresentation.newMap();
+ args.mapPut("from.value", -1);
+ args.mapPut("to.value", 2);
+ Response response = serviceResource.invokeActionQueryOnly("ActionsEntities", "subList", UrlEncodingUtils.urlEncode(args));
+ RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
+
+ // then
+ thenResponseIsAValidationError(restfulResponse);
+ }
+
+ private static void thenResponseIsAValidationError(final RestfulResponse<ActionResultRepresentation> restfulResponse) throws JsonParseException, JsonMappingException, IOException {
+ assertThat(restfulResponse, hasStatus(HttpStatusCode.VALIDATION_FAILED));
+
+ assertThat(restfulResponse.getHeader(Header.WARNING), containsString("Validation failed, see body for details"));
+
+ // hmmm... what is the media type, though? the spec doesn't say. testing for a generic one.
+ assertThat(restfulResponse.getHeader(Header.CONTENT_TYPE), hasProfile(MediaType.APPLICATION_JSON));
+
+ RestfulResponse<JsonRepresentation> restfulResponseOfError = restfulResponse.wraps(JsonRepresentation.class);
+ JsonRepresentation repr = restfulResponseOfError.getEntity();
+
+ assertThat(repr.getString("from.invalidReason"), is("Cannot be less than zero"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_thenResponseCode_200_ok_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_thenResponseCode_200_ok_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_thenResponseCode_200_ok_TODO.java
new file mode 100644
index 0000000..b42bef2
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_thenResponseCode_200_ok_TODO.java
@@ -0,0 +1,14 @@
+package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action.invoke;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class Get_thenResponseCode_200_ok_TODO {
+
+ @Ignore
+ @Test
+ public void todo() throws Exception {
+ // should return 201 (13.2)
+ // if a newly created object
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_thenResponseHeaders_CacheControl_ok_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_thenResponseHeaders_CacheControl_ok_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_thenResponseHeaders_CacheControl_ok_TODO.java
new file mode 100644
index 0000000..38b3aa3
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_thenResponseHeaders_CacheControl_ok_TODO.java
@@ -0,0 +1,61 @@
+/*
+ * 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.domainobjectorservice.id.action.invoke;
+
+import org.apache.isis.core.webserver.WebServer;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class Get_thenResponseHeaders_CacheControl_ok_TODO {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Ignore
+ @Test
+ public void noCaching() throws Exception {
+
+ }
+
+ @Ignore
+ @Test
+ public void shortTermCaching() throws Exception {
+
+ }
+
+ @Ignore
+ @Test
+ public void longTermCaching() throws Exception {
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenCreatedNewObject_thenResponseCode_201_ok_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenCreatedNewObject_thenResponseCode_201_ok_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenCreatedNewObject_thenResponseCode_201_ok_TODO.java
new file mode 100644
index 0000000..9245a59
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenCreatedNewObject_thenResponseCode_201_ok_TODO.java
@@ -0,0 +1,14 @@
+package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action.invoke;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class Get_whenCreatedNewObject_thenResponseCode_201_ok_TODO {
+
+ @Ignore
+ @Test
+ public void todo() throws Exception {
+ // should return 201 (13.2)
+ // if a newly created object
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenErrorThrown_thenRepresentation_ok_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenErrorThrown_thenRepresentation_ok_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenErrorThrown_thenRepresentation_ok_TODO.java
new file mode 100644
index 0000000..baedd69
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenErrorThrown_thenRepresentation_ok_TODO.java
@@ -0,0 +1,13 @@
+package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action.invoke;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class Get_whenErrorThrown_thenRepresentation_ok_TODO {
+
+ @Ignore
+ @Test
+ public void todo() throws Exception {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenList_thenRepresentation_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenList_thenRepresentation_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenList_thenRepresentation_ok.java
new file mode 100644
index 0000000..0a7a054
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenList_thenRepresentation_ok.java
@@ -0,0 +1,112 @@
+/*
+ * 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.domainobjectorservice.id.action.invoke;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasProfile;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+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.domainobjects.ActionResultRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ActionResultRepresentation.ResultType;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.apache.isis.viewer.restfulobjects.tck.Util;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.hamcrest.Matchers;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class Get_whenList_thenRepresentation_ok {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ private DomainServiceResource serviceResource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+
+ serviceResource = client.getDomainServiceResource();
+ }
+
+ @Test
+ public void usingClientFollow() throws Exception {
+
+ // given
+ final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "list");
+ final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
+
+ final LinkRepresentation invokeLink = actionRepr.getInvoke();
+
+ assertThat(invokeLink, isLink(client)
+ .rel(Rel.INVOKE)
+ .httpMethod(RestfulHttpMethod.GET)
+ .href(Matchers.endsWith(":39393/services/ActionsEntities/actions/list/invoke"))
+ .arguments(JsonRepresentation.newMap())
+ .build());
+
+ // when
+ final RestfulResponse<ActionResultRepresentation> restfulResponse = client.followT(invokeLink);
+
+ // then
+ then(restfulResponse);
+ }
+
+ private static void then(final RestfulResponse<ActionResultRepresentation> restfulResponse) throws JsonParseException, JsonMappingException, IOException {
+
+ assertThat(restfulResponse.getHeader(Header.CONTENT_TYPE), hasProfile(RestfulMediaType.APPLICATION_JSON_ACTION_RESULT));
+ final ActionResultRepresentation actionResultRepr = restfulResponse.getEntity();
+
+ assertThat(actionResultRepr.getResultType(), is(ResultType.LIST));
+ final ListRepresentation listRepr = actionResultRepr.getResult().as(ListRepresentation.class);
+ assertThat(listRepr.getValue().size(), is(5));
+ }
+
+
+ @Test
+ public void usingResourceProxy() throws Exception {
+
+ // given, when
+ Response response = serviceResource.invokeActionQueryOnly("ActionsEntities", "list", null);
+ RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
+
+ then(restfulResponse);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenObject_thenRepresentation_ok_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenObject_thenRepresentation_ok_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenObject_thenRepresentation_ok_TODO.java
new file mode 100644
index 0000000..c86172c
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenObject_thenRepresentation_ok_TODO.java
@@ -0,0 +1,13 @@
+package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action.invoke;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class Get_whenObject_thenRepresentation_ok_TODO {
+
+ @Ignore
+ @Test
+ public void todo() throws Exception {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenScalar_thenRepresentation_ok_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenScalar_thenRepresentation_ok_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenScalar_thenRepresentation_ok_TODO.java
new file mode 100644
index 0000000..b5703a1
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenScalar_thenRepresentation_ok_TODO.java
@@ -0,0 +1,13 @@
+package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action.invoke;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class Get_whenScalar_thenRepresentation_ok_TODO {
+
+ @Ignore
+ @Test
+ public void todo() throws Exception {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenVoid_thenRepresentation_ok_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenVoid_thenRepresentation_ok_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenVoid_thenRepresentation_ok_TODO.java
new file mode 100644
index 0000000..7207f1f
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenVoid_thenRepresentation_ok_TODO.java
@@ -0,0 +1,13 @@
+package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action.invoke;
+
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class Get_whenVoid_thenRepresentation_ok_TODO {
+
+ @Ignore
+ @Test
+ public void todo() throws Exception {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Post_givenActionSemanticsOfIdempotent_thenResponseCode_205_bad_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Post_givenActionSemanticsOfIdempotent_thenResponseCode_205_bad_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Post_givenActionSemanticsOfIdempotent_thenResponseCode_205_bad_TODO.java
new file mode 100644
index 0000000..94d5a09
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Post_givenActionSemanticsOfIdempotent_thenResponseCode_205_bad_TODO.java
@@ -0,0 +1,112 @@
+/*
+ * 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.domainobjectorservice.id.action.invoke;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasProfile;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasStatus;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.hamcrest.Matchers;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+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.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.domainobjects.ActionResultRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.util.UrlEncodingUtils;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.apache.isis.viewer.restfulobjects.tck.Util;
+
+public class Post_givenActionSemanticsOfIdempotent_thenResponseCode_205_bad_TODO {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ private DomainServiceResource serviceResource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+
+ serviceResource = client.getDomainServiceResource();
+ }
+
+ @Ignore("to write - copied from req_safe")
+ @Test
+ public void usingClientFollow() throws Exception {
+
+ // given, when
+ final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "subListWithOptionalRange");
+ final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
+
+ final LinkRepresentation invokeLink = actionRepr.getInvoke();
+
+ assertThat(invokeLink, isLink(client)
+ .rel(Rel.INVOKE)
+ .httpMethod(RestfulHttpMethod.GET)
+ .href(Matchers.endsWith(":39393/services/ActionsEntities/actions/subListWithOptionalRange/invoke"))
+ .build());
+
+ invokeLink.withMethod(RestfulHttpMethod.POST);
+
+ // when
+ JsonRepresentation args = JsonRepresentation.newMap();
+ args = JsonRepresentation.newMap();
+ args.mapPut("id.value", 123);
+
+ final RestfulResponse<ActionResultRepresentation> restfulResponse = client.followT(invokeLink, args);
+
+ // then
+ thenResponseIsErrorWithInvalidReason(restfulResponse);
+ }
+
+
+ // not possible to test using resourceProxy
+
+
+ private static void thenResponseIsErrorWithInvalidReason(final RestfulResponse<ActionResultRepresentation> restfulResponse) throws JsonParseException, JsonMappingException, IOException {
+ assertThat(restfulResponse, hasStatus(HttpStatusCode.METHOD_NOT_ALLOWED));
+ assertThat(restfulResponse.getHeader(Header.WARNING), is("object is immutable")); // not a good message, but as per spec
+
+ // hmmm... what is the media type, though? the spec doesn't say. testing for a generic one.
+ assertThat(restfulResponse.getHeader(Header.CONTENT_TYPE), hasProfile(MediaType.APPLICATION_JSON));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Post_givenActionSemanticsOfSafe_thenResponseCode_205_bad_TOFIX.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Post_givenActionSemanticsOfSafe_thenResponseCode_205_bad_TOFIX.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Post_givenActionSemanticsOfSafe_thenResponseCode_205_bad_TOFIX.java
new file mode 100644
index 0000000..36e5491
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Post_givenActionSemanticsOfSafe_thenResponseCode_205_bad_TOFIX.java
@@ -0,0 +1,112 @@
+/*
+ * 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.domainobjectorservice.id.action.invoke;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasProfile;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasStatus;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.hamcrest.Matchers;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+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.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.domainobjects.ActionResultRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.util.UrlEncodingUtils;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.apache.isis.viewer.restfulobjects.tck.Util;
+
+public class Post_givenActionSemanticsOfSafe_thenResponseCode_205_bad_TOFIX {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ private DomainServiceResource serviceResource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+
+ serviceResource = client.getDomainServiceResource();
+ }
+
+ @Ignore("currently failing")
+ @Test
+ public void usingClientFollow() throws Exception {
+
+ // given, when
+ final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "subListWithOptionalRange");
+ final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
+
+ final LinkRepresentation invokeLink = actionRepr.getInvoke();
+
+ assertThat(invokeLink, isLink(client)
+ .rel(Rel.INVOKE)
+ .httpMethod(RestfulHttpMethod.GET)
+ .href(Matchers.endsWith(":39393/services/ActionsEntities/actions/subListWithOptionalRange/invoke"))
+ .build());
+
+ invokeLink.withMethod(RestfulHttpMethod.POST);
+
+ // when
+ JsonRepresentation args = JsonRepresentation.newMap();
+ args = JsonRepresentation.newMap();
+ args.mapPut("id.value", 123);
+
+ final RestfulResponse<ActionResultRepresentation> restfulResponse = client.followT(invokeLink, args);
+
+ // then
+ thenResponseIsErrorWithInvalidReason(restfulResponse);
+ }
+
+
+ // not possible to test using resourceProxy
+
+
+ private static void thenResponseIsErrorWithInvalidReason(final RestfulResponse<ActionResultRepresentation> restfulResponse) throws JsonParseException, JsonMappingException, IOException {
+ assertThat(restfulResponse, hasStatus(HttpStatusCode.METHOD_NOT_ALLOWED));
+ assertThat(restfulResponse.getHeader(Header.WARNING), is("object is immutable")); // not a good message, but as per spec
+
+ // hmmm... what is the media type, though? the spec doesn't say. testing for a generic one.
+ assertThat(restfulResponse.getHeader(Header.CONTENT_TYPE), hasProfile(MediaType.APPLICATION_JSON));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Put_givenActionSemanticsOfNotIdempotent_thenResponseCode_205_bad_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Put_givenActionSemanticsOfNotIdempotent_thenResponseCode_205_bad_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Put_givenActionSemanticsOfNotIdempotent_thenResponseCode_205_bad_TODO.java
new file mode 100644
index 0000000..fd57a21
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Put_givenActionSemanticsOfNotIdempotent_thenResponseCode_205_bad_TODO.java
@@ -0,0 +1,112 @@
+/*
+ * 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.domainobjectorservice.id.action.invoke;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasProfile;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasStatus;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.hamcrest.Matchers;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+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.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.domainobjects.ActionResultRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.util.UrlEncodingUtils;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.apache.isis.viewer.restfulobjects.tck.Util;
+
+public class Put_givenActionSemanticsOfNotIdempotent_thenResponseCode_205_bad_TODO {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ private DomainServiceResource serviceResource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+
+ serviceResource = client.getDomainServiceResource();
+ }
+
+ @Ignore("to write - copied from req_safe")
+ @Test
+ public void usingClientFollow() throws Exception {
+
+ // given, when
+ final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "subListWithOptionalRange");
+ final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
+
+ final LinkRepresentation invokeLink = actionRepr.getInvoke();
+
+ assertThat(invokeLink, isLink(client)
+ .rel(Rel.INVOKE)
+ .httpMethod(RestfulHttpMethod.GET)
+ .href(Matchers.endsWith(":39393/services/ActionsEntities/actions/subListWithOptionalRange/invoke"))
+ .build());
+
+ invokeLink.withMethod(RestfulHttpMethod.POST);
+
+ // when
+ JsonRepresentation args = JsonRepresentation.newMap();
+ args = JsonRepresentation.newMap();
+ args.mapPut("id.value", 123);
+
+ final RestfulResponse<ActionResultRepresentation> restfulResponse = client.followT(invokeLink, args);
+
+ // then
+ thenResponseIsErrorWithInvalidReason(restfulResponse);
+ }
+
+
+ // not possible to test using resourceProxy
+
+
+ private static void thenResponseIsErrorWithInvalidReason(final RestfulResponse<ActionResultRepresentation> restfulResponse) throws JsonParseException, JsonMappingException, IOException {
+ assertThat(restfulResponse, hasStatus(HttpStatusCode.METHOD_NOT_ALLOWED));
+ assertThat(restfulResponse.getHeader(Header.WARNING), is("object is immutable")); // not a good message, but as per spec
+
+ // hmmm... what is the media type, though? the spec doesn't say. testing for a generic one.
+ assertThat(restfulResponse.getHeader(Header.CONTENT_TYPE), hasProfile(MediaType.APPLICATION_JSON));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Put_givenActionSemanticsOfSafe_thenResponseCode_205_bad_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Put_givenActionSemanticsOfSafe_thenResponseCode_205_bad_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Put_givenActionSemanticsOfSafe_thenResponseCode_205_bad_TODO.java
new file mode 100644
index 0000000..8d33e6b
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Put_givenActionSemanticsOfSafe_thenResponseCode_205_bad_TODO.java
@@ -0,0 +1,112 @@
+/*
+ * 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.domainobjectorservice.id.action.invoke;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasProfile;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasStatus;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.hamcrest.Matchers;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+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.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.domainobjects.ActionResultRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.util.UrlEncodingUtils;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.apache.isis.viewer.restfulobjects.tck.Util;
+
+public class Put_givenActionSemanticsOfSafe_thenResponseCode_205_bad_TODO {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ private DomainServiceResource serviceResource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+
+ serviceResource = client.getDomainServiceResource();
+ }
+
+ @Ignore("to write - copied from req_safe")
+ @Test
+ public void usingClientFollow() throws Exception {
+
+ // given, when
+ final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "subListWithOptionalRange");
+ final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
+
+ final LinkRepresentation invokeLink = actionRepr.getInvoke();
+
+ assertThat(invokeLink, isLink(client)
+ .rel(Rel.INVOKE)
+ .httpMethod(RestfulHttpMethod.GET)
+ .href(Matchers.endsWith(":39393/services/ActionsEntities/actions/subListWithOptionalRange/invoke"))
+ .build());
+
+ invokeLink.withMethod(RestfulHttpMethod.POST);
+
+ // when
+ JsonRepresentation args = JsonRepresentation.newMap();
+ args = JsonRepresentation.newMap();
+ args.mapPut("id.value", 123);
+
+ final RestfulResponse<ActionResultRepresentation> restfulResponse = client.followT(invokeLink, args);
+
+ // then
+ thenResponseIsErrorWithInvalidReason(restfulResponse);
+ }
+
+
+ // not possible to test using resourceProxy
+
+
+ private static void thenResponseIsErrorWithInvalidReason(final RestfulResponse<ActionResultRepresentation> restfulResponse) throws JsonParseException, JsonMappingException, IOException {
+ assertThat(restfulResponse, hasStatus(HttpStatusCode.METHOD_NOT_ALLOWED));
+ assertThat(restfulResponse.getHeader(Header.WARNING), is("object is immutable")); // not a good message, but as per spec
+
+ // hmmm... what is the media type, though? the spec doesn't say. testing for a generic one.
+ assertThat(restfulResponse.getHeader(Header.CONTENT_TYPE), hasProfile(MediaType.APPLICATION_JSON));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_req_header_accept.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_req_header_accept.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_req_header_accept.java
deleted file mode 100644
index 93b694e..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_req_header_accept.java
+++ /dev/null
@@ -1,105 +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.domainservice.root;
-
-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.domainobjects.ListRepresentation;
-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 DomainServiceTest_req_header_accept {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private RestfulRequest request;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
- request = client.createRequest(RestfulHttpMethod.GET, "services");
- }
-
- @Test
- public void applicationJson_noProfile_returns200() throws Exception {
-
- request.withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
- final RestfulResponse<ListRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- assertThat(restfulResponse.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.LIST.getMediaType()));
- }
-
- @Test
- public void applicationJson_profileList_returns200() throws Exception {
-
- request.withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.LIST.getMediaType());
- final RestfulResponse<ListRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void missingHeader_returns200() throws Exception {
-
- final RestfulResponse<ListRepresentation> restfulResp = request.executeT();
-
- assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_profileIncorrect_returns406() throws Exception {
-
- request.withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.VERSION.getMediaType());
- final RestfulResponse<ListRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
- }
-
- @Test
- public void incorrectMediaType_returnsNotAcceptable() throws Exception {
-
- // given
- final ClientRequest clientRequest = client.getClientRequestFactory().createRelativeRequest("services");
- 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/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_req_queryarg_xrofollowlinks.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_req_queryarg_xrofollowlinks.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_req_queryarg_xrofollowlinks.java
deleted file mode 100644
index 8568b23..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_req_queryarg_xrofollowlinks.java
+++ /dev/null
@@ -1,152 +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.domainservice.root;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isMap;
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.junit.Assert.assertThat;
-
-import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
-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.RestfulRequest;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest.RequestParameter;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.hamcrest.Matchers;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class DomainServiceTest_req_queryarg_xrofollowlinks {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
-
- private RestfulRequest request;
- private RestfulResponse<ListRepresentation> restfulResponse;
- private ListRepresentation repr;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
-
- }
-
- @Test
- public void noFollow() throws Exception {
-
- request = client.createRequest(RestfulHttpMethod.GET, "services");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- assertThat(repr.getSelf().getValue(), is(nullValue()));
- assertThat(repr.getUp().getValue(), is(nullValue()));
- }
-
- @Test
- public void self() throws Exception {
-
- request = client.createRequest(RestfulHttpMethod.GET, "services")
- .withArg(RequestParameter.FOLLOW_LINKS, "links[rel=" + Rel.SELF.getName() + "]");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- assertThat(repr.getSelf().getValue(), is(not(nullValue())));
- }
-
- @Test
- public void up() throws Exception {
-
- request = client.createRequest(RestfulHttpMethod.GET, "services")
- .withArg(RequestParameter.FOLLOW_LINKS, "links[rel=" + Rel.UP.getName() + "]");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- assertThat(repr.getUp().getValue(), is(not(nullValue())));
- }
-
- @Test
- public void value_noQualifications_andSoAllOfThemEagerlyReturned() throws Exception {
-
- request = client.createRequest(RestfulHttpMethod.GET, "services")
- .withArg(RequestParameter.FOLLOW_LINKS, "value[rel=" + Rel.SERVICE.getName() + "]");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- request = client.createRequest(RestfulHttpMethod.GET, "services")
- .withArg(RequestParameter.FOLLOW_LINKS, "value");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- // then
- for (final LinkRepresentation link : repr.getValue().arrayIterable(LinkRepresentation.class)) {
-
- assertThat(link, isLink(client)
- .rel(containsString(Rel.SERVICE.getName()))
- .href(containsString(":39393/"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.DOMAIN_OBJECT.getMediaType())
- .value(is(not(nullValue(JsonRepresentation.class))))
- );
- }
-
- }
-
- @Test
- public void value_withQualification_andSoSingleServiceEagerlyReturned() throws Exception {
-
- request = client.createRequest(RestfulHttpMethod.GET, "services")
- .withArg(RequestParameter.FOLLOW_LINKS, "value[rel=" + Rel.SERVICE.getName() + ";serviceId=\"JdkValuedEntities\"]");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- // then
- int numWithValue = 0;
- int numWithoutValue = 0;
- for (final LinkRepresentation link : repr.getValue().arrayIterable(LinkRepresentation.class)) {
-
- if(isLink(client).value(is(not(nullValue(JsonRepresentation.class)))).build().matches(link)) {
- numWithValue++;
- } else {
- numWithoutValue++;
- }
- }
-
- assertThat(numWithValue, is(1));
- assertThat(numWithoutValue, is(greaterThan(0)));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_resp_headers.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_resp_headers.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_resp_headers.java
deleted file mode 100644
index 4ea2892..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_resp_headers.java
+++ /dev/null
@@ -1,82 +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.domainservice.root;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasMaxAge;
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasParameter;
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasSubType;
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasType;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-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.domainobjects.DomainServiceResource;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
-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 DomainServiceTest_resp_headers {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private DomainServiceResource resource;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
- resource = client.getDomainServiceResource();
- }
-
-
- @Test
- public void contentType_and_cacheControl() throws Exception {
- // given
- final Response resp = resource.services();
-
- // when
- final RestfulResponse<ListRepresentation> 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/list"));
- assertThat(contentType, is(RepresentationType.LIST.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/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_resp_representation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_resp_representation.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_resp_representation.java
deleted file mode 100644
index 9fec3c4..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/DomainServiceTest_resp_representation.java
+++ /dev/null
@@ -1,128 +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.domainservice.root;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isMap;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.endsWith;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import javax.ws.rs.core.Response;
-
-import org.apache.isis.core.webserver.WebServer;
-import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
-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.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class DomainServiceTest_resp_representation {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private DomainServiceResource resource;
-
- @Before
- public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
-
- resource = client.getDomainServiceResource();
- }
-
- @Test
- public void representation() throws Exception {
-
- // when
- final Response response = resource.services();
- final RestfulResponse<ListRepresentation> restfulResponse = RestfulResponse.ofT(response);
-
- // then
- final ListRepresentation repr = restfulResponse.getEntity();
-
- assertThat(repr, isMap());
-
- assertThat(repr.getSelf(), isLink(client)
- .rel(Rel.SELF)
- .href(endsWith(":39393/services"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.LIST.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.getValue(), isArray());
-
- assertThat(repr.getLinks(), isArray());
- assertThat(repr.getExtensions(), isMap());
- }
-
- @Test
- public void linksToDomainServiceResources() throws Exception {
-
- // given
- final RestfulResponse<ListRepresentation> jsonResp = RestfulResponse.ofT(resource.services());
- final ListRepresentation repr = jsonResp.getEntity();
-
- // when
- final JsonRepresentation values = repr.getValue();
-
- // then
- for (final LinkRepresentation link : values.arrayIterable(LinkRepresentation.class)) {
- assertThat("HiddenRepository should not show up in services list", false, is(link.getHref().endsWith("HiddenRepository")));
- }
-
- // and also
- for (final LinkRepresentation link : values.arrayIterable(LinkRepresentation.class)) {
-
- assertThat(link, isLink(client)
- .rel(containsString(Rel.SERVICE.getName()))
- .href(containsString(":39393/"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.DOMAIN_OBJECT.getMediaType())
- );
- assertThat(link, isLink(client)
- .returning(HttpStatusCode.OK)
- .responseEntityWithSelfHref(link.getHref())
- );
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_thenRepresentation_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_thenRepresentation_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_thenRepresentation_ok.java
new file mode 100644
index 0000000..02cefba
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_thenRepresentation_ok.java
@@ -0,0 +1,128 @@
+/*
+ * 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.domainservice.root;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.assertThat;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isArray;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isMap;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.Response;
+
+import org.apache.isis.core.webserver.WebServer;
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+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.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class Get_thenRepresentation_ok {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private DomainServiceResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+
+ resource = client.getDomainServiceResource();
+ }
+
+ @Test
+ public void representation() throws Exception {
+
+ // when
+ final Response response = resource.services();
+ final RestfulResponse<ListRepresentation> restfulResponse = RestfulResponse.ofT(response);
+
+ // then
+ final ListRepresentation repr = restfulResponse.getEntity();
+
+ assertThat(repr, isMap());
+
+ assertThat(repr.getSelf(), isLink(client)
+ .rel(Rel.SELF)
+ .href(endsWith(":39393/services"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.LIST.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.getValue(), isArray());
+
+ assertThat(repr.getLinks(), isArray());
+ assertThat(repr.getExtensions(), isMap());
+ }
+
+ @Test
+ public void linksToDomainServiceResources() throws Exception {
+
+ // given
+ final RestfulResponse<ListRepresentation> jsonResp = RestfulResponse.ofT(resource.services());
+ final ListRepresentation repr = jsonResp.getEntity();
+
+ // when
+ final JsonRepresentation values = repr.getValue();
+
+ // then
+ for (final LinkRepresentation link : values.arrayIterable(LinkRepresentation.class)) {
+ assertThat("HiddenRepository should not show up in services list", false, is(link.getHref().endsWith("HiddenRepository")));
+ }
+
+ // and also
+ for (final LinkRepresentation link : values.arrayIterable(LinkRepresentation.class)) {
+
+ assertThat(link, isLink(client)
+ .rel(containsString(Rel.SERVICE.getName()))
+ .href(containsString(":39393/"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.DOMAIN_OBJECT.getMediaType())
+ );
+ assertThat(link, isLink(client)
+ .returning(HttpStatusCode.OK)
+ .responseEntityWithSelfHref(link.getHref())
+ );
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_thenResponseHeaders_CacheControl_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_thenResponseHeaders_CacheControl_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_thenResponseHeaders_CacheControl_ok.java
new file mode 100644
index 0000000..041f2b4
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_thenResponseHeaders_CacheControl_ok.java
@@ -0,0 +1,68 @@
+/*
+ * 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.domainservice.root;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasMaxAge;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.CacheControl;
+import javax.ws.rs.core.Response;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+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.domainobjects.DomainServiceResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+public class Get_thenResponseHeaders_CacheControl_ok {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private DomainServiceResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ resource = client.getDomainServiceResource();
+ }
+
+
+ @Test
+ public void ok() throws Exception {
+ // given
+ final Response resp = resource.services();
+
+ // when
+ final RestfulResponse<ListRepresentation> restfulResponse = RestfulResponse.ofT(resp);
+
+ // 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/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_thenResponseHeaders_ContentType_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_thenResponseHeaders_ContentType_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_thenResponseHeaders_ContentType_ok.java
new file mode 100644
index 0000000..c89c3a2
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_thenResponseHeaders_ContentType_ok.java
@@ -0,0 +1,73 @@
+/*
+ * 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.domainservice.root;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasParameter;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasSubType;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasType;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+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.domainobjects.DomainServiceResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+public class Get_thenResponseHeaders_ContentType_ok {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private DomainServiceResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ resource = client.getDomainServiceResource();
+ }
+
+
+ @Test
+ public void contentType_and_cacheControl() throws Exception {
+ // given
+ final Response resp = resource.services();
+
+ // when
+ final RestfulResponse<ListRepresentation> 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/list"));
+ assertThat(contentType, is(RepresentationType.LIST.getMediaType()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/ca8a43ee/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_whenCallWithWrongHttpMethod_bad_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_whenCallWithWrongHttpMethod_bad_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_whenCallWithWrongHttpMethod_bad_TODO.java
new file mode 100644
index 0000000..27972c8
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/root/Get_whenCallWithWrongHttpMethod_bad_TODO.java
@@ -0,0 +1,5 @@
+package org.apache.isis.viewer.restfulobjects.tck.domainservice.root;
+
+public class Get_whenCallWithWrongHttpMethod_bad_TODO {
+
+}