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 2014/04/23 21:43:53 UTC
[10/14] git commit: ISIS-421: more work on RO TCK tests
ISIS-421: more work on RO TCK tests
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/76d5b0bb
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/76d5b0bb
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/76d5b0bb
Branch: refs/heads/master
Commit: 76d5b0bb1551f4e4ad1e33412a590506f6f71958
Parents: 9c83204
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Fri Apr 4 08:08:30 2014 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue Apr 22 17:37:04 2014 +0100
----------------------------------------------------------------------
.../applib/JsonRepresentation.java | 33 +++-----
.../isis/viewer/restfulobjects/applib/Rel.java | 21 +++++
.../domainobjects/DomainRepresentation.java | 9 ++-
.../restfulobjects/applib/util/PathNode.java | 22 ++++--
.../AbstractObjectMemberReprRenderer.java | 2 +-
.../domainobjects/JsonValueEncoder.java | 47 ++++-------
.../rendering/LinkFollowSpecsTest_follow.java | 42 ++++++++--
.../JsonValueEncoderTest_asAdapter.java | 81 +++++++++++--------
.../server/resources/DomainResourceHelper.java | 31 ++++++--
.../restfulobjects/tck/RelTest_matches.java | 32 ++++++++
.../restfulobjects/tck/RestfulMatchers.java | 23 ++----
.../isis/viewer/restfulobjects/tck/Util.java | 35 +++------
...EntityWithActions_thenRepresentation_ok.java | 4 +-
.../collection/Get_thenRepresentation_ok.java | 17 ++--
.../oid/property/Get_thenRepresentation_ok.java | 17 ++--
.../id/action/Get_thenRepresentation_ok.java | 17 ++--
.../Get_givenActionSemanticsOfSafe_ok.java | 32 ++++----
...enMandatorySimpleArg_whenArgMissing_bad.java | 13 +---
.../Get_whenQueryArg_xRoFollowLinks_ok.java | 36 ++++-----
.../root/Get_whenRequestHeaders_Accept_ok.java | 78 +++++++++++++++++++
.../root/Get_whenRequestHeaders_accept_ok.java | 82 --------------------
.../BooleanValueSemanticsProviderAbstract.java | 2 +-
22 files changed, 353 insertions(+), 323 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/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 8d12315..009bf42 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
@@ -22,34 +22,21 @@ import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
-
-import org.apache.isis.viewer.restfulobjects.applib.util.JsonNodeUtils;
-import org.apache.isis.viewer.restfulobjects.applib.util.PathNode;
-import org.apache.isis.viewer.restfulobjects.applib.util.UrlEncodingUtils;
-
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.node.ArrayNode;
-import org.codehaus.jackson.node.BigIntegerNode;
-import org.codehaus.jackson.node.DecimalNode;
-import org.codehaus.jackson.node.JsonNodeFactory;
-import org.codehaus.jackson.node.NullNode;
-import org.codehaus.jackson.node.ObjectNode;
-import org.codehaus.jackson.node.POJONode;
-import org.joda.time.format.DateTimeFormat;
-import org.joda.time.format.DateTimeFormatter;
-
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.node.*;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+import org.apache.isis.viewer.restfulobjects.applib.util.JsonNodeUtils;
+import org.apache.isis.viewer.restfulobjects.applib.util.PathNode;
+import org.apache.isis.viewer.restfulobjects.applib.util.UrlEncodingUtils;
/**
* A wrapper around {@link JsonNode} that provides some additional helper
@@ -793,9 +780,9 @@ public class JsonRepresentation {
}
checkValue(path, node, "a bigdecimal");
if (node.isBigDecimal()) {
- throw new IllegalArgumentException(formatExMsg(path, "is not a bigdecimal (or any other numeric)"));
+ return node.getDecimalValue();
}
- return node.getDecimalValue();
+ throw new IllegalArgumentException(formatExMsg(path, "is not a bigdecimal (or any other numeric)"));
}
private BigDecimal getBigDecimalFromNumeric(final String path, final JsonNode node) {
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/Rel.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/Rel.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/Rel.java
index c52b49a..5381e1b 100644
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/Rel.java
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/Rel.java
@@ -82,4 +82,25 @@ public enum Rel {
:"");
}
+ public boolean matches(Rel otherRel) {
+ return this == otherRel;
+ }
+
+ public boolean matches(final String otherRelStr) {
+ final Rel otherRel = Rel.parse(otherRelStr);
+ return matches(otherRel);
+ }
+
+ public static Rel parse(String str) {
+ final int i = str.indexOf(";");
+ if(i != -1) {
+ str = str.substring(0, i);
+ }
+ for (Rel candidate: Rel.values()) {
+ if(candidate.getName().equals(str)) {
+ return candidate;
+ }
+ }
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainRepresentation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainRepresentation.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainRepresentation.java
index 31b81e1..1a954b1 100644
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainRepresentation.java
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainRepresentation.java
@@ -18,13 +18,13 @@
*/
package org.apache.isis.viewer.restfulobjects.applib.domainobjects;
+import org.codehaus.jackson.JsonNode;
import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation.HasExtensions;
import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation.HasLinkToSelf;
import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation.HasLinks;
import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.Rel;
-import org.codehaus.jackson.JsonNode;
public abstract class DomainRepresentation extends JsonRepresentation implements HasLinkToSelf, HasLinks, HasExtensions {
@@ -43,7 +43,12 @@ public abstract class DomainRepresentation extends JsonRepresentation implements
}
public LinkRepresentation getLinkWithRel(final Rel rel) {
- return getLinkWithRel(rel.getName());
+ for (final LinkRepresentation linkRepr : getLinks().arrayIterable(LinkRepresentation.class)) {
+ if(rel.matches(linkRepr.getRel())) {
+ return linkRepr;
+ }
+ }
+ return null;
}
public LinkRepresentation getLinkWithRel(final String rel) {
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/util/PathNode.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/util/PathNode.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/util/PathNode.java
index 4cd303a..c2e2257 100644
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/util/PathNode.java
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/util/PathNode.java
@@ -23,13 +23,11 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
-import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
-
import com.google.common.base.Objects;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
public class PathNode {
private static final Pattern NODE = Pattern.compile("^([^\\[]*)(\\[(.+)\\])?$");
@@ -117,10 +115,24 @@ public class PathNode {
return false;
}
for (final Map.Entry<String, String> criterium : getCriteria().entrySet()) {
- final String requiredValue = criterium.getValue();
+ String requiredValue = criterium.getValue();
if(requiredValue != null) {
// list syntax
- final String actualValue = repr.getString(criterium.getKey());
+ String actualValue = repr.getString(criterium.getKey());
+ if(actualValue == null) {
+ return false;
+ }
+
+ // determine if fuzzy match (ie without additional parameters)
+ // eg [rel=urn:org.restfulobjects:rel/details;action="list"] matches [rel=urn:org.restfulobjects:rel/details]
+ final int actualValueSemiIndex = actualValue.indexOf(";");
+ final int requiredValueSemiIndex = requiredValue.indexOf(";");
+ if(actualValueSemiIndex != -1 && requiredValueSemiIndex == -1 ) {
+ actualValue = actualValue.substring(0, actualValueSemiIndex);
+ }
+ if(actualValueSemiIndex == -1 && requiredValueSemiIndex != -1) {
+ requiredValue = requiredValue.substring(0, requiredValueSemiIndex);
+ }
if (!Objects.equal(requiredValue, actualValue)) {
return false;
}
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/AbstractObjectMemberReprRenderer.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/AbstractObjectMemberReprRenderer.java b/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/AbstractObjectMemberReprRenderer.java
index 4b9871d..c2d2622 100644
--- a/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/AbstractObjectMemberReprRenderer.java
+++ b/component/viewer/restfulobjects/rendering/src/main/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/AbstractObjectMemberReprRenderer.java
@@ -155,7 +155,7 @@ public abstract class AbstractObjectMemberReprRenderer<R extends ReprRendererAbs
representation.mapPut("id", objectMember.getId());
if(!mode.isArguments()) {
- representation.mapPut("memberType", memberType.getName());
+ representation.mapPut("memberType", objectMemberType.getName());
}
if (mode.isInline()) {
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/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 63d4de7..c3446b6 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,15 +21,12 @@ package org.apache.isis.viewer.restfulobjects.rendering.domainobjects;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
-import java.util.Date;
import java.util.List;
import java.util.Map;
-
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-
import org.codehaus.jackson.node.NullNode;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
@@ -37,10 +34,10 @@ import org.joda.time.LocalDateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
-
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
+import org.apache.isis.core.metamodel.facets.object.parseable.TextEntryParseException;
import org.apache.isis.core.metamodel.spec.ObjectSpecId;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.runtime.system.context.IsisContext;
@@ -575,35 +572,21 @@ public final class JsonValueEncoder {
- public static ObjectAdapter asAdapter(final ObjectSpecification objectSpec, final JsonRepresentation argRepr) {
- if(!argRepr.mapHas("value")) {
- String reason = "No 'value' key";
- argRepr.mapPut("invalidReason", reason);
- throw new IllegalArgumentException(reason);
+ public static ObjectAdapter asAdapter(final ObjectSpecification objectSpec, final JsonRepresentation argValueRepr) {
+ if(argValueRepr == null) {
+ return null;
}
- if (objectSpec == null) {
- String reason = "ObjectSpec is null, cannot validate";
- argRepr.mapPut("invalidReason", reason);
- throw new IllegalArgumentException(reason);
+ if (!argValueRepr.isValue()) {
+ throw new IllegalArgumentException("Representation must be of a value");
}
final EncodableFacet encodableFacet = objectSpec.getFacet(EncodableFacet.class);
if (encodableFacet == null) {
String reason = "ObjectSpec expected to have an EncodableFacet";
- argRepr.mapPut("invalidReason", reason);
- throw new IllegalArgumentException(reason);
- }
-
- final JsonRepresentation argValueRepr = argRepr.getRepresentation("value");
- if(argValueRepr == null) {
- return null;
- }
- if (!argValueRepr.isValue()) {
- String reason = "Representation must be of a value";
- argRepr.mapPut("invalidReason", reason);
throw new IllegalArgumentException(reason);
}
- final JsonValueConverter jvc = converterBySpec.get(objectSpec.getSpecId());
+ final ObjectSpecId specId = objectSpec.getSpecId();
+ final JsonValueConverter jvc = converterBySpec.get(specId);
if(jvc == null) {
// best effort
if (argValueRepr.isString()) {
@@ -611,9 +594,7 @@ public final class JsonValueEncoder {
return encodableFacet.fromEncodedString(argStr);
}
- final String reason = "Unable to parse value";
- argRepr.mapPut("invalidReason", reason);
- throw new IllegalArgumentException(reason);
+ throw new IllegalArgumentException("Unable to parse value");
}
final ObjectAdapter asAdapter = jvc.asAdapter(argValueRepr);
@@ -624,12 +605,14 @@ public final class JsonValueEncoder {
// last attempt
if (argValueRepr.isString()) {
final String argStr = argValueRepr.asString();
- return encodableFacet.fromEncodedString(argStr);
+ try {
+ return encodableFacet.fromEncodedString(argStr);
+ } catch(TextEntryParseException ex) {
+ throw new IllegalArgumentException(ex.getMessage());
+ }
}
- final String reason = "Could not parse value '" + argValueRepr.asString() + "' as a " + objectSpec.getFullIdentifier();
- argRepr.mapPut("invalidReason", reason);
- throw new IllegalArgumentException(reason);
+ throw new IllegalArgumentException("Could not parse value '" + argValueRepr.asString() + "' as a " + objectSpec.getFullIdentifier());
}
public static void appendValueAndFormat(ObjectSpecification objectSpec, ObjectAdapter objectAdapter, JsonRepresentation repr) {
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/LinkFollowSpecsTest_follow.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/LinkFollowSpecsTest_follow.java b/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/LinkFollowSpecsTest_follow.java
index e6f3429..97b447c 100644
--- a/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/LinkFollowSpecsTest_follow.java
+++ b/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/LinkFollowSpecsTest_follow.java
@@ -18,14 +18,13 @@
*/
package org.apache.isis.viewer.restfulobjects.rendering;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
import java.util.List;
-
+import org.junit.Test;
import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.util.Parser;
-import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
public class LinkFollowSpecsTest_follow {
@@ -167,7 +166,38 @@ public class LinkFollowSpecsTest_follow {
assertThat(followRelUser.follow("y").isFollowing(), is(true));
}
-
+ @Test
+ public void multiplePaths_withRelFullCriteria() throws Exception {
+ final List<List<String>> links = asListOfLists("links[rel=urn:org.restfulobjects:rels/details;action=foo].x,links[rel=urn:org.restfulobjects:rels/details;action=bar].y");
+
+ final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links);
+
+ LinkFollowSpecs followRelVersion = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/details;action=foo]");
+ assertThat(followRelVersion.isFollowing(), is(true));
+ assertThat(followRelVersion.isTerminated(), is(false));
+
+ assertThat(followRelVersion.follow("x").isFollowing(), is(true));
+
+ LinkFollowSpecs followRelUser = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/details;action=bar]");
+ assertThat(followRelUser.isFollowing(), is(true));
+ assertThat(followRelUser.isTerminated(), is(false));
+ assertThat(followRelUser.follow("y").isFollowing(), is(true));
+ }
+
+ @Test
+ public void multiplePaths_withRelSimplifiedCriteria() throws Exception {
+ final List<List<String>> links = asListOfLists("links[rel=urn:org.restfulobjects:rels/details;action=foo].x,links[rel=urn:org.restfulobjects:rels/details;action=bar].y");
+
+ final LinkFollowSpecs linkFollower = LinkFollowSpecs.create(links);
+
+ LinkFollowSpecs followRelVersion = linkFollower.follow("links[rel=urn:org.restfulobjects:rels/details]");
+ assertThat(followRelVersion.isFollowing(), is(true));
+ assertThat(followRelVersion.isTerminated(), is(false));
+
+ assertThat(followRelVersion.follow("x").isFollowing(), is(true));
+ }
+
+
private List<List<String>> asListOfLists(final String string) {
return Parser.forListOfListOfStrings().valueOf(string);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/JsonValueEncoderTest_asAdapter.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/JsonValueEncoderTest_asAdapter.java b/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/JsonValueEncoderTest_asAdapter.java
index e4cf0e4..62a4847 100644
--- a/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/JsonValueEncoderTest_asAdapter.java
+++ b/component/viewer/restfulobjects/rendering/src/test/java/org/apache/isis/viewer/restfulobjects/rendering/domainobjects/JsonValueEncoderTest_asAdapter.java
@@ -18,24 +18,10 @@
*/
package org.apache.isis.viewer.restfulobjects.rendering.domainobjects;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-
import java.math.BigDecimal;
import java.math.BigInteger;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
-import org.codehaus.jackson.node.BigIntegerNode;
-import org.codehaus.jackson.node.BooleanNode;
-import org.codehaus.jackson.node.DecimalNode;
-import org.codehaus.jackson.node.DoubleNode;
-import org.codehaus.jackson.node.IntNode;
-import org.codehaus.jackson.node.LongNode;
-import org.codehaus.jackson.node.TextNode;
+import org.codehaus.jackson.node.*;
+import org.hamcrest.Matchers;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.integration.junit4.JMock;
@@ -43,6 +29,16 @@ import org.jmock.integration.junit4.JUnit4Mockery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
+import org.apache.isis.core.metamodel.facets.object.parseable.TextEntryParseException;
+import org.apache.isis.core.metamodel.spec.ObjectSpecId;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.*;
@RunWith(JMock.class)
public class JsonValueEncoderTest_asAdapter {
@@ -70,10 +66,9 @@ public class JsonValueEncoderTest_asAdapter {
JsonValueEncoder.asAdapter(null, representation);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void whenReprIsNull() throws Exception {
- allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- JsonValueEncoder.asAdapter(objectSpec, null);
+ assertThat(JsonValueEncoder.asAdapter(objectSpec, null), is(Matchers.nullValue()));
}
@Test(expected = IllegalArgumentException.class)
@@ -108,7 +103,7 @@ public class JsonValueEncoderTest_asAdapter {
private void whenReprIsBoolean(final Class<?> correspondingClass) {
// given
allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- allowingObjectSpecCorrespondingClassIs(correspondingClass);
+ allowingObjectSpecCorrespondingClassAndSpecIdIs(correspondingClass);
final boolean value = true;
representation = new JsonRepresentation(BooleanNode.valueOf(value));
context.checking(new Expectations() {
@@ -129,7 +124,14 @@ public class JsonValueEncoderTest_asAdapter {
public void whenObjectSpecIsBooleanButReprIsNot() throws Exception {
// given
allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- allowingObjectSpecCorrespondingClassIs(boolean.class);
+ allowingObjectSpecCorrespondingClassAndSpecIdIs(boolean.class);
+
+ context.checking(new Expectations() {
+ {
+ one(encodableFacet).fromEncodedString("aString");
+ will(throwException(new TextEntryParseException("'aString' cannot be parsed as a boolean value")));
+ }
+ });
// when
jsonValueEncoder.asAdapter(objectSpec, representation);
@@ -148,7 +150,7 @@ public class JsonValueEncoderTest_asAdapter {
private void whenReprIsInteger(final Class<?> correspondingClass) {
// given
allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- allowingObjectSpecCorrespondingClassIs(correspondingClass);
+ allowingObjectSpecCorrespondingClassAndSpecIdIs(correspondingClass);
final int value = 123;
representation = new JsonRepresentation(IntNode.valueOf(value));
context.checking(new Expectations() {
@@ -169,7 +171,7 @@ public class JsonValueEncoderTest_asAdapter {
public void whenObjectSpecIsIntegerButReprIsNot() throws Exception {
// given
allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- allowingObjectSpecCorrespondingClassIs(int.class);
+ allowingObjectSpecCorrespondingClassAndSpecIdIs(int.class);
representation = JsonRepresentation.newMap("foo", "bar");
@@ -190,7 +192,7 @@ public class JsonValueEncoderTest_asAdapter {
private void whenReprIsLong(final Class<?> correspondingClass) {
// given
allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- allowingObjectSpecCorrespondingClassIs(correspondingClass);
+ allowingObjectSpecCorrespondingClassAndSpecIdIs(correspondingClass);
final long value = 1234567890L;
representation = new JsonRepresentation(LongNode.valueOf(value));
context.checking(new Expectations() {
@@ -211,7 +213,14 @@ public class JsonValueEncoderTest_asAdapter {
public void whenObjectSpecIsLongButReprIsNot() throws Exception {
// given
allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- allowingObjectSpecCorrespondingClassIs(long.class);
+ allowingObjectSpecCorrespondingClassAndSpecIdIs(long.class);
+
+ context.checking(new Expectations() {
+ {
+ one(encodableFacet).fromEncodedString("aString");
+ will(throwException(new TextEntryParseException("'aString' cannot be parsed as a long value")));
+ }
+ });
// when
jsonValueEncoder.asAdapter(objectSpec, representation);
@@ -230,7 +239,7 @@ public class JsonValueEncoderTest_asAdapter {
private void whenReprIsDouble(final Class<?> correspondingClass) {
// given
allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- allowingObjectSpecCorrespondingClassIs(correspondingClass);
+ allowingObjectSpecCorrespondingClassAndSpecIdIs(correspondingClass);
final double value = 123.45;
representation = new JsonRepresentation(DoubleNode.valueOf(value));
context.checking(new Expectations() {
@@ -251,7 +260,7 @@ public class JsonValueEncoderTest_asAdapter {
public void whenObjectSpecIsDoubleButReprIsNot() throws Exception {
// given
allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- allowingObjectSpecCorrespondingClassIs(double.class);
+ allowingObjectSpecCorrespondingClassAndSpecIdIs(double.class);
representation = JsonRepresentation.newMap("foo", "bar");
@@ -263,7 +272,7 @@ public class JsonValueEncoderTest_asAdapter {
public void whenReprIsBigInteger() throws Exception {
// given
allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- allowingObjectSpecCorrespondingClassIs(BigInteger.class);
+ allowingObjectSpecCorrespondingClassAndSpecIdIs(BigInteger.class);
final BigInteger value = BigInteger.valueOf(123);
representation = new JsonRepresentation(BigIntegerNode.valueOf(value));
context.checking(new Expectations() {
@@ -284,7 +293,7 @@ public class JsonValueEncoderTest_asAdapter {
public void whenObjectSpecIsBigIntegerButReprIsNot() throws Exception {
// given
allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- allowingObjectSpecCorrespondingClassIs(BigInteger.class);
+ allowingObjectSpecCorrespondingClassAndSpecIdIs(BigInteger.class);
representation = JsonRepresentation.newMap("foo", "bar");
@@ -296,12 +305,12 @@ public class JsonValueEncoderTest_asAdapter {
public void whenReprIsBigDecimal() throws Exception {
// given
allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- allowingObjectSpecCorrespondingClassIs(BigDecimal.class);
+ allowingObjectSpecCorrespondingClassAndSpecIdIs(BigDecimal.class);
final BigDecimal value = new BigDecimal("123234234.45612312343535");
representation = new JsonRepresentation(DecimalNode.valueOf(value));
context.checking(new Expectations() {
{
- one(encodableFacet).fromEncodedString("" + value);
+ oneOf(encodableFacet).fromEncodedString("" + value);
will(returnValue(objectAdapter));
}
});
@@ -317,7 +326,7 @@ public class JsonValueEncoderTest_asAdapter {
public void whenObjectSpecIsBigDecimalButReprIsNot() throws Exception {
// given
allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- allowingObjectSpecCorrespondingClassIs(BigDecimal.class);
+ allowingObjectSpecCorrespondingClassAndSpecIdIs(BigDecimal.class);
representation = JsonRepresentation.newMap("foo", "bar");
@@ -329,7 +338,7 @@ public class JsonValueEncoderTest_asAdapter {
public void whenReprIsString() throws Exception {
// given
allowingObjectSpecHas(EncodableFacet.class, encodableFacet);
- allowingObjectSpecCorrespondingClassIs(String.class);
+ allowingObjectSpecCorrespondingClassAndSpecIdIs(String.class);
representation = new JsonRepresentation(TextNode.valueOf("aString"));
context.checking(new Expectations() {
@@ -355,11 +364,15 @@ public class JsonValueEncoderTest_asAdapter {
});
}
- private void allowingObjectSpecCorrespondingClassIs(final Class<?> result) {
+ private void allowingObjectSpecCorrespondingClassAndSpecIdIs(final Class<?> result) {
context.checking(new Expectations() {
{
allowing(objectSpec).getCorrespondingClass();
will(returnValue(result));
+
+ allowing(objectSpec).getSpecId();
+ will(returnValue(ObjectSpecId.of(result.getName())));
+
}
});
}
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainResourceHelper.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainResourceHelper.java b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainResourceHelper.java
index cb892af..e9c7690 100644
--- a/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainResourceHelper.java
+++ b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainResourceHelper.java
@@ -41,6 +41,7 @@ import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.version.Version;
import org.apache.isis.core.metamodel.consent.Consent;
+import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.feature.Contributed;
import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
@@ -342,11 +343,32 @@ public final class DomainResourceHelper {
return null;
}
+ if(!argRepr.mapHas("value")) {
+ String reason = "No 'value' key";
+ argRepr.mapPut("invalidReason", reason);
+ throw new IllegalArgumentException(reason);
+ }
+
+ if (objectSpec == null) {
+ String reason = "ObjectSpec is null, cannot validate";
+ argRepr.mapPut("invalidReason", reason);
+ throw new IllegalArgumentException(reason);
+ }
+ final EncodableFacet encodableFacet = objectSpec.getFacet(EncodableFacet.class);
+ if (encodableFacet == null) {
+ String reason = "ObjectSpec expected to have an EncodableFacet";
+ argRepr.mapPut("invalidReason", reason);
+ throw new IllegalArgumentException(reason);
+ }
+
+ final JsonRepresentation argValueRepr = argRepr.getRepresentation("value");
+
// value (encodable)
if (objectSpec.isEncodeable()) {
try {
- return JsonValueEncoder.asAdapter(objectSpec, argRepr);
+ return JsonValueEncoder.asAdapter(objectSpec, argValueRepr);
}catch(IllegalArgumentException ex) {
+ argRepr.mapPut("invalidReason", ex.getMessage());
throw ex;
}catch(Exception ex) {
StringBuilder buf = new StringBuilder("Failed to parse representation ");
@@ -362,13 +384,6 @@ public final class DomainResourceHelper {
}
}
- final JsonRepresentation argValueRepr = argRepr.getRepresentation("value");
- if(argValueRepr == null) {
- String reason = "No 'value' key";
- argRepr.mapPut("invalidReason", reason);
- throw new IllegalArgumentException(reason);
- }
-
// reference
if (!argValueRepr.isLink()) {
final String reason = "Expected a link (because this object's type is not a value) but found no 'href'";
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/RelTest_matches.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/RelTest_matches.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/RelTest_matches.java
new file mode 100644
index 0000000..5ad181c
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/RelTest_matches.java
@@ -0,0 +1,32 @@
+package org.apache.isis.viewer.restfulobjects.tck;
+
+import org.junit.Test;
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+public class RelTest_matches {
+
+ @Test
+ public void whenDoes() throws Exception {
+ assertThat(Rel.ACTION.matches(Rel.ACTION), is(true));
+ }
+
+ @Test
+ public void whenDoesNot() throws Exception {
+ assertThat(Rel.ACTION.matches(Rel.ACTION_PARAM), is(false));
+ }
+
+ @Test
+ public void whenMatchesOnStr() throws Exception {
+ assertThat(Rel.ACTION.matches(Rel.ACTION.getName()), is(true));
+ }
+
+ @Test
+ public void whenMatchesOnStrWithParams() throws Exception {
+ assertThat(Rel.ACTION.matches(Rel.ACTION.andParam("foo", "bar")), is(true));
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/RestfulMatchers.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/RestfulMatchers.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/RestfulMatchers.java
index bb3c24a..fa71905 100644
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/RestfulMatchers.java
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/RestfulMatchers.java
@@ -18,11 +18,13 @@
*/
package org.apache.isis.viewer.restfulobjects.tck;
-import java.io.IOException;
-
import javax.ws.rs.core.CacheControl;
import javax.ws.rs.core.MediaType;
-
+import com.google.common.base.Objects;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+import org.junit.Assert;
import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation.HasLinkToSelf;
import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
@@ -32,19 +34,6 @@ 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.tck.RestfulMatchers.AbstractMatcherBuilder;
-import org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.CacheControlMatcherBuilder;
-import org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.LinkMatcherBuilder;
-
-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.Assert;
-
-import com.google.common.base.Objects;
public class RestfulMatchers {
@@ -340,7 +329,7 @@ public class RestfulMatchers {
return false;
}
final LinkRepresentation link = linkRepr.asLink();
- if (rel != null && !rel.equals(link.getRel())) {
+ if (rel != null && !Rel.parse(rel).matches(link.getRel())) {
return false;
}
if (relNameMatcher != null && !relNameMatcher.matches(link.getRel())) {
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/Util.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/Util.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/Util.java
index d3b59e3..4e783f9 100644
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/Util.java
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/Util.java
@@ -18,42 +18,26 @@
*/
package org.apache.isis.viewer.restfulobjects.tck;
-import static org.apache.isis.core.commons.matchers.IsisMatchers.matches;
-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;
-import static org.junit.Assert.assertThat;
-
-import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
import javax.ws.rs.core.Response;
-
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
import org.apache.isis.core.commons.matchers.IsisMatchers;
-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.*;
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;
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.ListRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ActionResultRepresentation.ResultType;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.hamcrest.CoreMatchers;
-import org.junit.Test;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
public class Util {
@@ -80,15 +64,16 @@ public class Util {
public static JsonRepresentation givenAction(RestfulClient client, final String serviceId, final String actionId) throws JsonParseException, JsonMappingException, IOException {
final String href = givenHrefToService(client, serviceId);
+ final String detailRel = Rel.DETAILS.andParam("action", actionId);
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, href).withArg(RequestParameter.FOLLOW_LINKS, "members[%s].links[rel=%s]", actionId, Rel.DETAILS.getName());
+ final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, href).withArg(RequestParameter.FOLLOW_LINKS, "members[%s].links[rel=%s]", actionId, detailRel);
final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();
assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
final DomainObjectRepresentation repr = restfulResponse.getEntity();
final JsonRepresentation actionLinkRepr = repr.getAction(actionId);
- return actionLinkRepr.getRepresentation("links[rel=%s].value", Rel.DETAILS.getName());
+ return actionLinkRepr.getRepresentation("links[rel=%s].value", detailRel);
}
/**
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithActions_thenRepresentation_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithActions_thenRepresentation_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithActions_thenRepresentation_ok.java
index 88b4b65..194868a 100644
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithActions_thenRepresentation_ok.java
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithActions_thenRepresentation_ok.java
@@ -73,7 +73,7 @@ public class Get_givenEntityWithActions_thenRepresentation_ok {
assertThat(actions.size(), is(3));
final DomainObjectMemberRepresentation containsAction = domainObjectRepr.getAction("contains");
- assertThat(containsAction.getString("objectMemberType"), is("action"));
+ assertThat(containsAction.getString("memberType"), is("action"));
assertThat(containsAction.getString("id"), is("contains"));
LinkRepresentation containsActionLink = containsAction.getLinkWithRel(Rel.DETAILS.andParam("action", "contains"));
@@ -84,7 +84,7 @@ public class Get_givenEntityWithActions_thenRepresentation_ok {
// can also look up with abbreviated parameterized version of Rel
containsActionLink = containsAction.getLinkWithRel(Rel.DETAILS);
- assertThat(containsActionLink.getRel(), is("action"));
+ assertThat(containsActionLink.getRel(), is("urn:org.restfulobjects:rels/details;action=\"contains\""));
assertThat(containsActionLink.getHref(), is(self.getHref() + "/actions/contains"));
assertThat(containsActionLink.getType(), is(RepresentationType.OBJECT_ACTION.getMediaType()));
assertThat(containsActionLink.getHttpMethod(), is(RestfulHttpMethod.GET));
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/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
index 9ed6daf..4fcf756 100644
--- 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
@@ -18,22 +18,11 @@
*/
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;
@@ -46,6 +35,10 @@ import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRe
import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectCollectionRepresentation;
import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.*;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
public class Get_thenRepresentation_ok {
@Rule
public IsisWebServerRule webServerRule = new IsisWebServerRule();
@@ -72,7 +65,7 @@ public class Get_thenRepresentation_ok {
// then
final ObjectCollectionRepresentation collectionRepr = collectionJsonResp.getEntity();
- assertThat(collectionRepr.getString("objectMemberType"), is("collection"));
+ assertThat(collectionRepr.getString("memberType"), is("collection"));
// self link
final LinkRepresentation selfLink = collectionRepr.getLinkWithRel(Rel.SELF);
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/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
index 89b9e78..1583409 100644
--- 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
@@ -18,22 +18,11 @@
*/
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;
@@ -46,6 +35,10 @@ import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRe
import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectPropertyRepresentation;
import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.*;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
public class Get_thenRepresentation_ok {
@@ -74,7 +67,7 @@ public class Get_thenRepresentation_ok {
// then
final ObjectPropertyRepresentation propertyRepr = idPropertyJsonResp.getEntity();
- assertThat(propertyRepr.getString("objectMemberType"), is("property"));
+ assertThat(propertyRepr.getString("memberType"), is("property"));
// self link
final LinkRepresentation selfLink = propertyRepr.getLinkWithRel(Rel.SELF);
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/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
index f72f1df..96b997d 100644
--- 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
@@ -18,21 +18,11 @@
*/
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;
@@ -45,6 +35,11 @@ import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRe
import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation;
import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.assertThat;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
public class Get_thenRepresentation_ok {
@Rule
@@ -71,7 +66,7 @@ public class Get_thenRepresentation_ok {
// then
final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity();
- assertThat(actionPromptRepr.getString("objectMemberType"), is("action"));
+ assertThat(actionPromptRepr.getString("memberType"), is("action"));
// self link
final LinkRepresentation selfLink = actionPromptRepr.getLinkWithRel(Rel.SELF);
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenActionSemanticsOfSafe_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenActionSemanticsOfSafe_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenActionSemanticsOfSafe_ok.java
index edf63db..cce19c1 100644
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenActionSemanticsOfSafe_ok.java
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenActionSemanticsOfSafe_ok.java
@@ -18,20 +18,15 @@
*/
package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action.invoke;
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasMediaTypeProfile;
-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.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;
+import org.apache.isis.viewer.restfulobjects.applib.*;
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;
@@ -42,12 +37,11 @@ import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresenta
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;
+
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasMediaTypeProfile;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
public class Get_givenActionSemanticsOfSafe_ok {
@@ -75,7 +69,7 @@ public class Get_givenActionSemanticsOfSafe_ok {
final LinkRepresentation invokeLink = actionRepr.getInvoke();
assertThat(invokeLink, isLink(client)
- .rel(Rel.INVOKE)
+ .rel(Rel.INVOKE.andParam("action", "list"))
.httpMethod(RestfulHttpMethod.GET)
.href(Matchers.endsWith(":39393/services/ActionsEntities/actions/list/invoke"))
.arguments(JsonRepresentation.newMap())
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenMandatorySimpleArg_whenArgMissing_bad.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenMandatorySimpleArg_whenArgMissing_bad.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenMandatorySimpleArg_whenArgMissing_bad.java
index 7d4a2ba..7a80072 100644
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenMandatorySimpleArg_whenArgMissing_bad.java
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/invoke/Get_givenMandatorySimpleArg_whenArgMissing_bad.java
@@ -18,24 +18,15 @@
*/
package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action.invoke;
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.hasMediaTypeProfile;
-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.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;
@@ -52,6 +43,10 @@ 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 static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.*;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
public class Get_givenMandatorySimpleArg_whenArgMissing_bad {
@Rule
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/serviceId/Get_whenQueryArg_xRoFollowLinks_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/serviceId/Get_whenQueryArg_xRoFollowLinks_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/serviceId/Get_whenQueryArg_xRoFollowLinks_ok.java
index a22dfc2..0971323 100644
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/serviceId/Get_whenQueryArg_xRoFollowLinks_ok.java
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainservice/serviceId/Get_whenQueryArg_xRoFollowLinks_ok.java
@@ -18,36 +18,28 @@
*/
package org.apache.isis.viewer.restfulobjects.tck.domainservice.serviceId;
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isMap;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-
import java.io.IOException;
-
-
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
-
import org.apache.isis.core.webserver.WebServer;
import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.Rel;
import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest.RequestParameter;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
import org.apache.isis.viewer.restfulobjects.tck.Util;
-import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.*;
+import static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isMap;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
public class Get_whenQueryArg_xRoFollowLinks_ok {
@@ -117,7 +109,7 @@ public class Get_whenQueryArg_xRoFollowLinks_ok {
final String href = givenHrefToService("WrapperValuedEntities");
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, href).withArg(RequestParameter.FOLLOW_LINKS, "members[%s].links[rel=%s]", "list", Rel.DETAILS.getName());
+ final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, href).withArg(RequestParameter.FOLLOW_LINKS, "members[%s].links[rel=%s]", "list", Rel.DETAILS.andParam("action", "list"));
final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();
assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
@@ -129,12 +121,12 @@ public class Get_whenQueryArg_xRoFollowLinks_ok {
JsonRepresentation actionRepr;
actionRepr = membersList.getRepresentation("list");
- assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"]"), is(not(nullValue())));
- assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"].value"), is(not(nullValue()))); // followed
+ assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "list")+"]"), is(not(nullValue())));
+ assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "list")+"].value"), is(not(nullValue()))); // followed
actionRepr = membersList.getRepresentation("newEntity");
- assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"]"), is(not(nullValue())));
- assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"].value"), is(nullValue())); // not followed
+ assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "newEntity")+"]"), is(not(nullValue())));
+ assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "newEntity")+"].value"), is(nullValue())); // not followed
}
@Test
@@ -142,7 +134,7 @@ public class Get_whenQueryArg_xRoFollowLinks_ok {
final String href = givenHrefToService("WrapperValuedEntities");
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, href).withArg(RequestParameter.FOLLOW_LINKS, "members[%s].links[rel=%s],members[%s].links[rel=%s]", "list", Rel.DETAILS.getName(), "newEntity", Rel.DETAILS.getName());
+ final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, href).withArg(RequestParameter.FOLLOW_LINKS, "members[%s].links[rel=%s],members[%s].links[rel=%s]", "list", Rel.DETAILS.andParam("action", "list"), "newEntity", Rel.DETAILS.andParam("action", "newEntity"));
final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();
assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
@@ -154,12 +146,12 @@ public class Get_whenQueryArg_xRoFollowLinks_ok {
JsonRepresentation actionRepr;
actionRepr = membersList.getRepresentation("list");
- assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"]"), is(not(nullValue())));
- assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"].value"), is(not(nullValue()))); // followed
+ assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "list")+"]"), is(not(nullValue())));
+ assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "list")+"].value"), is(not(nullValue()))); // followed
actionRepr = membersList.getRepresentation("newEntity");
- assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"]"), is(not(nullValue())));
- assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"].value"), is(not(nullValue()))); // also followed
+ assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "newEntity")+"]"), is(not(nullValue())));
+ assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "newEntity")+"].value"), is(not(nullValue()))); // also followed
}
private String givenHrefToService(final String serviceId) throws JsonParseException, JsonMappingException, IOException {
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/user/root/Get_whenRequestHeaders_Accept_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/user/root/Get_whenRequestHeaders_Accept_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/user/root/Get_whenRequestHeaders_Accept_ok.java
new file mode 100644
index 0000000..e467907
--- /dev/null
+++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/user/root/Get_whenRequestHeaders_Accept_ok.java
@@ -0,0 +1,78 @@
+/*
+ * 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.user.root;
+
+import javax.ws.rs.core.MediaType;
+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.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class Get_whenRequestHeaders_Accept_ok {
+
+ @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, "user");
+ }
+
+ @Test
+ public void applicationJson_noProfile_returns200() throws Exception {
+
+ request.withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
+ final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ assertThat(restfulResponse.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.USER.getMediaType()));
+ }
+
+ @Test
+ public void applicationJson_profileUser_returns200() throws Exception {
+
+ request.withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
+ final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ }
+
+ @Test
+ public void missingHeader_returns200() throws Exception {
+
+ final RestfulResponse<UserRepresentation> restfulResp = request.executeT();
+
+ assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/user/root/Get_whenRequestHeaders_accept_ok.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/user/root/Get_whenRequestHeaders_accept_ok.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/user/root/Get_whenRequestHeaders_accept_ok.java
deleted file mode 100644
index bfa5f9a..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/user/root/Get_whenRequestHeaders_accept_ok.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.user.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.user.UserRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.jboss.resteasy.client.ClientRequest;
-import org.jboss.resteasy.client.ClientResponse;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class Get_whenRequestHeaders_Accept_ok {
-
- @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, "user");
- }
-
- @Test
- public void applicationJson_noProfile_returns200() throws Exception {
-
- request.withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
- final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- assertThat(restfulResponse.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.USER.getMediaType()));
- }
-
- @Test
- public void applicationJson_profileUser_returns200() throws Exception {
-
- request.withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
- final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void missingHeader_returns200() throws Exception {
-
- final RestfulResponse<UserRepresentation> restfulResp = request.executeT();
-
- assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/76d5b0bb/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/booleans/BooleanValueSemanticsProviderAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/booleans/BooleanValueSemanticsProviderAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/booleans/BooleanValueSemanticsProviderAbstract.java
index c41b01d..68f0cb6 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/booleans/BooleanValueSemanticsProviderAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/progmodel/facets/value/booleans/BooleanValueSemanticsProviderAbstract.java
@@ -54,7 +54,7 @@ public abstract class BooleanValueSemanticsProviderAbstract extends ValueSemanti
} else if ("false".startsWith(compareTo)) {
return Boolean.FALSE;
} else {
- throw new TextEntryParseException("Not a logical value " + entry);
+ throw new TextEntryParseException(String.format("'%s' cannot be parsed as a boolean", entry));
}
}