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/06/12 07:28:05 UTC
git commit: ISIS-421: Remaining Get_thenRepresentation_ok_TODO RO TCK
Tests
Updated Branches:
refs/heads/master af6bdba64 -> 449a03bac
ISIS-421: Remaining Get_thenRepresentation_ok_TODO RO TCK Tests
Signed-off-by: Dan Haywood <da...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/449a03ba
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/449a03ba
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/449a03ba
Branch: refs/heads/master
Commit: 449a03bacae6a19b97921de246bc36dddfc14174
Parents: af6bdba
Author: DImuthuUpe <di...@gmail.com>
Authored: Tue Jun 11 14:27:06 2013 -0700
Committer: Dan Haywood <da...@apache.org>
Committed: Wed Jun 12 06:21:34 2013 +0100
----------------------------------------------------------------------
.../collection/Get_thenRepresentation_ok.java | 128 +++++++++++++++++++
.../Get_thenRepresentation_ok_TODO.java | 23 ----
.../oid/property/Get_thenRepresentation_ok.java | 126 ++++++++++++++++++
.../Get_thenRepresentation_ok_TODO.java | 96 --------------
.../id/action/Get_thenRepresentation_ok.java | 112 ++++++++++++++++
.../action/Get_thenRepresentation_ok_TODO.java | 104 ---------------
6 files changed, 366 insertions(+), 223 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/449a03ba/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/collection/Get_thenRepresentation_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/collection/Get_thenRepresentation_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/collection/Get_thenRepresentation_ok.java
new file mode 100644
index 0000000..5f08c8f
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/collection/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.domainobject.oid.collection;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.assertThat;
+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.endsWith;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status.Family;
+
+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.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.DomainObjectResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectCollectionRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+public class Get_thenRepresentation_ok {
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+ private DomainObjectResource domainObjectResource;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ domainObjectResource = client.getDomainObjectResource();
+ }
+
+
+ @Test
+ public void representation() throws Exception {
+
+ // when
+ final Response collectionResp = domainObjectResource.accessCollection("BSRL", "64", "invisibleCollection");
+ final RestfulResponse<ObjectCollectionRepresentation> collectionJsonResp = RestfulResponse.ofT(collectionResp);
+ assertThat(collectionJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
+
+ // then
+ final ObjectCollectionRepresentation collectionRepr = collectionJsonResp.getEntity();
+
+ assertThat(collectionRepr.getString("memberType"), is("collection"));
+
+ // self link
+ final LinkRepresentation selfLink = collectionRepr.getLinkWithRel(Rel.SELF);
+ assertThat(selfLink, isLink(client)
+ .httpMethod(RestfulHttpMethod.GET)
+ .href(endsWith("/objects/BSRL/64/collections/invisibleCollection"))
+ .returning(HttpStatusCode.OK));
+
+ // up link
+ final LinkRepresentation upLink = collectionRepr.getLinkWithRel(Rel.UP);
+ assertThat(upLink, isLink(client)
+ .httpMethod(RestfulHttpMethod.GET)
+ .href(endsWith("http://localhost:39393/objects/BSRL/64"))
+ .returning(HttpStatusCode.OK)
+ .type(RepresentationType.DOMAIN_OBJECT.getMediaType())
+ .title("Untitled Bus Rules Entity"));
+
+ //addto link
+ final LinkRepresentation addtoLink = collectionRepr.getLinkWithRel(Rel.ADD_TO);
+ assertThat(addtoLink, isLink(client)
+ .httpMethod(RestfulHttpMethod.POST)
+ .type(RepresentationType.OBJECT_COLLECTION.getMediaType())
+ .href(endsWith("/objects/BSRL/64/collections/invisibleCollection")));
+
+ assertThat(addtoLink.getArguments(), is(not(nullValue())));
+ assertThat(addtoLink.getArguments().isArray(), is(false));
+ assertThat(addtoLink.getArguments().size(), is(1));
+
+ //remove-from link
+ final LinkRepresentation removeFromLink = collectionRepr.getLinkWithRel(Rel.REMOVE_FROM);
+ assertThat(removeFromLink, isLink(client)
+ .httpMethod(RestfulHttpMethod.DELETE)
+ .type(RepresentationType.OBJECT_COLLECTION.getMediaType())
+ .href(endsWith("/objects/BSRL/64/collections/invisibleCollection")));
+
+ assertThat(removeFromLink.getArguments(), is(not(nullValue())));
+ assertThat(removeFromLink.getArguments().isArray(), is(false));
+ assertThat(removeFromLink.getArguments().size(), is(1));
+
+ // described by link
+ final LinkRepresentation describedByLink = collectionRepr.getLinkWithRel(Rel.DESCRIBEDBY);
+ assertThat(describedByLink, isLink(client)
+ .returning(HttpStatusCode.OK)
+ .responseEntityWithSelfHref(describedByLink.getHref()));
+
+ assertThat(collectionRepr.getArray("value").isArray(),is(true));
+
+ assertThat(collectionRepr.getExtensions(), isMap());
+ assertThat(collectionRepr.getExtensions().getString("collectionSemantics"), is("list"));
+ assertThat(collectionRepr.getExtensions().getArray("changed").isArray(), is(true));
+ assertThat(collectionRepr.getExtensions().getArray("disposed").isArray(), is(true));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/449a03ba/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/collection/Get_thenRepresentation_ok_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/collection/Get_thenRepresentation_ok_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/collection/Get_thenRepresentation_ok_TODO.java
deleted file mode 100644
index c7223b8..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/collection/Get_thenRepresentation_ok_TODO.java
+++ /dev/null
@@ -1,23 +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.domainobject.oid.collection;
-
-public class Get_thenRepresentation_ok_TODO {
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/449a03ba/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Get_thenRepresentation_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Get_thenRepresentation_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Get_thenRepresentation_ok.java
new file mode 100644
index 0000000..028695e
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Get_thenRepresentation_ok.java
@@ -0,0 +1,126 @@
+/*
+ * 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.domainobject.oid.property;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.assertThat;
+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.endsWith;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status.Family;
+
+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.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.DomainObjectResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectPropertyRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+public class Get_thenRepresentation_ok {
+
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+ private DomainObjectResource domainObjectResource;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ domainObjectResource = client.getDomainObjectResource();
+ }
+
+
+ @Test
+ public void representation() throws Exception {
+
+ // when
+ final Response idPropertyResp = domainObjectResource.propertyDetails("org.apache.isis.core.tck.dom.defaults.WithDefaultsEntity","58", "anInt");
+ final RestfulResponse<ObjectPropertyRepresentation> idPropertyJsonResp = RestfulResponse.ofT(idPropertyResp);
+ assertThat(idPropertyJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
+
+ // then
+ final ObjectPropertyRepresentation propertyRepr = idPropertyJsonResp.getEntity();
+
+ assertThat(propertyRepr.getString("memberType"), is("property"));
+
+ // self link
+ final LinkRepresentation selfLink = propertyRepr.getLinkWithRel(Rel.SELF);
+ assertThat(selfLink, isLink(client)
+ .httpMethod(RestfulHttpMethod.GET)
+ .href(endsWith("/objects/org.apache.isis.core.tck.dom.defaults.WithDefaultsEntity/58/properties/anInt"))
+ .returning(HttpStatusCode.OK));
+
+ // up link
+ final LinkRepresentation upLink = propertyRepr.getLinkWithRel(Rel.UP);
+ assertThat(upLink, isLink(client)
+ .httpMethod(RestfulHttpMethod.GET)
+ .href(endsWith("/objects/org.apache.isis.core.tck.dom.defaults.WithDefaultsEntity/58"))
+ .returning(HttpStatusCode.OK)
+ .type(RepresentationType.DOMAIN_OBJECT.getMediaType())
+ .title("default-name"));
+
+ //modify link
+ final LinkRepresentation modifyLink = propertyRepr.getLinkWithRel(Rel.MODIFY);
+ assertThat(modifyLink, isLink(client)
+ .httpMethod(RestfulHttpMethod.PUT)
+ .type(RepresentationType.OBJECT_PROPERTY.getMediaType())
+ .href(endsWith("/objects/org.apache.isis.core.tck.dom.defaults.WithDefaultsEntity/58/properties/anInt")));
+
+ assertThat(modifyLink.getArguments(), is(not(nullValue())));
+ assertThat(modifyLink.getArguments().isArray(), is(false));
+ assertThat(modifyLink.getArguments().size(), is(1));
+
+ //clear link
+ final LinkRepresentation clearLink = propertyRepr.getLinkWithRel(Rel.CLEAR);
+ assertThat(clearLink, isLink(client)
+ .httpMethod(RestfulHttpMethod.DELETE)
+ .type(RepresentationType.OBJECT_PROPERTY.getMediaType())
+ .href(endsWith("/objects/org.apache.isis.core.tck.dom.defaults.WithDefaultsEntity/58/properties/anInt")));
+
+ // described by link
+ final LinkRepresentation describedByLink = propertyRepr.getLinkWithRel(Rel.DESCRIBEDBY);
+ assertThat(describedByLink, isLink(client)
+ .returning(HttpStatusCode.OK)
+ .responseEntityWithSelfHref(describedByLink.getHref()));
+
+ assertThat(propertyRepr.getInt("value"), is(42));
+ assertThat(propertyRepr.getString("format"),is("int"));
+ assertThat(propertyRepr.getString("x-isis-format"), is("int"));
+ assertThat(propertyRepr.getExtensions(), isMap());
+ assertThat(propertyRepr.getExtensions().getArray("changed").isArray(), is(true));
+ assertThat(propertyRepr.getExtensions().getArray("disposed").isArray(), is(true));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/449a03ba/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Get_thenRepresentation_ok_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Get_thenRepresentation_ok_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Get_thenRepresentation_ok_TODO.java
deleted file mode 100644
index a824653..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/property/Get_thenRepresentation_ok_TODO.java
+++ /dev/null
@@ -1,96 +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.domainobject.oid.property;
-
-import static org.apache.isis.core.commons.matchers.IsisMatchers.matches;
-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 javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status.Family;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.tck.dom.scalars.ApplibValuedEntityRepository;
-import org.apache.isis.core.webserver.WebServer;
-import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
-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.domainobjects.DomainObjectResource;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectPropertyRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-
-public class Get_thenRepresentation_ok_TODO {
-
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- protected RestfulClient client;
- private DomainObjectResource domainObjectResource;
-
- @Before
- public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
- domainObjectResource = client.getDomainObjectResource();
- }
-
-
- @Ignore("to get working again")
- @Test
- public void propertyDetails() throws Exception {
-
- // when
- final Response idPropertyResp = domainObjectResource.propertyDetails("OID","1", "id");
- final RestfulResponse<ObjectPropertyRepresentation> idPropertyJsonResp = RestfulResponse.ofT(idPropertyResp);
- assertThat(idPropertyJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- // then
- final ObjectPropertyRepresentation propertyDetailsRepr = idPropertyJsonResp.getEntity();
-
- // _self.link
- final LinkRepresentation selfLink = propertyDetailsRepr.getLink("_self.link");
- assertThat(selfLink.getRel(), is("member"));
- assertThat(selfLink.getHref(), matches(".+objects/OID:1/properties/id"));
- assertThat(selfLink.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- // _self.object
- final LinkRepresentation selfObject = propertyDetailsRepr.getLink("_self.object");
- assertThat(selfObject.getRel(), is("object"));
- assertThat(selfObject.getHref(), matches(".+objects/OID:1"));
- assertThat(selfObject.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- // type
- final LinkRepresentation type = propertyDetailsRepr.getLink("type");
- assertThat(type.getRel(), is("type"));
- assertThat(type.getHref(), matches(".+vnd\\.string\\+json"));
- assertThat(type.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- assertThat(propertyDetailsRepr.getString("memberType"), is("property"));
- assertThat(propertyDetailsRepr.getString("value"), is(ApplibValuedEntityRepository.class.getName()));
- assertThat(propertyDetailsRepr.getString("disabledReason"), is(not(nullValue())));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/449a03ba/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Get_thenRepresentation_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Get_thenRepresentation_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Get_thenRepresentation_ok.java
new file mode 100644
index 0000000..e0e74c4
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Get_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;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.assertThat;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
+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 javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status.Family;
+
+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.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.DomainObjectResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+public class Get_thenRepresentation_ok {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+ private DomainObjectResource domainObjectResource;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ domainObjectResource = client.getDomainObjectResource();
+ }
+
+ @Test
+ public void representation() throws Exception {
+
+ // when
+ final Response actionPromptResp = domainObjectResource.actionPrompt("RTNE", "67", "contains");
+ final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp);
+ assertThat(actionPromptJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
+
+ // then
+ final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity();
+
+ assertThat(actionPromptRepr.getString("memberType"), is("action"));
+
+ // self link
+ final LinkRepresentation selfLink = actionPromptRepr.getLinkWithRel(Rel.SELF);
+ assertThat(selfLink, isLink(client)
+ .httpMethod(RestfulHttpMethod.GET)
+ .href(endsWith("/objects/RTNE/67/actions/contains"))
+ .returning(HttpStatusCode.OK));
+
+ // up link
+ final LinkRepresentation upLink = actionPromptRepr.getLinkWithRel(Rel.UP);
+ assertThat(upLink, isLink(client)
+ .httpMethod(RestfulHttpMethod.GET)
+ .href(endsWith("/objects/RTNE/67"))
+ .returning(HttpStatusCode.OK)
+ .type(RepresentationType.DOMAIN_OBJECT.getMediaType())
+ .title("Untitled Actions Entity"));
+
+ //invoke link
+ final LinkRepresentation invokeLink = actionPromptRepr.getLinkWithRel(Rel.INVOKE);
+ assertThat(invokeLink, isLink(client)
+ .httpMethod(RestfulHttpMethod.GET)
+ .href(endsWith("/services/ActionsEntities/actions/contains/invoke")));
+
+ assertThat(invokeLink.getArguments(), is(not(nullValue())));
+ assertThat(invokeLink.getArguments().isArray(), is(false));
+ assertThat(invokeLink.getArguments().size(), is(3));
+
+ // described by link
+ final LinkRepresentation describedByLink = actionPromptRepr.getLinkWithRel(Rel.DESCRIBEDBY);
+ assertThat(describedByLink, isLink(client)
+ .returning(HttpStatusCode.OK)
+ .responseEntityWithSelfHref(describedByLink.getHref()));
+
+ assertThat(actionPromptRepr.getExtensions().getString("actionType"), is("user"));
+ assertThat(actionPromptRepr.getExtensions().getString("actionSemantics"), is("safe"));
+ assertThat(actionPromptRepr.getArray("parameters").size(), is(3));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/449a03ba/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Get_thenRepresentation_ok_TODO.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Get_thenRepresentation_ok_TODO.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Get_thenRepresentation_ok_TODO.java
deleted file mode 100644
index 5c42e0e..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Get_thenRepresentation_ok_TODO.java
+++ /dev/null
@@ -1,104 +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.domainobjectorservice.id.action;
-
-import static org.apache.isis.core.commons.matchers.IsisMatchers.matches;
-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 javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status.Family;
-
-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.LinkRepresentation;
-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.domainobjects.DomainObjectResource;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-
-public class Get_thenRepresentation_ok_TODO {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- protected RestfulClient client;
- private DomainObjectResource domainObjectResource;
-
- @Before
- public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
- domainObjectResource = client.getDomainObjectResource();
- }
-
- @Ignore("to get working again")
- @Test
- public void actionPrompt() throws Exception {
-
- // when
- final Response actionPromptResp = domainObjectResource.actionPrompt("OID","1", "list");
- final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp);
- assertThat(actionPromptJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- // then
- final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity();
-
- // _self.link
- final LinkRepresentation selfLink = actionPromptRepr.getLink("_self.link");
- assertThat(selfLink.getRel(), is("member"));
- assertThat(selfLink.getHref(), matches(".+objects/OID:1/actions/list"));
- assertThat(selfLink.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- // _self.object
- final LinkRepresentation selfObject = actionPromptRepr.getLink("_self.object");
- assertThat(selfObject.getRel(), is("object"));
- assertThat(selfObject.getHref(), matches(".+objects/OID:1"));
- assertThat(selfObject.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- // type
- final LinkRepresentation type = actionPromptRepr.getLink("type");
- assertThat(type.getRel(), is("type"));
- assertThat(type.getHref(), matches(".+vnd\\.list\\+json"));
- assertThat(type.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- assertThat(actionPromptRepr.getString("memberType"), is("action"));
- assertThat(actionPromptRepr.getString("actionType"), is("USER"));
- assertThat(actionPromptRepr.getInt("numParameters"), is(0));
- assertThat(actionPromptRepr.getArray("parameters").size(), is(0));
-
- final LinkRepresentation invokeLink = actionPromptRepr.getLink("invoke");
- assertThat(invokeLink.getRel(), is("invoke"));
- assertThat(invokeLink.getHref(), matches(".+objects/OID:1/actions/list/invoke"));
- assertThat(invokeLink.getHttpMethod(), is(RestfulHttpMethod.POST));
- assertThat(invokeLink.getArguments(), is(not(nullValue())));
- assertThat(invokeLink.getArguments().isArray(), is(true));
- assertThat(invokeLink.getArguments().size(), is(0));
- }
-
-
-}