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/25 07:56:36 UTC
git commit: ISIS-233: more RO tests
Updated Branches:
refs/heads/dan/ISIS-233-ro 584eb10a1 -> 8617b4562
ISIS-233: more RO tests
focusing on the domain object representation
render URLs without the version info of the OID
recombining certain happy case tests
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/8617b456
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/8617b456
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/8617b456
Branch: refs/heads/dan/ISIS-233-ro
Commit: 8617b45628d5df3c9bae70e9ebb3c944e57a4d76
Parents: 584eb10
Author: Dan Haywood <da...@apache.org>
Authored: Thu Apr 25 06:55:59 2013 +0100
Committer: Dan Haywood <da...@apache.org>
Committed: Thu Apr 25 06:55:59 2013 +0100
----------------------------------------------------------------------
.../restfulobjects/applib/JsonRepresentation.java | 66 ++++++++
.../domainobjects/DomainObjectReprRenderer.java | 21 +++
.../rendering/domainobjects/JsonValueEncoder.java | 103 +++++++++++--
.../domainobjects/ObjectPropertyReprRenderer.java | 12 +--
.../restfulobjects/rendering/util/OidUtils.java | 2 +-
.../oid/Get_thenRepresentation_ok_TOFIX.java | 68 +++++---
.../invoke/Get_thenResponseCode_200_ok_TODO.java | 14 --
...ntType_andContentLength_andRespCode_200_ok.java | 115 +++++++++++++
...nseHeaders_ContentType_andContentLength_ok.java | 112 -------------
...tType_andContentLength__andRespCode_200_ok.java | 127 +++++++++++++++
...nseHeaders_ContentType_andContentLength_ok.java | 125 --------------
.../tck/dom/scalars/PrimitiveValuedEntity.java | 9 +-
12 files changed, 472 insertions(+), 302 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/8617b456/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/JsonRepresentation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/JsonRepresentation.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/JsonRepresentation.java
index ac23b28..f7b20ca 100644
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/JsonRepresentation.java
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/JsonRepresentation.java
@@ -400,6 +400,72 @@ public class JsonRepresentation {
}
// ///////////////////////////////////////////////////////////////////////
+ // isNumber
+ // ///////////////////////////////////////////////////////////////////////
+
+ public boolean isNumber(final String path) {
+ return isNumber(getNode(path));
+ }
+
+ public boolean isNumber() {
+ return isNumber(asJsonNode());
+ }
+
+ private boolean isNumber(final JsonNode node) {
+ return !representsNull(node) && node.isValueNode() && node.isNumber();
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // getShort, asShort
+ // ///////////////////////////////////////////////////////////////////////
+
+ public Short getShort(final String path) {
+ final JsonNode node = getNode(path);
+ return getShort(path, node);
+ }
+
+ public Short asShort() {
+ return getShort(null, asJsonNode());
+ }
+
+ private Short getShort(final String path, final JsonNode node) {
+ if (representsNull(node)) {
+ return null;
+ }
+ checkValue(path, node, "an short");
+ if (!node.isNumber()) {
+ // there is no node.isShort()
+ throw new IllegalArgumentException(formatExMsg(path, "is not a number"));
+ }
+ return node.getNumberValue().shortValue();
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
+ // getByte, asByte
+ // ///////////////////////////////////////////////////////////////////////
+
+ public Byte getByte(final String path) {
+ final JsonNode node = getNode(path);
+ return getByte(path, node);
+ }
+
+ public Byte asByte() {
+ return getByte(null, asJsonNode());
+ }
+
+ private Byte getByte(final String path, final JsonNode node) {
+ if (representsNull(node)) {
+ return null;
+ }
+ checkValue(path, node, "an byte");
+ if (!node.isNumber()) {
+ // there is no node.isByte()
+ throw new IllegalArgumentException(formatExMsg(path, "is not a number"));
+ }
+ return node.getNumberValue().byteValue();
+ }
+
+ // ///////////////////////////////////////////////////////////////////////
// isLong, getLong, asLong
// ///////////////////////////////////////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/isis/blob/8617b456/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/DomainObjectReprRenderer.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/DomainObjectReprRenderer.java b/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/DomainObjectReprRenderer.java
index da3fa24..6b70656 100644
--- a/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/DomainObjectReprRenderer.java
+++ b/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/DomainObjectReprRenderer.java
@@ -18,6 +18,8 @@ package org.apache.isis.viewer.restfulobjects.rendering.domainobjects;
import java.util.List;
+import org.codehaus.jackson.node.NullNode;
+
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
import org.apache.isis.core.metamodel.consent.Consent;
@@ -326,6 +328,25 @@ public class DomainObjectReprRenderer extends ReprRendererAbstract<DomainObjectR
//
// ///////////////////////////////////////////////////////////////////
+ public static void appendValueAndFormatOrRef(final RendererContext resourceContext, final ObjectAdapter objectAdapter, final ObjectSpecification objectSpec, JsonRepresentation repr) {
+
+ final ValueFacet valueFacet = objectSpec.getFacet(ValueFacet.class);
+ if (valueFacet != null) {
+ JsonValueEncoder.appendValueAndFormat(objectSpec, objectAdapter, repr);
+ return;
+ }
+
+ if(objectAdapter == null) {
+ repr.mapPut("value", NullNode.getInstance());
+ } else {
+ final TitleFacet titleFacet = objectSpec.getFacet(TitleFacet.class);
+ final String title = titleFacet.title(objectAdapter, resourceContext.getLocalization());
+ JsonRepresentation ref = DomainObjectReprRenderer.newLinkToBuilder(resourceContext, Rel.VALUE, objectAdapter).withTitle(title).build();
+ repr.mapPut("value", ref);
+ }
+
+ }
+
public static Object valueOrRef(final RendererContext resourceContext, final ObjectAdapter objectAdapter, final ObjectSpecification objectSpec) {
final ValueFacet valueFacet = objectSpec.getFacet(ValueFacet.class);
if (valueFacet != null) {
http://git-wip-us.apache.org/repos/asf/isis/blob/8617b456/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/JsonValueEncoder.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/JsonValueEncoder.java b/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/JsonValueEncoder.java
index 1165c40..0989147 100644
--- a/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/JsonValueEncoder.java
+++ b/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/JsonValueEncoder.java
@@ -21,6 +21,8 @@ package org.apache.isis.viewer.restfulobjects.rendering.domainobjects;
import java.math.BigDecimal;
import java.math.BigInteger;
+import org.codehaus.jackson.node.NullNode;
+
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
@@ -178,7 +180,71 @@ public final class JsonValueEncoder {
throw new IllegalArgumentException(reason);
}
- Object asObject(final ObjectAdapter objectAdapter) {
+ static void appendValueAndFormat(ObjectSpecification objectSpec, ObjectAdapter objectAdapter, JsonRepresentation repr) {
+
+ // special case handling for JSON built-ins
+ // (at least so far as json.org defines them).
+ Object value;
+ String format = null; // as defined by RO spec
+ String xIsisFormat = null; // isis-specific support
+ if (isBoolean(objectSpec)) {
+ value = asValueElseNull(objectAdapter);
+ xIsisFormat = "boolean";
+ } else if (isByte(objectSpec)) {
+ value = asValueElseNull(objectAdapter);
+ xIsisFormat = "byte";
+ } else if (isChar(objectSpec)) {
+ value = asValueElseNull(objectAdapter);
+ xIsisFormat = "char";
+ } else if (isShort(objectSpec)) {
+ value = asValueElseNull(objectAdapter);
+ xIsisFormat = "short";
+ } else if (isInteger(objectSpec)) {
+ value = asValueElseNull(objectAdapter);
+ format = "int";
+ xIsisFormat = "int";
+ } else if (isLong(objectSpec)) {
+ value = asValueElseNull(objectAdapter);
+ format = "int";
+ xIsisFormat = "long";
+ } else if (isBigInteger(objectSpec)) {
+ value = asValueElseNull(objectAdapter);
+ format = "int";
+ xIsisFormat = "biginteger";
+ } else if (isFloat(objectSpec)) {
+ value = asValueElseNull(objectAdapter);
+ format = "decimal";
+ xIsisFormat = "float";
+ } else if (isDouble(objectSpec)) {
+ value = asValueElseNull(objectAdapter);
+ format = "decimal";
+ xIsisFormat = "double";
+ } else if (isBigDecimal(objectSpec)) {
+ value = asValueElseNull(objectAdapter);
+ format = "decimal";
+ xIsisFormat = "bigdecimal";
+ } else {
+ final EncodableFacet encodableFacet = objectSpec.getFacet(EncodableFacet.class);
+ if (encodableFacet == null) {
+ throw new IllegalArgumentException("objectSpec expected to have EncodableFacet");
+ }
+ value = objectAdapter != null? encodableFacet.toEncodedString(objectAdapter): NullNode.getInstance();
+ }
+
+ repr.mapPut("value", value);
+ if(format != null) {
+ repr.mapPut("format", format);
+ }
+ if(xIsisFormat != null) {
+ repr.mapPut("x-isis-format", xIsisFormat);
+ }
+ }
+
+ private static Object asValueElseNull(ObjectAdapter objectAdapter) {
+ return objectAdapter != null? objectAdapter.getObject(): NullNode.getInstance();
+ }
+
+ static Object asObject(final ObjectAdapter objectAdapter) {
if (objectAdapter == null) {
throw new IllegalArgumentException("objectAdapter cannot be null");
}
@@ -198,31 +264,47 @@ public final class JsonValueEncoder {
return encodableFacet.toEncodedString(objectAdapter);
}
- private boolean isBoolean(final ObjectSpecification objectSpec) {
+ private static boolean isBoolean(final ObjectSpecification objectSpec) {
return hasCorrespondingClass(objectSpec, boolean.class, Boolean.class);
}
- private boolean isInteger(final ObjectSpecification objectSpec) {
- return hasCorrespondingClass(objectSpec, int.class, Integer.class);
+ private static boolean isByte(final ObjectSpecification objectSpec) {
+ return hasCorrespondingClass(objectSpec, byte.class, Byte.class);
+ }
+
+ private static boolean isChar(final ObjectSpecification objectSpec) {
+ return hasCorrespondingClass(objectSpec, char.class, Character.class);
+ }
+
+ private static boolean isShort(final ObjectSpecification objectSpec) {
+ return hasCorrespondingClass(objectSpec, short.class, Short.class);
}
- private boolean isLong(final ObjectSpecification objectSpec) {
+ private static boolean isInteger(final ObjectSpecification objectSpec) {
+ return hasCorrespondingClass(objectSpec, int.class, Integer.class);
+ }
+
+ private static boolean isLong(final ObjectSpecification objectSpec) {
return hasCorrespondingClass(objectSpec, long.class, Long.class);
}
- private boolean isBigInteger(final ObjectSpecification objectSpec) {
+ private static boolean isBigInteger(final ObjectSpecification objectSpec) {
return hasCorrespondingClass(objectSpec, BigInteger.class);
}
+
+ private static boolean isFloat(final ObjectSpecification objectSpec) {
+ return hasCorrespondingClass(objectSpec, float.class, Float.class);
+ }
- private boolean isDouble(final ObjectSpecification objectSpec) {
+ private static boolean isDouble(final ObjectSpecification objectSpec) {
return hasCorrespondingClass(objectSpec, double.class, Double.class);
}
-
- private boolean isBigDecimal(final ObjectSpecification objectSpec) {
+
+ private static boolean isBigDecimal(final ObjectSpecification objectSpec) {
return hasCorrespondingClass(objectSpec, BigDecimal.class);
}
- private boolean hasCorrespondingClass(final ObjectSpecification objectSpec, final Class<?>... candidates) {
+ private static boolean hasCorrespondingClass(final ObjectSpecification objectSpec, final Class<?>... candidates) {
final Class<?> specClass = objectSpec.getCorrespondingClass();
for (final Class<?> candidate : candidates) {
if (specClass == candidate) {
@@ -238,4 +320,5 @@ public final class JsonValueEncoder {
throw new IllegalArgumentException(reason);
}
+
}
http://git-wip-us.apache.org/repos/asf/isis/blob/8617b456/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/ObjectPropertyReprRenderer.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/ObjectPropertyReprRenderer.java b/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/ObjectPropertyReprRenderer.java
index e89188d..f5501c2 100644
--- a/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/ObjectPropertyReprRenderer.java
+++ b/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/ObjectPropertyReprRenderer.java
@@ -61,18 +61,8 @@ public class ObjectPropertyReprRenderer extends AbstractObjectMemberReprRenderer
// ///////////////////////////////////////////////////
private void addValue() {
- representation.mapPut("value", valueOrRefRepr());
- }
-
- private Object valueOrRefRepr() {
final ObjectAdapter valueAdapter = objectMember.get(objectAdapter);
- if (valueAdapter == null) {
- return NullNode.getInstance();
- }
- // REVIEW: previously was using the spec of the member, but think instead it should be the spec of the adapter itself
- // final ObjectSpecification valueSpec = objectMember.getSpecification();
- ObjectSpecification valueSpec = valueAdapter.getSpecification();
- return DomainObjectReprRenderer.valueOrRef(rendererContext, valueAdapter, valueSpec);
+ DomainObjectReprRenderer.appendValueAndFormatOrRef(rendererContext, valueAdapter, valueAdapter.getSpecification(), representation);
}
// ///////////////////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/isis/blob/8617b456/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/util/OidUtils.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/util/OidUtils.java b/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/util/OidUtils.java
index 04144a0..823da16 100644
--- a/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/util/OidUtils.java
+++ b/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/util/OidUtils.java
@@ -51,7 +51,7 @@ public final class OidUtils {
if(!(oid instanceof RootOid)) {
throw new IllegalArgumentException("objectAdapter must be a root adapter");
}
- return oid != null ? oid.enString(getOidMarshaller()) : null;
+ return oid != null ? oid.enStringNoVersion(getOidMarshaller()) : null;
}
private static OidMarshaller getOidMarshaller() {
http://git-wip-us.apache.org/repos/asf/isis/blob/8617b456/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_thenRepresentation_ok_TOFIX.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_thenRepresentation_ok_TOFIX.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_thenRepresentation_ok_TOFIX.java
index 253fde7..4e5248f 100644
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_thenRepresentation_ok_TOFIX.java
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_thenRepresentation_ok_TOFIX.java
@@ -20,7 +20,9 @@ package org.apache.isis.viewer.restfulobjects.tck.domainobject.oid;
import static org.apache.isis.core.commons.matchers.IsisMatchers.matches;
import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.assertThat;
+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.*;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
@@ -47,11 +49,16 @@ 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.RestfulMediaType;
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.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.DomainObjectMemberRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource;
import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation;
@@ -73,41 +80,56 @@ public class Get_thenRepresentation_ok_TOFIX {
client = new RestfulClient(webServer.getBase());
}
- @Ignore("to fix")
@Test
- public void returnsDomainObjectRepresentation() throws Exception {
+ public void withPrimitiveProperties() throws Exception {
// given
final DomainObjectResource domainObjectResource = client.getDomainObjectResource();
// when
- final Response domainObjectResp = domainObjectResource.object("OID","6");
- final RestfulResponse<DomainObjectRepresentation> domainObjectJsonResp = RestfulResponse.ofT(domainObjectResp);
- assertThat(domainObjectJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
+ final Response jaxrsResponse = domainObjectResource.object("PRMV","29");
+ final RestfulResponse<DomainObjectRepresentation> restfulResponse = RestfulResponse.ofT(jaxrsResponse);
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
// then
- final DomainObjectRepresentation domainObjectRepr = domainObjectJsonResp.getEntity();
- assertThat(domainObjectRepr, is(not(nullValue())));
- }
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ assertThat(restfulResponse.getHeader(Header.CONTENT_TYPE), hasProfile(RestfulMediaType.APPLICATION_JSON_OBJECT));
+ assertThat(restfulResponse.getHeader(Header.CONTENT_LENGTH), is(6226));
- @Ignore("to fix")
- @Test
- public void domainObjectRepresentationForPersistentObject_hasSelfAndOid() throws Exception {
+ final DomainObjectRepresentation domainObjectRepr = restfulResponse.getEntity();
+ assertThat(domainObjectRepr, is(not(nullValue())));
- // given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
+ // and then has title
+ assertThat(domainObjectRepr.getTitle(), is("Primitive Valued Entity #0")); // running in-memory
+
+ // and then extensions
+ assertThat(domainObjectRepr.getExtensions().getString("oid"), is("PRMV:29"));
+ assertThat(domainObjectRepr.getExtensions().getBoolean("isService"), is(false));
+ assertThat(domainObjectRepr.getExtensions().getBoolean("isPersistent"), is(true));
- // then
+ // and then has links
final LinkRepresentation self = domainObjectRepr.getSelf();
- assertThat(self, isLink().rel(Rel.SELF).href(matches(".+objects/OID/32")).httpMethod(RestfulHttpMethod.GET).type(MediaType.APPLICATION_JSON_TYPE).typeParameter("profile", "urn:org.restfulobjects/domainobject"));
- assertThat(domainObjectRepr.getLinkWithRel(Rel.DESCRIBEDBY), isLink().href(matches(".+" + BidirWithSetChildEntity.class.getName())).httpMethod(RestfulHttpMethod.GET).type(MediaType.APPLICATION_JSON_TYPE).typeParameter("profile", "urn:org.restfulobjects/domaintype"));
-
- assertThat(domainObjectRepr.getTitle(), is("parent 4 - child 2"));
- assertThat(domainObjectRepr.getOid(), is("OID:32"));
-
- // no icon
- final LinkRepresentation selfIcon = domainObjectRepr.getLinkWithRel(Rel.ICON);
- assertThat(selfIcon, is(nullValue()));
+ assertThat(self, isLink()
+ .rel(Rel.SELF)
+ .href(matches(".+\\/objects\\/PRMV\\/29"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.DOMAIN_OBJECT.getMediaType()));
+ assertThat(domainObjectRepr.getLinkWithRel(Rel.DESCRIBEDBY),
+ isLink()
+ .href(matches(".+\\/domain-types\\/PRMV"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.DOMAIN_TYPE.getMediaType()));
+ assertThat(domainObjectRepr.getLinkWithRel(Rel.MODIFY),
+ isLink()
+ .href(matches(".+\\/objects\\/PRMV\\/29"))
+ .httpMethod(RestfulHttpMethod.PUT)
+ .type(RepresentationType.DOMAIN_OBJECT.getMediaType()));
+
+ // and then members
+ DomainObjectMemberRepresentation property = domainObjectRepr.getProperty("byteProperty");
+ assertThat(property.getMemberType(), is("property"));
+ Byte byteValue = property.getRepresentation("value").as(ScalarValueRepresentation.class).asByte();
+ assertThat(byteValue, is((byte)0));
}
@Ignore("to fix")
http://git-wip-us.apache.org/repos/asf/isis/blob/8617b456/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
deleted file mode 100644
index b42bef2..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_thenResponseCode_200_ok_TODO.java
+++ /dev/null
@@ -1,14 +0,0 @@
-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/8617b456/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenList_thenRepr_andRespHeaders_ContentType_andContentLength_andRespCode_200_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenList_thenRepr_andRespHeaders_ContentType_andContentLength_andRespCode_200_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenList_thenRepr_andRespHeaders_ContentType_andContentLength_andRespCode_200_ok.java
new file mode 100644
index 0000000..2ead161
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenList_thenRepr_andRespHeaders_ContentType_andContentLength_andRespCode_200_ok.java
@@ -0,0 +1,115 @@
+/*
+ * 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.*;
+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.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.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_thenRepr_andRespHeaders_ContentType_andContentLength_andRespCode_200_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);
+ }
+
+ @Test
+ public void usingResourceProxy() throws Exception {
+
+ // given, when
+ Response response = serviceResource.invokeActionQueryOnly("ActionsEntities", "list", null);
+ RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
+
+ then(restfulResponse);
+ }
+
+ private static void then(final RestfulResponse<ActionResultRepresentation> restfulResponse) throws JsonParseException, JsonMappingException, IOException {
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ assertThat(restfulResponse.getHeader(Header.CONTENT_TYPE), hasProfile(RestfulMediaType.APPLICATION_JSON_ACTION_RESULT));
+ assertThat(restfulResponse.getHeader(Header.CONTENT_LENGTH), is(2090));
+
+ 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));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/8617b456/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenList_thenRepresentation_ok_andResponseHeaders_ContentType_andContentLength_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_andResponseHeaders_ContentType_andContentLength_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenList_thenRepresentation_ok_andResponseHeaders_ContentType_andContentLength_ok.java
deleted file mode 100644
index 5ac99c4..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenList_thenRepresentation_ok_andResponseHeaders_ContentType_andContentLength_ok.java
+++ /dev/null
@@ -1,112 +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.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_andResponseHeaders_ContentType_andContentLength_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);
- }
-
- @Test
- public void usingResourceProxy() throws Exception {
-
- // given, when
- Response response = serviceResource.invokeActionQueryOnly("ActionsEntities", "list", null);
- RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
-
- 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));
- assertThat(restfulResponse.getHeader(Header.CONTENT_LENGTH), is(2245));
-
- 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));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/8617b456/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenObject_isNotNull_thenRepr_ok_andRespHeaders_ContentType_andContentLength__andRespCode_200_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenObject_isNotNull_thenRepr_ok_andRespHeaders_ContentType_andContentLength__andRespCode_200_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenObject_isNotNull_thenRepr_ok_andRespHeaders_ContentType_andContentLength__andRespCode_200_ok.java
new file mode 100644
index 0000000..a7b1856
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenObject_isNotNull_thenRepr_ok_andRespHeaders_ContentType_andContentLength__andRespCode_200_ok.java
@@ -0,0 +1,127 @@
+package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action.invoke;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasProfile;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.Response;
+
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+import org.junit.Before;
+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.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.DomainObjectRepresentation;
+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 Get_whenObject_isNotNull_thenRepr_ok_andRespHeaders_ContentType_andContentLength__andRespCode_200_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", "findById");
+ final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
+
+ final LinkRepresentation invokeLink = actionRepr.getInvoke();
+ final JsonRepresentation args =invokeLink.getArguments();
+
+ // when
+ args.mapPut("id.value", 1);
+
+ // when
+ final RestfulResponse<ActionResultRepresentation> restfulResponse = client.followT(invokeLink, args);
+
+ // then
+ then(restfulResponse);
+ }
+
+
+ @Test
+ public void usingResourceProxy() throws Exception {
+
+ // given, when
+
+ JsonRepresentation args = JsonRepresentation.newMap();
+ args.mapPut("id.value", 1);
+
+ Response response = serviceResource.invokeActionQueryOnly("ActionsEntities", "findById", UrlEncodingUtils.urlEncode(args));
+ RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
+
+ then(restfulResponse);
+ }
+
+ private static void then(final RestfulResponse<ActionResultRepresentation> restfulResponse) throws JsonParseException, JsonMappingException, IOException {
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ assertThat(restfulResponse.getHeader(Header.CONTENT_TYPE), hasProfile(RestfulMediaType.APPLICATION_JSON_ACTION_RESULT));
+ assertThat(restfulResponse.getHeader(Header.CONTENT_LENGTH), is(3248));
+
+ final ActionResultRepresentation actionResultRepr = restfulResponse.getEntity();
+
+ assertThat(actionResultRepr.getResultType(), is(ResultType.DOMAIN_OBJECT));
+ final DomainObjectRepresentation objRepr = actionResultRepr.getResult().as(DomainObjectRepresentation.class);
+
+ assertThat(objRepr.getMembers(), is(not(nullValue())));
+ assertThat(objRepr.getMembers().size(), is(greaterThan(0)));
+
+ assertThat(objRepr.getTitle(), is(not(nullValue())));
+
+ assertThat(objRepr.getLinks(), is(not(nullValue())));
+ assertThat(objRepr.getMembers().size(), is(greaterThan(0)));
+
+ assertThat(objRepr.getExtensions(), is(not(nullValue())));
+ }
+
+ private static Matcher<Integer> greaterThan(final int i) {
+ return new TypeSafeMatcher<Integer>() {
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("greater than " + i);
+ }
+
+ @Override
+ protected boolean matchesSafely(Integer item) {
+ return item > i;
+ }
+ };
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/8617b456/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenObject_isNotNull_thenRepresentation_ok_andResponseHeaders_ContentType_andContentLength_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenObject_isNotNull_thenRepresentation_ok_andResponseHeaders_ContentType_andContentLength_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenObject_isNotNull_thenRepresentation_ok_andResponseHeaders_ContentType_andContentLength_ok.java
deleted file mode 100644
index 92d5e58..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_whenObject_isNotNull_thenRepresentation_ok_andResponseHeaders_ContentType_andContentLength_ok.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action.invoke;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasProfile;
-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.Response;
-
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
-import org.hamcrest.TypeSafeMatcher;
-import org.junit.Before;
-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.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.DomainObjectRepresentation;
-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 Get_whenObject_isNotNull_thenRepresentation_ok_andResponseHeaders_ContentType_andContentLength_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", "findById");
- final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
-
- final LinkRepresentation invokeLink = actionRepr.getInvoke();
- final JsonRepresentation args =invokeLink.getArguments();
-
- // when
- args.mapPut("id.value", 1);
-
- // when
- final RestfulResponse<ActionResultRepresentation> restfulResponse = client.followT(invokeLink, args);
-
- // then
- then(restfulResponse);
- }
-
-
- @Test
- public void usingResourceProxy() throws Exception {
-
- // given, when
-
- JsonRepresentation args = JsonRepresentation.newMap();
- args.mapPut("id.value", 1);
-
- Response response = serviceResource.invokeActionQueryOnly("ActionsEntities", "findById", UrlEncodingUtils.urlEncode(args));
- RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
-
- 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));
- assertThat(restfulResponse.getHeader(Header.CONTENT_LENGTH), is(3335));
-
- final ActionResultRepresentation actionResultRepr = restfulResponse.getEntity();
-
- assertThat(actionResultRepr.getResultType(), is(ResultType.DOMAIN_OBJECT));
- final DomainObjectRepresentation objRepr = actionResultRepr.getResult().as(DomainObjectRepresentation.class);
-
- assertThat(objRepr.getMembers(), is(not(nullValue())));
- assertThat(objRepr.getMembers().size(), is(greaterThan(0)));
-
- assertThat(objRepr.getTitle(), is(not(nullValue())));
-
- assertThat(objRepr.getLinks(), is(not(nullValue())));
- assertThat(objRepr.getMembers().size(), is(greaterThan(0)));
-
- assertThat(objRepr.getExtensions(), is(not(nullValue())));
- }
-
- private static Matcher<Integer> greaterThan(final int i) {
- return new TypeSafeMatcher<Integer>() {
-
- @Override
- public void describeTo(Description description) {
- description.appendText("greater than " + i);
- }
-
- @Override
- protected boolean matchesSafely(Integer item) {
- return item > i;
- }
- };
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/8617b456/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/scalars/PrimitiveValuedEntity.java
----------------------------------------------------------------------
diff --git a/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/scalars/PrimitiveValuedEntity.java b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/scalars/PrimitiveValuedEntity.java
index c8c738e..2b0da2d 100644
--- a/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/scalars/PrimitiveValuedEntity.java
+++ b/core/tck/tck-dom/src/main/java/org/apache/isis/core/tck/dom/scalars/PrimitiveValuedEntity.java
@@ -22,6 +22,7 @@ package org.apache.isis.core.tck.dom.scalars;
import org.apache.isis.applib.AbstractDomainObject;
import org.apache.isis.applib.annotation.MemberOrder;
import org.apache.isis.applib.annotation.ObjectType;
+import org.apache.isis.applib.annotation.Title;
@javax.jdo.annotations.PersistenceCapable
@javax.jdo.annotations.Discriminator("PRMV")
@@ -31,9 +32,11 @@ import org.apache.isis.applib.annotation.ObjectType;
@ObjectType("PRMV")
public class PrimitiveValuedEntity extends AbstractDomainObject {
+
// {{ Id (Integer)
private Integer id;
+ @Title(prepend="Primitive Valued Entity #")
@javax.jdo.annotations.PrimaryKey // must be on the getter.
public Integer getId() {
return id;
@@ -44,12 +47,6 @@ public class PrimitiveValuedEntity extends AbstractDomainObject {
}
// }}
- // {{ Title
- public String title() {
- return null;
- }
-
- // }}
// {{ BooleanProperty
private boolean booleanProperty;