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/10/28 17:16:18 UTC
[15/56] [abbrv] ISIS-937: moved TCK out of core.
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/Util.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/Util.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/Util.java
new file mode 100644
index 0000000..bcbe014
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/Util.java
@@ -0,0 +1,148 @@
+/*
+ * 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;
+
+import java.io.IOException;
+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.*;
+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 static org.apache.isis.viewer.restfulobjects.tck.RestfulMatchers.isLink;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+public class Util {
+
+ private Util() {
+ }
+
+ public static String givenLinkToService(RestfulClient restfulClient, String serviceId) throws JsonParseException, JsonMappingException, IOException {
+
+ final DomainServiceResource resource = restfulClient.getDomainServiceResource();
+ final Response response = resource.services();
+ final ListRepresentation services = RestfulResponse.<ListRepresentation> ofT(response).getEntity();
+
+ final String href = services.getRepresentation("value[rel=" + Rel.SERVICE.getName() + ";serviceId=\"" + serviceId + "\"]").asLink().getHref();
+ return href;
+ }
+
+ public static String givenHrefToService(RestfulClient client, final String serviceId) throws JsonParseException, JsonMappingException, IOException {
+ final DomainServiceResource resource = client.getDomainServiceResource();
+ final Response response = resource.services();
+ final ListRepresentation services = RestfulResponse.<ListRepresentation> ofT(response).getEntity();
+
+ return services.getRepresentation("value[rel=urn:org.restfulobjects:rels/service;serviceId=\"%s\"]", serviceId).asLink().getHref();
+ }
+
+ 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, 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", detailRel);
+ }
+
+ /**
+ * For clientFollow tests; returns a link to the first entity in the list returned by invoking the 'list' action of the specified repo
+ */
+ public static LinkRepresentation serviceActionListInvokeFirstReference(RestfulClient client, String repoName) throws Exception {
+ return serviceActionListInvokeFirstReference(client, repoName, "list");
+ }
+
+ /**
+ * For clientFollow tests; returns a link to the first entity in the list returned by invoking the specified repo and action
+ */
+ public static LinkRepresentation serviceActionListInvokeFirstReference(RestfulClient client, String repoName, String actionName) throws Exception {
+ return serviceActionListInvokeFirstReference(client, repoName, actionName, 0);
+ }
+
+ /**
+ * For clientFollow tests; returns a link to the Nth entity in the list returned by invoking the specified repo and action
+ */
+ public static LinkRepresentation serviceActionListInvokeFirstReference(RestfulClient client, String repoName, String actionName, int idx) throws Exception {
+
+ final DomainServiceResource serviceResource = client.getDomainServiceResource();
+
+ Response response = serviceResource.invokeActionQueryOnly(repoName, actionName, null);
+ RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ final ActionResultRepresentation actionResultRepr = restfulResponse.getEntity();
+
+ assertThat(actionResultRepr.getResultType(), is(ResultType.LIST));
+ final ListRepresentation listRepr = actionResultRepr.getResult().as(ListRepresentation.class);
+
+ assertThat(listRepr.getValue(), is(not(nullValue())));
+ assertThat(listRepr.getValue().size(), is(IsisMatchers.greaterThan(idx + 1)));
+
+ final LinkRepresentation domainObjectLinkRepr = listRepr.getValue().arrayGet(idx).as(LinkRepresentation.class);
+
+ assertThat(domainObjectLinkRepr, is(not(nullValue())));
+ assertThat(domainObjectLinkRepr, isLink().rel(Rel.ELEMENT).httpMethod(RestfulHttpMethod.GET).type(RepresentationType.DOMAIN_OBJECT.getMediaType()).arguments(JsonRepresentation.newMap()).build());
+
+ return domainObjectLinkRepr;
+ }
+
+
+
+ /**
+ * For resourceProxy tests; returns the first entity in the list returned by invoking the 'list' action on the specified repo
+ */
+ public static RestfulResponse<DomainObjectRepresentation> domainObjectJaxrsResponse(RestfulClient client, String repoName) throws Exception {
+ return domainObjectJaxrsResponse(client, repoName, "list");
+ }
+
+ /**
+ * For resourceProxy tests; returns the first entity in the list returned by invoking the specified repo and action
+ */
+ public static RestfulResponse<DomainObjectRepresentation> domainObjectJaxrsResponse(RestfulClient client, String repoName, String actionName) throws Exception {
+ return domainObjectJaxrsResponse(client, repoName, actionName, 0);
+ }
+
+ /**
+ * For resourceProxy tests; returns the Nth entity in the list returned by invoking the specified repo and action
+ */
+ public static RestfulResponse<DomainObjectRepresentation> domainObjectJaxrsResponse(RestfulClient client, String repoName, String actionName, int idx) throws Exception {
+ final LinkRepresentation link = Util.serviceActionListInvokeFirstReference(client, repoName, actionName, idx);
+ DomainObjectRepresentation domainObjectRepr = client.follow(link).getEntity().as(DomainObjectRepresentation.class);
+
+ final Response jaxrsResponse = client.getDomainObjectResource().object(domainObjectRepr.getDomainType(), domainObjectRepr.getInstanceId());
+ final RestfulResponse<DomainObjectRepresentation> restfulResponse = RestfulResponse.ofT(jaxrsResponse);
+ return restfulResponse;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/all/stories/UserStoryTest_TOFIX.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/all/stories/UserStoryTest_TOFIX.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/all/stories/UserStoryTest_TOFIX.java
new file mode 100644
index 0000000..4ca4583
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/all/stories/UserStoryTest_TOFIX.java
@@ -0,0 +1,86 @@
+/*
+ * 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.all.stories;
+
+import static org.apache.isis.core.commons.matchers.IsisMatchers.matches;
+import static org.junit.Assert.assertThat;
+
+import javax.ws.rs.core.Response;
+
+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.client.RepresentationWalker;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageResource;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+public class UserStoryTest_TOFIX {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Ignore("to get working again")
+ @Test
+ public void walkResources() throws Exception {
+
+ // given a response for an initial resource
+ final HomePageResource homePageResource = client.getHomePageResource();
+ final Response homePageResp = homePageResource.homePage();
+
+ // and given a walker starting from this response
+ final RepresentationWalker walker = client.createWalker(homePageResp);
+
+ // when walk the home pages' 'services' link
+ walker.walk("services");
+
+ // and when locate the ApplibValues repo and walk the its 'object' link
+ walker.walk("values[title=ApplibValues].links[rel=object]");
+
+ // and when locate the AppLibValues repo's "newEntity" action and walk
+ // to its details
+ walker.walk("values[objectMemberType=action].details");
+
+ // and when find the invoke body for the "newEntity" action and then
+ // walk the action using the body
+ final JsonRepresentation newEntityActionDetails = walker.getEntity();
+ final JsonRepresentation newEntityActionInvokeBody = newEntityActionDetails.getArray("invoke.body");
+ walker.walk("invoke", newEntityActionInvokeBody);
+
+ // and when walk the link to the returned object
+ walker.walk("link");
+
+ // then the returned object is created with its OID
+ final JsonRepresentation newEntityDomainObject = walker.getEntity();
+ assertThat(newEntityDomainObject.getString("_self.link.href"), matches(".+/objects/OID:[\\d]+$"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/any/NotAuthorizedTest_TODO.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/any/NotAuthorizedTest_TODO.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/any/NotAuthorizedTest_TODO.java
new file mode 100644
index 0000000..b81203e
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/any/NotAuthorizedTest_TODO.java
@@ -0,0 +1,51 @@
+/*
+ * 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.any;
+
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class NotAuthorizedTest_TODO {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+ private RestfulClient client;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ }
+
+ @Ignore("TODO")
+ @Test
+ public void whenAuthenticated() throws Exception {
+
+ }
+
+ @Ignore("TODO")
+ @Test
+ public void whenNotAuthenticated() throws Exception {
+ // should return 401 (13.5)
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/any/errorhandling/AnyResourceTest_serverSideException.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/any/errorhandling/AnyResourceTest_serverSideException.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/any/errorhandling/AnyResourceTest_serverSideException.java
new file mode 100644
index 0000000..26b9614
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/any/errorhandling/AnyResourceTest_serverSideException.java
@@ -0,0 +1,63 @@
+/*
+ * 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.any.errorhandling;
+
+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.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest.Header;
+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.util.Parser;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class AnyResourceTest_serverSideException {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ @Before
+ public void setUp() throws Exception {
+ client = webServerRule.getClient();
+ }
+
+ @Test
+ public void runtimeException_isMapped() throws Exception {
+
+ // given
+ final RestfulRequest restfulReq = client.createRequest(RestfulHttpMethod.GET, "version");
+ final Header<Boolean> header = new Header<Boolean>("X-FAIL", Parser.forBoolean());
+ restfulReq.withHeader(header, true);
+
+ // when
+ final RestfulResponse<JsonRepresentation> jsonResp = restfulReq.execute();
+
+ // then
+ assertThat(jsonResp.getStatus(), is(HttpStatusCode.METHOD_FAILURE));
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Delete_then_405_bad.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Delete_then_405_bad.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Delete_then_405_bad.java
new file mode 100644
index 0000000..88c2131
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Delete_then_405_bad.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.domainobject.oid;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.apache.isis.core.webserver.WebServer;
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.errors.ErrorRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.apache.isis.viewer.restfulobjects.tck.Util;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class Delete_then_405_bad {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ private ErrorRepresentation errorRepresentation;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Test
+ public void followLink() throws Exception {
+
+ // when
+ final LinkRepresentation link = Util.serviceActionListInvokeFirstReference(client, "PrimitiveValuedEntities");
+ final LinkRepresentation deleteLink = link.withMethod(RestfulHttpMethod.DELETE);
+ final RestfulResponse<JsonRepresentation> restfulResponse = client.follow(deleteLink);
+
+ assertThat(restfulResponse.getStatus(), is(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED));
+ assertThat(restfulResponse.getHeader(RestfulResponse.Header.WARNING), is("Deleting objects is not supported."));
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenDisabledMembers_thenRepresentation_ok.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenDisabledMembers_thenRepresentation_ok.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenDisabledMembers_thenRepresentation_ok.java
new file mode 100644
index 0000000..7d87dad
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenDisabledMembers_thenRepresentation_ok.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.domainobject.oid;
+
+import java.io.IOException;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status.Family;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.apache.isis.core.webserver.WebServer;
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class Get_givenDisabledMembers_thenRepresentation_ok {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ private DomainObjectResource domainObjectResource;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ domainObjectResource = client.getDomainObjectResource();
+
+ }
+
+ @Test
+ public void domainObjectWithDisabledMembers() throws Exception {
+
+ // given, when
+ final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("BSRL","75");
+
+ // property ('visibleButNotEditableProperty')
+ final JsonRepresentation properties = domainObjectRepr.getProperties();
+ final JsonRepresentation nameProperty = properties.getRepresentation("visibleButNotEditableProperty");
+ assertThat(nameProperty.getString("disabledReason"), is("Always disabled"));
+ }
+
+
+ private DomainObjectRepresentation givenDomainObjectRepresentationFor(final String domainType, String instanceId) throws JsonParseException, JsonMappingException, IOException {
+ final DomainObjectResource domainObjectResource = client.getDomainObjectResource();
+
+ final Response domainObjectResp = domainObjectResource.object(domainType, instanceId);
+ final RestfulResponse<DomainObjectRepresentation> domainObjectJsonResp = RestfulResponse.ofT(domainObjectResp);
+ assertThat(domainObjectJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
+
+ return domainObjectJsonResp.getEntity();
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenDomainModelSchemeIsFormal_thenRepresentation_ok_TODO.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenDomainModelSchemeIsFormal_thenRepresentation_ok_TODO.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenDomainModelSchemeIsFormal_thenRepresentation_ok_TODO.java
new file mode 100644
index 0000000..2982489
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenDomainModelSchemeIsFormal_thenRepresentation_ok_TODO.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.domainobject.oid;
+
+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.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+public class Get_givenDomainModelSchemeIsFormal_thenRepresentation_ok_TODO {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ private DomainObjectRepresentation domainObjectRepr;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Ignore("TODO")
+ @Test
+ public void thenMembers() throws Exception {
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenDomainModelSchemeIsSimple_thenRepresentation_ok_TODO.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenDomainModelSchemeIsSimple_thenRepresentation_ok_TODO.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenDomainModelSchemeIsSimple_thenRepresentation_ok_TODO.java
new file mode 100644
index 0000000..8f4a162
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenDomainModelSchemeIsSimple_thenRepresentation_ok_TODO.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.domainobject.oid;
+
+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.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+public class Get_givenDomainModelSchemeIsSimple_thenRepresentation_ok_TODO {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ private DomainObjectRepresentation domainObjectRepr;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Ignore("TODO")
+ @Test
+ public void thenMembers() throws Exception {
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithActions_thenRepresentation_ok.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithActions_thenRepresentation_ok.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithActions_thenRepresentation_ok.java
new file mode 100644
index 0000000..a107a4f
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithActions_thenRepresentation_ok.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.domainobject.oid;
+
+import javax.ws.rs.core.Response;
+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.*;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.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.tck.IsisWebServerRule;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+public class Get_givenEntityWithActions_thenRepresentation_ok {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ private DomainObjectResource domainObjectResource;
+ private DomainObjectRepresentation domainObjectRepr;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ domainObjectResource = client.getDomainObjectResource();
+
+ }
+
+ @Test
+ public void thenMembers() throws Exception {
+
+ // when
+ final Response jaxrsResponse = domainObjectResource.object("RTNE","78");
+ final RestfulResponse<DomainObjectRepresentation> restfulResponse = RestfulResponse.ofT(jaxrsResponse);
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+
+ // then
+ domainObjectRepr = restfulResponse.getEntity();
+ assertThat(domainObjectRepr, is(not(nullValue())));
+
+
+ final LinkRepresentation self = domainObjectRepr.getSelf();
+
+ // then actions
+ final JsonRepresentation actions = domainObjectRepr.getActions();
+ assertThat(actions.size(), is(3));
+
+ final DomainObjectMemberRepresentation containsAction = domainObjectRepr.getAction("contains");
+ assertThat(containsAction.getString("memberType"), is("action"));
+ assertThat(containsAction.getString("id"), is("contains"));
+
+ LinkRepresentation containsActionLink = containsAction.getLinkWithRel(Rel.DETAILS.andParam("action", "contains"));
+ assertThat(containsActionLink.getRel(), is(Rel.DETAILS.andParam("action", "contains")));
+ assertThat(containsActionLink.getHref(), is(self.getHref() + "/actions/contains"));
+ assertThat(containsActionLink.getType(), is(RepresentationType.OBJECT_ACTION.getMediaType()));
+ assertThat(containsActionLink.getHttpMethod(), is(RestfulHttpMethod.GET));
+
+ // can also look up with abbreviated parameterized version of Rel
+ containsActionLink = containsAction.getLinkWithRel(Rel.DETAILS);
+ 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/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithApplibProperties_thenRepresentation_ok_TODO.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithApplibProperties_thenRepresentation_ok_TODO.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithApplibProperties_thenRepresentation_ok_TODO.java
new file mode 100644
index 0000000..3f38f85
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithApplibProperties_thenRepresentation_ok_TODO.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.domainobject.oid;
+
+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.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 org.joda.time.LocalDate;
+import org.joda.time.LocalDateTime;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.commons.matchers.IsisMatchers;
+import org.apache.isis.core.webserver.WebServer;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectMemberRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ScalarValueRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.apache.isis.viewer.restfulobjects.tck.Util;
+
+public class Get_givenEntityWithApplibProperties_thenRepresentation_ok_TODO {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ private DomainObjectRepresentation domainObjectRepr;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Ignore("TODO")
+ @Test
+ public void thenMembers() throws Exception {
+
+ // when
+ final LinkRepresentation link = Util.serviceActionListInvokeFirstReference(client, "ApplibValuedEntities");
+ domainObjectRepr = client.follow(link).getEntity().as(DomainObjectRepresentation.class);
+
+ // and then members (types)
+ DomainObjectMemberRepresentation property;
+ ScalarValueRepresentation scalarRepr;
+
+
+ // copy from Get_givenEntityWithPrimitiveProperties_thenRepresentation_ok
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithCollections_thenRepresentation_ok_TODO.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithCollections_thenRepresentation_ok_TODO.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithCollections_thenRepresentation_ok_TODO.java
new file mode 100644
index 0000000..0ea7f76
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithCollections_thenRepresentation_ok_TODO.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.domainobject.oid;
+
+import javax.ws.rs.core.Response;
+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.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+public class Get_givenEntityWithCollections_thenRepresentation_ok_TODO {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ private DomainObjectResource domainObjectResource;
+ private DomainObjectRepresentation domainObjectRepr;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ domainObjectResource = client.getDomainObjectResource();
+
+ }
+
+
+ @Test
+ public void thenCollections() throws Exception {
+
+ // when
+ final Response jaxrsResponse = domainObjectResource.object("PRMV","43");
+ final RestfulResponse<DomainObjectRepresentation> restfulResponse = RestfulResponse.ofT(jaxrsResponse);
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+
+ // then
+
+ domainObjectRepr = restfulResponse.getEntity();
+ assertThat(domainObjectRepr, is(not(nullValue())));
+
+ // then collections
+
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithJdkProperties_thenRepresentation_ok.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithJdkProperties_thenRepresentation_ok.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithJdkProperties_thenRepresentation_ok.java
new file mode 100644
index 0000000..a658574
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithJdkProperties_thenRepresentation_ok.java
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.domainobject.oid;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.apache.isis.core.webserver.WebServer;
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectMemberRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ScalarValueRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.apache.isis.viewer.restfulobjects.tck.Util;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class Get_givenEntityWithJdkProperties_thenRepresentation_ok {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ private DomainObjectRepresentation domainObjectRepr;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Test
+ public void thenMembers() throws Exception {
+
+ // when
+ final LinkRepresentation link = Util.serviceActionListInvokeFirstReference(client, "JdkValuedEntities");
+ final RestfulResponse<JsonRepresentation> restResp = client.follow(link);
+ final JsonRepresentation entityRepr = restResp.getEntity();
+ domainObjectRepr = entityRepr.as(DomainObjectRepresentation.class);
+
+ // and then members (types)
+ DomainObjectMemberRepresentation property;
+ ScalarValueRepresentation scalarRepr;
+
+ property = domainObjectRepr.getProperty("bigDecimalProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("big-decimal(30,10)"));
+ assertThat(property.getXIsisFormat(), is("javamathbigdecimal"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isString(), is(true));
+ BigDecimal bigDecimal = scalarRepr.asBigDecimal(property.getFormat());
+ assertThat(bigDecimal, is(new BigDecimal("12345678901234567890.1234567890")));
+
+ property = domainObjectRepr.getProperty("bigDecimalProperty2");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("big-decimal(18,2)"));
+ assertThat(property.getXIsisFormat(), is("javamathbigdecimal"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isString(), is(true));
+ BigDecimal bigDecimal2 = scalarRepr.asBigDecimal(property.getFormat());
+ assertThat(bigDecimal2, is(new BigDecimal("123.45")));
+
+ property = domainObjectRepr.getProperty("bigIntegerProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("big-integer"));
+ assertThat(property.getXIsisFormat(), is("javamathbiginteger"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isString(), is(true));
+ BigInteger bigInteger = scalarRepr.asBigInteger(property.getFormat());
+ assertThat(bigInteger, is(new BigInteger("123456789012345678")));
+
+ property = domainObjectRepr.getProperty("bigIntegerProperty2");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("big-integer"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isString(), is(true));
+ BigInteger bigInteger2 = scalarRepr.asBigInteger(property.getFormat());
+ assertThat(bigInteger2, is(new BigInteger("12345")));
+
+ property = domainObjectRepr.getProperty("javaSqlDateProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("date"));
+ assertThat(property.getXIsisFormat(), is("javasqldate"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isString(), is(true));
+ assertThat(scalarRepr.asString(), is("2014-04-24"));
+ assertThat(scalarRepr.asDate(), is(asDate("2014-04-24")));
+
+ property = domainObjectRepr.getProperty("javaSqlTimeProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("time"));
+ assertThat(property.getXIsisFormat(), is("javasqltime"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isString(), is(true));
+ assertThat(scalarRepr.asString(), is("12:34:45"));
+ assertThat(scalarRepr.asTime(), is(asDateTime("1970-01-01T12:34:45Z")));
+
+ property = domainObjectRepr.getProperty("javaSqlTimestampProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("utc-millisec"));
+ assertThat(property.getXIsisFormat(), is("javasqltimestamp"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isInt() || scalarRepr.isLong(), is(true));
+ Long aLong = scalarRepr.asLong();
+ assertThat(aLong, is(new Long("1234567890")));
+
+ property = domainObjectRepr.getProperty("javaUtilDateProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("date-time"));
+ assertThat(property.getXIsisFormat(), is("javautildate"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isString(), is(true));
+ Date utilDate = scalarRepr.asDateTime();
+ assertThat(utilDate, is(asDateTime("2013-05-25T12:34:45Z")));
+ assertThat(scalarRepr.asString(), is("2013-05-25T12:34:45Z"));
+
+ property = domainObjectRepr.getProperty("myEnum");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("string"));
+ assertThat(property.getXIsisFormat(), is("string"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isString(), is(true));
+ String myEnumStr = scalarRepr.asString();
+ assertThat(myEnumStr, is("RED"));
+ }
+
+
+ private static Date asDate(final String text) {
+ return new java.util.Date(JsonRepresentation.yyyyMMdd.withZoneUTC().parseDateTime(text).getMillis());
+ }
+
+ private static Date asDateTime(final String text) {
+ return new java.util.Date(JsonRepresentation.yyyyMMddTHHmmssZ.withZoneUTC().parseDateTime(text).getMillis());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithJodaProperties_thenRepresentation_ok.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithJodaProperties_thenRepresentation_ok.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithJodaProperties_thenRepresentation_ok.java
new file mode 100644
index 0000000..e6b55d7
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithJodaProperties_thenRepresentation_ok.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.domainobject.oid;
+
+import java.util.Date;
+import org.joda.time.LocalDateTime;
+import org.joda.time.format.ISODateTimeFormat;
+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.*;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+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.ScalarValueRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.apache.isis.viewer.restfulobjects.tck.Util;
+
+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.isLink;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class Get_givenEntityWithJodaProperties_thenRepresentation_ok {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ private DomainObjectRepresentation domainObjectRepr;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Test
+ public void thenMembers() throws Exception {
+
+ // when
+ final LinkRepresentation link = Util.serviceActionListInvokeFirstReference(client, "JodaValuedEntities");
+ domainObjectRepr = client.follow(link).getEntity().as(DomainObjectRepresentation.class);
+
+ // and then members (types)
+ DomainObjectMemberRepresentation property;
+ ScalarValueRepresentation scalarRepr;
+
+ property = domainObjectRepr.getProperty("dateTimeProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("date-time"));
+ assertThat(property.getXIsisFormat(), is("jodadatetime"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isString(), is(true));
+ assertThat(scalarRepr.asDateTime(), is(asDateTime("2010-03-31T09:50:43Z")));
+ assertThat(scalarRepr.asString(), is("2010-03-31T09:50:43Z"));
+
+ property = domainObjectRepr.getProperty("localDateProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("date"));
+ assertThat(property.getXIsisFormat(), is("jodalocaldate"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isString(), is(true));
+ assertThat(scalarRepr.asDate(), is(asDate("2008-03-21")));
+ assertThat(scalarRepr.asString(), is("2008-03-21"));
+
+ property = domainObjectRepr.getProperty("localDateTimeProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("date-time"));
+ assertThat(property.getXIsisFormat(), is("jodalocaldatetime"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isString(), is(true));
+
+ final LocalDateTime expected = new LocalDateTime(2009, 4, 29, 13, 45, 22);
+
+ assertThat(scalarRepr.asDateTime(), is(expected.toDate()));
+ assertThat(scalarRepr.asString(), is(ISODateTimeFormat.dateTimeNoMillis().withZoneUTC().print(expected.toDateTime())));
+
+ // and then member types have links to details (selected ones inspected only)
+ property = domainObjectRepr.getProperty("localDateProperty");
+ assertThat(property.getLinkWithRel(Rel.DETAILS),
+ isLink()
+ .href(matches(".+\\/objects\\/JODA\\/\\d+\\/properties\\/localDateProperty"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));
+
+ property = domainObjectRepr.getProperty("localDateTimeProperty");
+ assertThat(property.getLinkWithRel(Rel.DETAILS),
+ isLink()
+ .href(matches(".+\\/objects\\/JODA\\/\\d+\\/properties\\/localDateTimeProperty"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));
+ }
+
+ private static Date asDate(final String text) {
+ return new java.util.Date(JsonRepresentation.yyyyMMdd.withZoneUTC().parseDateTime(text).getMillis());
+ }
+
+ private static Date asDateTime(final String text) {
+ return new java.util.Date(JsonRepresentation.yyyyMMddTHHmmssZ.withZoneUTC().parseDateTime(text).getMillis());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithPrimitiveProperties_thenRepresentation_ok.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithPrimitiveProperties_thenRepresentation_ok.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithPrimitiveProperties_thenRepresentation_ok.java
new file mode 100644
index 0000000..ed5977e
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithPrimitiveProperties_thenRepresentation_ok.java
@@ -0,0 +1,178 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.domainobject.oid;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.core.webserver.WebServer;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectMemberRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ScalarValueRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.apache.isis.viewer.restfulobjects.tck.Util;
+
+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.isLink;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+public class Get_givenEntityWithPrimitiveProperties_thenRepresentation_ok {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ private DomainObjectRepresentation domainObjectRepr;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Test
+ public void thenMembers() throws Exception {
+
+ // when
+ final LinkRepresentation link = Util.serviceActionListInvokeFirstReference(client, "PrimitiveValuedEntities");
+ domainObjectRepr = client.follow(link).getEntity().as(DomainObjectRepresentation.class);
+
+ // then members (types)
+ DomainObjectMemberRepresentation property;
+ ScalarValueRepresentation scalarRepr;
+
+ property = domainObjectRepr.getProperty("booleanProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is(nullValue()));
+ assertThat(property.getXIsisFormat(), is("boolean"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isBoolean(), is(true));
+ Boolean booleanValue = scalarRepr.asBoolean();
+ assertThat(booleanValue, is(equalTo(Boolean.TRUE)));
+
+ property = domainObjectRepr.getProperty("byteProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("int"));
+ assertThat(property.getXIsisFormat(), is("byte"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isIntegralNumber(), is(true));
+ Byte byteValue = scalarRepr.asByte();
+ assertThat(byteValue, is((byte)123));
+
+ property = domainObjectRepr.getProperty("shortProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("int"));
+ assertThat(property.getXIsisFormat(), is("short"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isIntegralNumber(), is(true));
+ Short shortValue = scalarRepr.asShort();
+ assertThat(shortValue, is((short)32123));
+
+ property = domainObjectRepr.getProperty("intProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("int"));
+ assertThat(property.getXIsisFormat(), is("int"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isInt(), is(true));
+ Integer intValue = scalarRepr.asInt();
+ assertThat(intValue, is(987654321));
+
+ property = domainObjectRepr.getProperty("longProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("int"));
+ assertThat(property.getXIsisFormat(), is("long"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isLong(), is(true));
+ Long longValue = scalarRepr.asLong();
+ assertThat(longValue, is(2345678901234567890L));
+
+ property = domainObjectRepr.getProperty("charProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is(nullValue()));
+ assertThat(property.getXIsisFormat(), is("char"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isString(), is(true));
+ Character charValue = scalarRepr.asChar();
+ assertThat(charValue, is('a'));
+
+ property = domainObjectRepr.getProperty("floatProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("decimal"));
+ assertThat(property.getXIsisFormat(), is("float"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isNumber(), is(true));
+ assertThat(scalarRepr.isIntegralNumber(), is(false));
+ Float floatValue = scalarRepr.asFloat();
+ assertThat(floatValue, is(12345678901234567890.1234567890F));
+
+ property = domainObjectRepr.getProperty("doubleProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("decimal"));
+ assertThat(property.getXIsisFormat(), is("double"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isDouble(), is(true));
+ Double doubleValue = scalarRepr.asDouble();
+ assertThat(doubleValue, is(12345678901234567890.1234567890));
+
+
+
+ // and then member types have links to details (selected ones inspected only)
+ property = domainObjectRepr.getProperty("booleanProperty");
+ assertThat(property.getLinkWithRel(Rel.DETAILS),
+ isLink()
+ .href(matches(".+\\/objects\\/PRMV\\/\\d+\\/properties\\/booleanProperty"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));
+
+ property = domainObjectRepr.getProperty("byteProperty");
+ assertThat(property.getLinkWithRel(Rel.DETAILS),
+ isLink()
+ .href(matches(".+\\/objects\\/PRMV\\/\\d+\\/properties\\/byteProperty"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));
+
+ property = domainObjectRepr.getProperty("shortProperty");
+ assertThat(property.getLinkWithRel(Rel.DETAILS),
+ isLink()
+ .href(matches(".+\\/objects\\/PRMV\\/\\d+\\/properties\\/shortProperty"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));
+
+ // can navigate using fully qualified form of Rel
+ property = domainObjectRepr.getProperty("booleanProperty");
+ assertThat(property.getLinkWithRel(Rel.DETAILS.andParam("property", "booleanProperty")),
+ isLink()
+ .href(matches(".+\\/objects\\/PRMV\\/\\d+\\/properties\\/booleanProperty"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));
+
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithWrapperProperties_thenRepresentation_ok.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithWrapperProperties_thenRepresentation_ok.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithWrapperProperties_thenRepresentation_ok.java
new file mode 100644
index 0000000..b7cb2be
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntityWithWrapperProperties_thenRepresentation_ok.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.domainobject.oid;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.apache.isis.core.webserver.WebServer;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectMemberRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ScalarValueRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.apache.isis.viewer.restfulobjects.tck.Util;
+
+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.isLink;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+public class Get_givenEntityWithWrapperProperties_thenRepresentation_ok {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ private DomainObjectRepresentation domainObjectRepr;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Test
+ public void thenMembers() throws Exception {
+
+ // when
+ final LinkRepresentation link = Util.serviceActionListInvokeFirstReference(client, "WrapperValuedEntities");
+ domainObjectRepr = client.follow(link).getEntity().as(DomainObjectRepresentation.class);
+
+
+ // and then members (types)
+ DomainObjectMemberRepresentation property;
+ ScalarValueRepresentation scalarRepr;
+
+ property = domainObjectRepr.getProperty("booleanProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is(nullValue()));
+ assertThat(property.getXIsisFormat(), is("boolean"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isBoolean(), is(true));
+ Boolean booleanValue = scalarRepr.asBoolean();
+ assertThat(booleanValue, is(true));
+
+ property = domainObjectRepr.getProperty("byteProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("int"));
+ assertThat(property.getXIsisFormat(), is("byte"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isIntegralNumber(), is(true));
+ Byte byteValue = scalarRepr.asByte();
+ assertThat(byteValue, is((byte)123));
+
+ property = domainObjectRepr.getProperty("shortProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("int"));
+ assertThat(property.getXIsisFormat(), is("short"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isIntegralNumber(), is(true));
+ Short shortValue = scalarRepr.asShort();
+ assertThat(shortValue, is((short)32123));
+
+ property = domainObjectRepr.getProperty("integerProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("int"));
+ assertThat(property.getXIsisFormat(), is("int"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isInt(), is(true));
+ Integer intValue = scalarRepr.asInt();
+ assertThat(intValue, is(987654321));
+
+ property = domainObjectRepr.getProperty("longProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("int"));
+ assertThat(property.getXIsisFormat(), is("long"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isLong(), is(true));
+ Long longValue = scalarRepr.asLong();
+ assertThat(longValue, is(2345678901234567890L));
+
+ property = domainObjectRepr.getProperty("characterProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is(nullValue()));
+ assertThat(property.getXIsisFormat(), is("char"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isString(), is(true));
+ Character charValue = scalarRepr.asChar();
+ assertThat(charValue, is('a'));
+
+ property = domainObjectRepr.getProperty("floatProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("decimal"));
+ assertThat(property.getXIsisFormat(), is("float"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isNumber(), is(true));
+ assertThat(scalarRepr.isIntegralNumber(), is(false));
+ Float floatValue = scalarRepr.asFloat();
+ assertThat(floatValue, is(12345678901234567890.1234567890F));
+
+ property = domainObjectRepr.getProperty("doubleProperty");
+ assertThat(property.getMemberType(), is("property"));
+ assertThat(property.getFormat(), is("decimal"));
+ assertThat(property.getXIsisFormat(), is("double"));
+ scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
+ assertThat(scalarRepr.isDouble(), is(true));
+ Double doubleValue = scalarRepr.asDouble();
+ assertThat(doubleValue, is(12345678901234567890.1234567890));
+
+
+ // and then member types have links to details (selected ones inspected only)
+ property = domainObjectRepr.getProperty("booleanProperty");
+ assertThat(property.getLinkWithRel(Rel.DETAILS),
+ isLink()
+ .href(matches(".+\\/objects\\/WRPV\\/\\d+\\/properties\\/booleanProperty"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));
+
+ property = domainObjectRepr.getProperty("byteProperty");
+ assertThat(property.getLinkWithRel(Rel.DETAILS),
+ isLink()
+ .href(matches(".+\\/objects\\/WRPV\\/\\d+\\/properties\\/byteProperty"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));
+
+ property = domainObjectRepr.getProperty("shortProperty");
+ assertThat(property.getLinkWithRel(Rel.DETAILS),
+ isLink()
+ .href(matches(".+\\/objects\\/WRPV\\/\\d+\\/properties\\/shortProperty"))
+ .httpMethod(RestfulHttpMethod.GET)
+ .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/21e2882a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntity_thenRepresentation_ofTitleIdLinksEtc_ok.java
----------------------------------------------------------------------
diff --git a/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntity_thenRepresentation_ofTitleIdLinksEtc_ok.java b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntity_thenRepresentation_ofTitleIdLinksEtc_ok.java
new file mode 100644
index 0000000..2a7529a
--- /dev/null
+++ b/tck/tck-viewer-restfulobjects/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobject/oid/Get_givenEntity_thenRepresentation_ofTitleIdLinksEtc_ok.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.isis.viewer.restfulobjects.tck.domainobject.oid;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.apache.isis.core.commons.matchers.IsisMatchers;
+import org.apache.isis.core.webserver.WebServer;
+import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.Rel;
+import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
+import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
+import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
+import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
+import org.apache.isis.viewer.restfulobjects.tck.Util;
+
+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.isLink;
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+
+public class Get_givenEntity_thenRepresentation_ofTitleIdLinksEtc_ok {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ private DomainObjectRepresentation domainObjectRepr;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Test
+ public void thenTitle_andExtensions_andLinks() throws Exception {
+
+ // when
+ final LinkRepresentation link = Util.serviceActionListInvokeFirstReference(client, "PrimitiveValuedEntities");
+ domainObjectRepr = client.follow(link).getEntity().as(DomainObjectRepresentation.class);
+
+ // then has domain type, instanceId, title
+ assertThat(domainObjectRepr, is(not(nullValue())));
+
+ assertThat(domainObjectRepr.getTitle(), is("Primitive Valued Entity #0")); // running in-memory
+ assertThat(domainObjectRepr.getDomainType(), is("PRMV"));
+ assertThat(domainObjectRepr.getInstanceId(), is(not(nullValue())));
+
+ // and then extensions
+ assertThat(domainObjectRepr.getExtensions().getString("oid"), IsisMatchers.startsWith("PRMV:" + domainObjectRepr.getInstanceId()));
+ assertThat(domainObjectRepr.getExtensions().getBoolean("isService"), is(false));
+ assertThat(domainObjectRepr.getExtensions().getBoolean("isPersistent"), is(true));
+
+ // and then has links
+ final LinkRepresentation self = domainObjectRepr.getSelf();
+ assertThat(self, isLink()
+ .rel(Rel.SELF)
+ .href(matches(".+\\/objects\\/PRMV\\/\\d+"))
+ .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.UPDATE),
+ isLink()
+ .href(matches(".+\\/objects\\/PRMV\\/\\d+"))
+ .httpMethod(RestfulHttpMethod.PUT)
+ .type(RepresentationType.DOMAIN_OBJECT.getMediaType()));
+ assertThat(domainObjectRepr.getLinkWithRel(Rel.ICON),
+ is(nullValue()));
+
+ }
+
+
+}