You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2013/04/27 20:31:26 UTC
[07/50] [abbrv] ISIS-233-ro: testing domainservices_services resource
http://git-wip-us.apache.org/repos/asf/isis/blob/1b9a2a74/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/domainService/DomainServiceResourceTest_services_representation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/domainService/DomainServiceResourceTest_services_representation.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/domainService/DomainServiceResourceTest_services_representation.java
deleted file mode 100644
index 5dae3b8..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/domainService/DomainServiceResourceTest_services_representation.java
+++ /dev/null
@@ -1,137 +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.resources.domainService;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.endsWith;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status.Family;
-
-import org.apache.isis.core.webserver.WebServer;
-import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.Rel;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.hamcrest.Matchers;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class DomainServiceResourceTest_services_representation {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private DomainServiceResource resource;
-
- @Before
- public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
-
- resource = client.getDomainServiceResource();
- }
-
- @Test
- public void representation() throws Exception {
-
- // when
- final Response response = resource.services();
- final RestfulResponse<ListRepresentation> restfulResponse = RestfulResponse.ofT(response);
-
- // then
- final ListRepresentation repr = restfulResponse.getEntity();
-
- assertThat(repr, isMap());
-
- assertThat(repr.getSelf(), isLink(client)
- .rel(Rel.SELF)
- .href(endsWith(":39393/services"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.LIST.getMediaType())
- .returning(HttpStatusCode.OK)
- );
- assertThat(repr.getUp(), isLink(client)
- .rel(Rel.UP)
- .href(endsWith(":39393/"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.HOME_PAGE.getMediaType())
- .returning(HttpStatusCode.OK)
- );
-
- assertThat(repr.getValue(), isArray());
-
- assertThat(repr.getLinks(), isArray());
- assertThat(repr.getExtensions(), isMap());
- }
-
- @Test
- public void linksToDomainServiceResources() throws Exception {
-
- // given
- final ListRepresentation repr = givenRepresentation();
-
- // when
- final JsonRepresentation values = repr.getValue();
-
- // then
- for (final LinkRepresentation link : values.arrayIterable(LinkRepresentation.class)) {
- assertThat("HiddenRepository should not show up in services list", false, is(link.getHref().endsWith("HiddenRepository")));
- }
-
- // and also
- for (final LinkRepresentation link : values.arrayIterable(LinkRepresentation.class)) {
-
- assertThat(link, isLink(client)
- .rel(containsString(Rel.SERVICE.getName()))
- .href(endsWith(":39393/"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.HOME_PAGE.getMediaType())
- .returning(HttpStatusCode.OK)
- .responseEntityWithSelfHref(link.getHref())
- );
- }
- }
-
- private ListRepresentation givenRepresentation() throws JsonParseException, JsonMappingException, IOException {
- final RestfulResponse<ListRepresentation> jsonResp = RestfulResponse.ofT(resource.services());
- return jsonResp.getEntity();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/1b9a2a74/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/domainService/DomainServiceResourceTest_services_responseHeaders.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/domainService/DomainServiceResourceTest_services_responseHeaders.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/domainService/DomainServiceResourceTest_services_responseHeaders.java
deleted file mode 100644
index 499ff45..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/domainService/DomainServiceResourceTest_services_responseHeaders.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.resources.domainService;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasMaxAge;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasParameter;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasSubType;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasType;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.isis.core.webserver.WebServer;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.Header;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class DomainServiceResourceTest_services_responseHeaders {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private DomainServiceResource resource;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
- resource = client.getDomainServiceResource();
- }
-
-
- @Test
- public void contentType_and_cacheControl() throws Exception {
- // given
- final Response resp = resource.services();
-
- // when
- final RestfulResponse<ListRepresentation> restfulResponse = RestfulResponse.ofT(resp);
-
- // then
- final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
- assertThat(contentType, hasType("application"));
- assertThat(contentType, hasSubType("json"));
- assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/list"));
- assertThat(contentType, is(RepresentationType.LIST.getMediaType()));
-
- // then
- final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
- assertThat(cacheControl, hasMaxAge(24 * 60 * 60));
- assertThat(cacheControl.getMaxAge(), is(24 * 60 * 60));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/1b9a2a74/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/domainService/DomainServiceResourceTest_services_xrofollowlinks.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/domainService/DomainServiceResourceTest_services_xrofollowlinks.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/domainService/DomainServiceResourceTest_services_xrofollowlinks.java
deleted file mode 100644
index a50a2da..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/domainService/DomainServiceResourceTest_services_xrofollowlinks.java
+++ /dev/null
@@ -1,122 +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.resources.domainService;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.junit.Assert.assertThat;
-
-import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.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.RestfulRequest.RequestParameter;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class DomainServiceResourceTest_services_xrofollowlinks {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
-
- private RestfulRequest request;
- private RestfulResponse<UserRepresentation> restfulResponse;
- private UserRepresentation repr;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
-
- }
-
- @Test
- public void noFollow() throws Exception {
-
- request = client.createRequest(RestfulHttpMethod.GET, "user");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- assertThat(repr.getSelf().getValue(), is(nullValue()));
- assertThat(repr.getUp().getValue(), is(nullValue()));
- }
-
- @Test
- public void self() throws Exception {
-
- request = client.createRequest(RestfulHttpMethod.GET, "user")
- .withArg(RequestParameter.FOLLOW_LINKS, "links[rel=" + Rel.SELF.getName() + "]");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- assertThat(repr.getSelf().getValue(), is(not(nullValue())));
- }
-
- @Test
- public void up() throws Exception {
-
- request = client.createRequest(RestfulHttpMethod.GET, "user")
- .withArg(RequestParameter.FOLLOW_LINKS, "links[rel=" + Rel.UP.getName() + "]");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- assertThat(repr.getUp().getValue(), is(not(nullValue())));
- }
-
-
- // TODO: split up this test?
- @Test
- public void services_withFollowLinks() throws Exception {
-
- RestfulRequest request;
- RestfulResponse<ListRepresentation> restfulResponse;
- ListRepresentation repr;
-
- request = client.createRequest(RestfulHttpMethod.GET, "services");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- assertThat(repr.getValue(), isArray());
- assertThat(repr.getValue().size(), is(greaterThan(0)));
- assertThat(repr.getValue().arrayGet(0), isLink().novalue());
-
- request = client.createRequest(RestfulHttpMethod.GET, "services")
- .withArg(RequestParameter.FOLLOW_LINKS, "value");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- assertThat(repr.getValue().arrayGet(0), isLink().value(is(not(nullValue(JsonRepresentation.class)))));
- assertThat(repr.getValue().arrayGet(0).getRepresentation("value"), isMap());
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/1b9a2a74/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_acceptHeader.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_acceptHeader.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_acceptHeader.java
deleted file mode 100644
index b05aed1..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_acceptHeader.java
+++ /dev/null
@@ -1,106 +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.resources.home;
-
-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.homepage.HomePageRepresentation;
-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 HomePageResourceTest_acceptHeader {
-
- @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, "/");
- }
-
- @Test
- public void applicationJson_noProfile_returns200() throws Exception {
-
- request.withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- assertThat(restfulResponse.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.HOME_PAGE.getMediaType()));
- }
-
- @Test
- public void applicationJson_profileHomePage_returns200() throws Exception {
-
- request.withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.HOME_PAGE.getMediaType());
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void missingHeader_returns200() throws Exception {
-
- final RestfulResponse<HomePageRepresentation> restfulResp = request.executeT();
-
- assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_profileIncorrect_returns406() throws Exception {
-
- request.withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
- }
-
- @Test
- public void incorrectMediaType_returnsNotAcceptable() throws Exception {
-
- // given
- final ClientRequest clientRequest = client.getClientRequestFactory().createRelativeRequest("/");
- clientRequest.accept(MediaType.APPLICATION_ATOM_XML_TYPE);
-
- // when
- final ClientResponse<?> resp = clientRequest.get();
- final RestfulResponse<JsonRepresentation> restfulResp = RestfulResponse.of(resp);
-
- // then
- assertThat(restfulResp.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/1b9a2a74/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_representation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_representation.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_representation.java
deleted file mode 100644
index b8221b1..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_representation.java
+++ /dev/null
@@ -1,111 +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.resources.home;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.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.apache.isis.viewer.restfulobjects.applib.Rel;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageResource;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class HomePageResourceTest_representation {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private HomePageResource resource;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
- resource = client.getHomePageResource();
- }
-
- @Test
- public void representation() throws Exception {
-
- // given
- final Response resp = resource.homePage();
-
- // when
- final RestfulResponse<HomePageRepresentation> restfulResponse = RestfulResponse.ofT(resp);
- assertThat(restfulResponse.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- // then
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
-
- final HomePageRepresentation repr = restfulResponse.getEntity();
- assertThat(repr, is(not(nullValue())));
- assertThat(repr, isMap());
-
- assertThat(repr.getSelf(), isLink(client)
- .rel(Rel.SELF)
- .href(endsWith(":39393/"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.HOME_PAGE.getMediaType())
- .returning(HttpStatusCode.OK)
- );
- assertThat(repr.getUser(), isLink(client)
- .rel(Rel.USER)
- .href(endsWith(":39393/user"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.USER.getMediaType())
- .returning(HttpStatusCode.OK)
- );
- assertThat(repr.getServices(), isLink(client)
- .rel(Rel.SERVICES)
- .href(endsWith(":39393/services"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.LIST.getMediaType())
- .returning(HttpStatusCode.OK)
- );
- assertThat(repr.getVersion(), isLink(client)
- .rel(Rel.VERSION)
- .href(endsWith(":39393/version"))
- .httpMethod(RestfulHttpMethod.GET)
- .type(RepresentationType.VERSION.getMediaType())
- .returning(HttpStatusCode.OK)
- );
-
- assertThat(repr.getLinks(), isArray());
- assertThat(repr.getExtensions(), isMap());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/1b9a2a74/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_responseHeaders.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_responseHeaders.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_responseHeaders.java
deleted file mode 100644
index f4d8231..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_responseHeaders.java
+++ /dev/null
@@ -1,79 +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.resources.home;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasMaxAge;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasParameter;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasSubType;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.hasType;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.Header;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageResource;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class HomePageResourceTest_responseHeaders {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private HomePageResource resource;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
- resource = client.getHomePageResource();
- }
-
-
- @Test
- public void contentType_and_cacheControl() throws Exception {
- // given
- final Response resp = resource.homePage();
-
- // when
- final RestfulResponse<HomePageRepresentation> restfulResponse = RestfulResponse.ofT(resp);
-
- // then
- final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
- assertThat(contentType, hasType("application"));
- assertThat(contentType, hasSubType("json"));
- assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects:repr-types/homepage"));
- assertThat(contentType, is(RepresentationType.HOME_PAGE.getMediaType()));
-
- // then
- final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
- assertThat(cacheControl, hasMaxAge(24 * 60 * 60));
- assertThat(cacheControl.getMaxAge(), is(24 * 60 * 60));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/1b9a2a74/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java
deleted file mode 100644
index 4af1ad0..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/home/HomePageResourceTest_xrofollowlinks.java
+++ /dev/null
@@ -1,168 +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.resources.home;
-
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.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.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.RestfulRequest.RequestParameter;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class HomePageResourceTest_xrofollowlinks {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
-
- private RestfulRequest request;
- private RestfulResponse<HomePageRepresentation> restfulResponse;
- private HomePageRepresentation repr;
-
- @Before
- public void setUp() throws Exception {
- client = webServerRule.getClient();
-
- }
-
- @Test
- public void noFollow() throws Exception {
- request = client.createRequest(RestfulHttpMethod.GET, "");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- assertThat(repr.getSelf().getValue(), is(nullValue()));
- assertThat(repr.getUser().getValue(), is(nullValue()));
- assertThat(repr.getVersion().getValue(), is(nullValue()));
- assertThat(repr.getServices().getValue(), is(nullValue()));
- }
-
- @Test
- public void self() throws Exception {
-
- repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SELF.getName() + "]");
-
- assertThat(repr.getSelf().getValue(), is(not(nullValue())));
- }
-
- @Test
- public void user() throws Exception {
-
- repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.USER.getName() + "]");
-
- assertThat(repr.getUser().getValue(), is(not(nullValue())));
- }
-
- @Test
- public void services() throws Exception {
-
- repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SERVICES.getName() + "]");
-
- assertThat(repr.getServices().getValue(), is(not(nullValue())));
- }
-
- @Test
- public void version() throws Exception {
-
- repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.VERSION.getName() + "]");
-
- assertThat(repr.getVersion().getValue(), is(not(nullValue())));
- }
-
- @Test
- public void multiple() throws Exception {
-
- repr = whenExecuteAndFollowLinksUsing("/",
- "links[rel=" + Rel.USER.getName() + "]," +
- "links[rel=" + Rel.SERVICES.getName() + "]," +
- "links[rel=" + Rel.VERSION.getName() + "]");
-
- assertThat(repr.getServices().getValue(), is(not(nullValue())));
- assertThat(repr.getUser().getValue(), is(not(nullValue())));
- assertThat(repr.getVersion().getValue(), is(not(nullValue())));
- }
-
- @Test
- public void allServices_Value() throws Exception {
-
- repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SERVICES.getName() + "].value");
-
- final JsonRepresentation servicesValue = repr.getServices().getValue();
- assertThat(servicesValue, is(not(nullValue())));
- assertThat(servicesValue, isMap());
- final JsonRepresentation serviceLinkList = servicesValue.getArray("value");
- assertThat(serviceLinkList, isArray());
-
- JsonRepresentation service;
-
- service = serviceLinkList.getRepresentation("[rel=%s;serviceId=\"%s\"]", Rel.SERVICE.getName(), "JdkValuedEntities");
- assertThat(service, isMap());
- assertThat(service.getRepresentation("value"), is(not(nullValue())));
-
- service = serviceLinkList.getRepresentation("[rel=%s;serviceId=\"%s\"]", Rel.SERVICE.getName(), "WrapperValuedEntities");
- assertThat(service, isMap());
- assertThat(service.getRepresentation("value"), is(not(nullValue())));
- }
-
- @Test
- public void selectedService_Value() throws Exception {
-
- repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SERVICES.getName() + "].value[rel=" + Rel.SERVICE.andParam("serviceId", "WrapperValuedEntities")+"]");
-
- final JsonRepresentation servicesValue = repr.getServices().getValue();
- assertThat(servicesValue, is(not(nullValue())));
- assertThat(servicesValue, isMap());
- final JsonRepresentation serviceLinkList = servicesValue.getArray("value");
- assertThat(serviceLinkList, isArray());
-
- JsonRepresentation service;
-
- service = serviceLinkList.getRepresentation("[rel=%s;serviceId=\"%s\"]", Rel.SERVICE.getName(), "WrapperValuedEntities");
- assertThat(service, isMap());
- assertThat(service.getRepresentation("value"), is(not(nullValue())));
-
- service = serviceLinkList.getRepresentation("[rel=%s;serviceId=\"%s\"]", Rel.SERVICE.getName(), "JdkValuedEntities");
- assertThat(service.getRepresentation("value"), is(nullValue()));
- }
-
- private HomePageRepresentation whenExecuteAndFollowLinksUsing(final String uriTemplate, final String followLinks) throws JsonParseException, JsonMappingException, IOException {
- request = client.createRequest(RestfulHttpMethod.GET, uriTemplate).withArg(RequestParameter.FOLLOW_LINKS, followLinks);
- restfulResponse = request.executeT();
- return restfulResponse.getEntity();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/1b9a2a74/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/object/DomainObjectResourceTest.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/object/DomainObjectResourceTest.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/object/DomainObjectResourceTest.java
deleted file mode 100644
index 23df8f8..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/object/DomainObjectResourceTest.java
+++ /dev/null
@@ -1,401 +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.resources.object;
-
-import static org.apache.isis.core.commons.matchers.IsisMatchers.matches;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.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 static org.junit.Assert.fail;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.MediaType;
-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.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.tck.dom.refs.BidirWithSetChildEntity;
-import org.apache.isis.core.tck.dom.scalars.ApplibValuedEntity;
-import org.apache.isis.core.tck.dom.scalars.ApplibValuedEntityRepository;
-import org.apache.isis.core.webserver.WebServer;
-import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.LinkRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.Rel;
-import org.apache.isis.viewer.restfulobjects.applib.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.domainobjects.ActionResultRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectPropertyRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ScalarValueRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ActionResultRepresentation.ResultType;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-
-public class DomainObjectResourceTest {
-
- @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());
- }
-
- @Test
- public void returnsDomainObjectRepresentation() throws Exception {
-
- // given
- final DomainObjectResource domainObjectResource = client.getDomainObjectResource();
-
- // when
- final Response domainObjectResp = domainObjectResource.object("OID","6");
- final RestfulResponse<DomainObjectRepresentation> domainObjectJsonResp = RestfulResponse.ofT(domainObjectResp);
- assertThat(domainObjectJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- // then
- final DomainObjectRepresentation domainObjectRepr = domainObjectJsonResp.getEntity();
- assertThat(domainObjectRepr, is(not(nullValue())));
- }
-
- @Test
- public void domainObjectRepresentationForPersistentObject_hasSelfAndOid() throws Exception {
-
- // given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
-
- // then
- final LinkRepresentation self = domainObjectRepr.getSelf();
- assertThat(self, isLink().rel(Rel.SELF).href(matches(".+objects/OID/32")).httpMethod(RestfulHttpMethod.GET).type(MediaType.APPLICATION_JSON_TYPE).typeParameter("profile", "urn:org.restfulobjects/domainobject"));
- assertThat(domainObjectRepr.getLinkWithRel(Rel.DESCRIBEDBY), isLink().href(matches(".+" + BidirWithSetChildEntity.class.getName())).httpMethod(RestfulHttpMethod.GET).type(MediaType.APPLICATION_JSON_TYPE).typeParameter("profile", "urn:org.restfulobjects/domaintype"));
-
- assertThat(domainObjectRepr.getTitle(), is("parent 4 - child 2"));
- assertThat(domainObjectRepr.getOid(), is("OID:32"));
-
- // no icon
- final LinkRepresentation selfIcon = domainObjectRepr.getLinkWithRel(Rel.ICON);
- assertThat(selfIcon, is(nullValue()));
- }
-
- @Test
- public void domainObjectRepresentationForTransient_hasNoSelf_andHasNoOid() throws Exception {
-
- // given, when
- final RestfulRequest request = this.client.createRequest(RestfulHttpMethod.POST, "services/simples/actions/newTransientEntity/invoke");
- final RestfulResponse<ActionResultRepresentation> response = request.executeT();
- final ActionResultRepresentation actionResultRepr = response.getEntity();
- assertThat(actionResultRepr.getResultType(), is(ResultType.DOMAIN_OBJECT));
- assertThat(actionResultRepr.getResult(), is(not(nullValue())));
-
- final DomainObjectRepresentation domainObjectRepr = actionResultRepr.getResult().as(DomainObjectRepresentation.class);
-
- // then
- final LinkRepresentation self = domainObjectRepr.getSelf();
- assertThat(self, is(nullValue()));
-
- assertThat(domainObjectRepr.getOid(), is(nullValue()));
- }
-
- @Test
- public void domainObjectRepresentation_hasTitle() throws Exception {
-
- // given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
-
- // then
- assertThat(domainObjectRepr.getTitle(), is("parent 4 - child 2"));
- }
-
- @Test
- public void domainObjectRepresentation_hasDescribedByLink() throws Exception {
-
- // given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
-
- // then
- assertThat(domainObjectRepr.getLinkWithRel(Rel.DESCRIBEDBY), isLink().href(matches(".+" + BidirWithSetChildEntity.class.getName())).httpMethod(RestfulHttpMethod.GET).type(MediaType.APPLICATION_JSON_TYPE).typeParameter("profile", "urn:org.restfulobjects/domaintype"));
- }
-
- @Test
- public void domainObjectRepresentation_noIcon() throws Exception {
-
- // given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
-
- // then
- final LinkRepresentation selfIcon = domainObjectRepr.getLinkWithRel(Rel.ICON);
- assertThat(selfIcon, is(nullValue()));
- }
-
- @Ignore("TODO")
- @Test
- public void domainObjectWithIcon() throws Exception {
-
- // given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","xxx");
-
- // icon
- final LinkRepresentation selfIcon = domainObjectRepr.getLinkWithRel(Rel.ICON);
- assertThat(selfIcon, isLink().href(matches(".+" + "/images/" + "null\\.png")).httpMethod(RestfulHttpMethod.GET));
-
- }
-
- @Test
- public void domainObjectRepresentationContent_Properties() throws Exception {
-
- // given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
- final LinkRepresentation self = domainObjectRepr.getSelf();
-
- // then properties
- final JsonRepresentation properties = domainObjectRepr.getProperties();
- assertThat(properties.size(), is(2));
-
- // property ('name')
- final JsonRepresentation nameProperty = properties.getRepresentation("[id=name]");
- assertThat(nameProperty.getString("memberType"), is("property"));
- assertThat(nameProperty.getString("value"), is("child 2"));
- assertThat(nameProperty.getString("disabledReason"), is(nullValue()));
-
- final LinkRepresentation namePropertyDetails = nameProperty.getLink("links[rel=details]");
- assertThat(namePropertyDetails, isLink().rel("details").href(self.getHref() + "/properties/name").httpMethod(RestfulHttpMethod.GET));
-
- }
-
- @Ignore("todo")
- @Test
- public void domainObjectRepresentationContent_Collections() throws Exception {
-
- // given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
-
- // then collections
-
- }
-
- @Ignore("TODO")
- @Test
- public void domainObjectRepresentationContent() throws Exception {
-
- // given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","32");
- final LinkRepresentation self = domainObjectRepr.getSelf();
-
- // then actions
- final JsonRepresentation actions = domainObjectRepr.getActions();
- assertThat(actions.size(), is(2));
-
- final JsonRepresentation listAction = actions.getRepresentation("list");
- assertThat(listAction.getString("memberType"), is("action"));
- assertThat(listAction.getString("actionId"), is("list"));
- assertThat(listAction.getString("actionType"), is("USER"));
- assertThat(listAction.getInt("numParameters"), is(0));
-
- final LinkRepresentation listActionType = listAction.getLink("type");
- assertThat(listActionType.getRel(), is("type"));
- assertThat(listActionType.getHref(), matches(".+vnd\\.list\\+json"));
- assertThat(listActionType.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- final LinkRepresentation listActionDetails = listAction.getLink("details");
- assertThat(listActionDetails.getRel(), is("action"));
- assertThat(listActionDetails.getHref(), is(self.getHref() + "/actions/list"));
- assertThat(listActionDetails.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- final JsonRepresentation newEntityAction = actions.getRepresentation("newEntity");
- assertThat(newEntityAction.getString("memberType"), is("action"));
- assertThat(newEntityAction.getString("actionType"), is("USER"));
- assertThat(newEntityAction.getInt("numParameters"), is(0));
-
- final LinkRepresentation newEntityActionType = newEntityAction.getLink("type");
- assertThat(newEntityActionType.getRel(), is("type"));
- assertThat(newEntityActionType.getHref(), matches(".+vnd\\." + ApplibValuedEntity.class.getName() + "\\+json"));
- assertThat(newEntityActionType.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- final LinkRepresentation newEntityActionDetails = newEntityAction.getLink("details");
- assertThat(newEntityActionDetails.getRel(), is("action"));
- assertThat(newEntityActionDetails.getHref(), is(self.getHref() + "/actions/newEntity"));
- assertThat(newEntityActionDetails.getHttpMethod(), is(RestfulHttpMethod.GET));
- }
-
- @Ignore("TODO")
- @Test
- public void domainObjectWithDisabledMembers() throws Exception {
-
- // given, when
- final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID","xxx");
-
- // property ('name')
- final JsonRepresentation properties = domainObjectRepr.getProperties();
- final JsonRepresentation nameProperty = properties.getRepresentation("name");
- assertThat(nameProperty.getString("disabledReason"), is(not(nullValue())));
- }
-
- @Ignore("to get working again")
- @Test
- public void propertyDetails() throws Exception {
- // given
- final DomainObjectResource domainObjectResource = client.getDomainObjectResource();
-
- // when
- final Response idPropertyResp = domainObjectResource.propertyDetails("OID","1", "id");
- final RestfulResponse<ObjectPropertyRepresentation> idPropertyJsonResp = RestfulResponse.ofT(idPropertyResp);
- assertThat(idPropertyJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- // then
- final ObjectPropertyRepresentation propertyDetailsRepr = idPropertyJsonResp.getEntity();
-
- // _self.link
- final LinkRepresentation selfLink = propertyDetailsRepr.getLink("_self.link");
- assertThat(selfLink.getRel(), is("member"));
- assertThat(selfLink.getHref(), matches(".+objects/OID:1/properties/id"));
- assertThat(selfLink.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- // _self.object
- final LinkRepresentation selfObject = propertyDetailsRepr.getLink("_self.object");
- assertThat(selfObject.getRel(), is("object"));
- assertThat(selfObject.getHref(), matches(".+objects/OID:1"));
- assertThat(selfObject.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- // type
- final LinkRepresentation type = propertyDetailsRepr.getLink("type");
- assertThat(type.getRel(), is("type"));
- assertThat(type.getHref(), matches(".+vnd\\.string\\+json"));
- assertThat(type.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- assertThat(propertyDetailsRepr.getString("memberType"), is("property"));
- assertThat(propertyDetailsRepr.getString("value"), is(ApplibValuedEntityRepository.class.getName()));
- assertThat(propertyDetailsRepr.getString("disabledReason"), is(not(nullValue())));
- }
-
- @Ignore("to get working again")
- @Test
- public void actionPrompt() throws Exception {
- // given
- final DomainObjectResource domainObjectResource = client.getDomainObjectResource();
-
- // when
- final Response actionPromptResp = domainObjectResource.actionPrompt("OID","1", "list");
- final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp);
- assertThat(actionPromptJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- // then
- final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity();
-
- // _self.link
- final LinkRepresentation selfLink = actionPromptRepr.getLink("_self.link");
- assertThat(selfLink.getRel(), is("member"));
- assertThat(selfLink.getHref(), matches(".+objects/OID:1/actions/list"));
- assertThat(selfLink.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- // _self.object
- final LinkRepresentation selfObject = actionPromptRepr.getLink("_self.object");
- assertThat(selfObject.getRel(), is("object"));
- assertThat(selfObject.getHref(), matches(".+objects/OID:1"));
- assertThat(selfObject.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- // type
- final LinkRepresentation type = actionPromptRepr.getLink("type");
- assertThat(type.getRel(), is("type"));
- assertThat(type.getHref(), matches(".+vnd\\.list\\+json"));
- assertThat(type.getHttpMethod(), is(RestfulHttpMethod.GET));
-
- assertThat(actionPromptRepr.getString("memberType"), is("action"));
- assertThat(actionPromptRepr.getString("actionType"), is("USER"));
- assertThat(actionPromptRepr.getInt("numParameters"), is(0));
- assertThat(actionPromptRepr.getArray("parameters").size(), is(0));
-
- final LinkRepresentation invokeLink = actionPromptRepr.getLink("invoke");
- assertThat(invokeLink.getRel(), is("invoke"));
- assertThat(invokeLink.getHref(), matches(".+objects/OID:1/actions/list/invoke"));
- assertThat(invokeLink.getHttpMethod(), is(RestfulHttpMethod.POST));
- assertThat(invokeLink.getArguments(), is(not(nullValue())));
- assertThat(invokeLink.getArguments().isArray(), is(true));
- assertThat(invokeLink.getArguments().size(), is(0));
- }
-
- @Ignore("TODO")
- @Test
- public void collectionDetails() throws Exception {
- fail();
- }
-
- @Ignore("to get working again")
- @Test
- public void actionPostInvoke_returningList() throws Exception {
-
- // given
- final DomainObjectResource domainObjectResource = client.getDomainObjectResource();
-
- final JsonRepresentation body = JsonRepresentation.newArray();
-
- // when
- final Response actionInvokeResp = domainObjectResource.invokeAction("OID","1", "list", body.asInputStream());
- final RestfulResponse<ScalarValueRepresentation> actionInvokeJsonResp = RestfulResponse.ofT(actionInvokeResp);
- assertThat(actionInvokeJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- // then
- final ScalarValueRepresentation actionInvokeRepr = actionInvokeJsonResp.getEntity();
- assertThat(actionInvokeRepr.isArray(), is(true));
- assertThat(actionInvokeRepr.size(), is(5));
-
- final JsonRepresentation domainObjectRefRepr = actionInvokeRepr.arrayGet(0);
-
- assertThat(domainObjectRefRepr, is(not(nullValue())));
- assertThat(domainObjectRefRepr.getString("title"), is("Untitled Applib Values Entity")); // TODO
-
- final LinkRepresentation domainObjectLink = domainObjectRefRepr.getLink("link");
- assertThat(domainObjectLink.getRel(), is("object"));
- assertThat(domainObjectLink.getHref(), matches("http://localhost:\\d+/objects/OID:7"));
-
- final LinkRepresentation domainObjectTypeLink = domainObjectRefRepr.getLink("type");
- assertThat(domainObjectTypeLink.getRel(), is("type"));
- assertThat(domainObjectTypeLink.getHref(), matches("http://localhost:\\d+/types/application/vnd." + org.apache.isis.core.tck.dom.scalars.ApplibValuedEntity.class.getName() + "\\+json"));
-
- final LinkRepresentation domainObjectIconLink = domainObjectRefRepr.getLink("icon");
- assertThat(domainObjectIconLink.getRel(), is("icon"));
- assertThat(domainObjectIconLink.getHref(), matches("http://localhost:\\d+/images/null.png")); // TODO
- }
-
- 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));
-
- final DomainObjectRepresentation domainObjectRepr = domainObjectJsonResp.getEntity();
- return domainObjectRepr;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/1b9a2a74/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java
deleted file mode 100644
index 913867e..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/invoke/DomainServiceResourceTest_invokeAction.java
+++ /dev/null
@@ -1,265 +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.resources.service.invoke;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.Response;
-
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.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.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.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.HttpStatusCode;
-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.ObjectActionRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ScalarValueRepresentation;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-
-public class DomainServiceResourceTest_invokeAction {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
-
- @SuppressWarnings("unused")
- private DomainServiceResource resource;
-
- @Before
- public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
-
- resource = client.getDomainServiceResource();
- }
-
- @Ignore("TODO - fix broken test resulting from introduction of actionresult repr")
- @Test
- public void invokeQueryOnly_noArg_usingClientFollow() throws Exception {
-
- // given
- final JsonRepresentation givenAction = givenAction("simples", "list");
- final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
-
- // when
- final LinkRepresentation invokeLink = actionRepr.getInvoke();
-
- // then
- assertThat(invokeLink, is(not(nullValue())));
- final RestfulResponse<ListRepresentation> restfulResponse = client.followT(invokeLink);
- final ListRepresentation listRepr = restfulResponse.getEntity();
-
- assertThat(listRepr.getValue().size(), is(5));
- }
-
- @Ignore("TODO - fix broken test resulting from introduction of actionresult repr")
- @Test
- public void invokeIdempotent_withArgs_usingClientFollow() throws Exception {
-
- // given action
- final JsonRepresentation givenAction = givenAction("simples", "newPersistentEntity");
- final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
-
- // when
- final LinkRepresentation invokeLink = actionRepr.getInvoke();
-
- // then
- assertThat(invokeLink, is(not(nullValue())));
-
- final JsonRepresentation args = invokeLink.getArguments();
- assertThat(args.size(), is(2));
- assertThat(args.mapHas("name"), is(true));
- assertThat(args.mapHas("flag"), is(true));
-
- // when
- args.mapPut("name", "New Name");
- args.mapPut("flag", true);
- final RestfulResponse<DomainObjectRepresentation> restfulResponse = client.followT(invokeLink, args);
-
- // then
- final DomainObjectRepresentation objectRepr = restfulResponse.getEntity();
-
- assertThat(objectRepr.getProperty("name").getString("value"), is("New Name"));
- assertThat(objectRepr.getProperty("flag").getBoolean("value"), is(true));
- }
-
- @Ignore("TODO - fix broken test resulting from introduction of actionresult repr")
- @Test
- public void invoke_returningScalar_withReferenceArgs_usingClientFollow() throws Exception {
-
- // given action
- final JsonRepresentation givenAction = givenAction("simples", "count");
- final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
-
- // when
- final LinkRepresentation invokeLink = actionRepr.getInvoke();
-
- // then
- assertThat(invokeLink, is(not(nullValue())));
- final JsonRepresentation args = invokeLink.getArguments();
- assertThat(args.size(), is(0));
-
- // when
- final RestfulResponse<ScalarValueRepresentation> restfulResponse = client.followT(invokeLink, args);
-
- // then
- final ScalarValueRepresentation objectRepr = restfulResponse.getEntity();
-
- assertThat(objectRepr.getValue().asInt(), is(6));
- }
-
- @Ignore("TODO - fix broken test resulting from introduction of actionresult repr")
- @Test
- public void invokeNonIdempotent_returningVoid_withReferenceArgs_usingClientFollow() throws Exception {
-
- // given simple entity with 'flag' property set to true
- final LinkRepresentation linkToSimpleEntity = givenLinkToSimpleEntity(0);
- final RestfulResponse<DomainObjectRepresentation> restfulResponseBefore = client.followT(linkToSimpleEntity);
- final DomainObjectRepresentation simpleEntityBefore = restfulResponseBefore.getEntity();
- final Boolean before = simpleEntityBefore.getProperty("flag").getBoolean("value");
-
- // and given 'toggle' action on repo
- final JsonRepresentation givenAction = givenAction("simples", "toggle");
- final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
-
- // when
- final LinkRepresentation invokeLink = actionRepr.getInvoke();
-
- // then
- assertThat(invokeLink, is(not(nullValue())));
-
- final JsonRepresentation args = invokeLink.getArguments();
- assertThat(args.size(), is(1));
- assertThat(args.mapHas("object"), is(true));
-
- // when
- args.mapPut("object", linkToSimpleEntity);
- final RestfulResponse<JsonRepresentation> restfulResponse = client.followT(invokeLink, args);
-
- // then
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NO_CONTENT));
-
- // and then simple entity 'flag' property set to false
- final RestfulResponse<DomainObjectRepresentation> restfulResponseAfter = client.followT(linkToSimpleEntity);
- final DomainObjectRepresentation simpleEntityAfter = restfulResponseAfter.getEntity();
-
- final Boolean after = simpleEntityAfter.getProperty("flag").getBoolean("value");
- assertThat(after, is(!before)); // ie has been toggled
- }
-
- @org.junit.Ignore("up to here")
- @Test
- public void invoke_withAllBuiltInArgs_usingClientFollow() throws Exception {
-
- // given simple entity with 'flag' property set to true
- final LinkRepresentation linkToSimpleEntity = givenLinkToSimpleEntity(0);
-
- // given
- final JsonRepresentation givenAction = givenAction("simples", "update");
- final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
-
- // when
- final LinkRepresentation invokeLink = actionRepr.getInvoke();
-
- // then
- assertThat(invokeLink, is(not(nullValue())));
-
- final JsonRepresentation args = invokeLink.getArguments();
- assertThat(args.size(), is(0));
- assertThat(args.mapHas("object"), is(true));
- assertThat(args.mapHas("name"), is(true));
- assertThat(args.mapHas("flag"), is(true));
- assertThat(args.mapHas("Boolean"), is(true));
- assertThat(args.mapHas("int"), is(true));
- assertThat(args.mapHas("integer"), is(true));
- assertThat(args.mapHas("long1"), is(true));
- assertThat(args.mapHas("long2"), is(true));
- assertThat(args.mapHas("double1"), is(true));
- assertThat(args.mapHas("double2"), is(true));
- assertThat(args.mapHas("bigInteger"), is(true));
- assertThat(args.mapHas("bigDecimal"), is(true));
-
- // when
- args.mapPut("name", "New Name");
- args.mapPut("flag", true);
- final RestfulResponse<DomainObjectRepresentation> restfulResponse = client.followT(invokeLink, args);
-
- // then
- final DomainObjectRepresentation objectRepr = restfulResponse.getEntity();
-
- assertThat(objectRepr.getRepresentation("members[propertyId=%s].value", "name").asString(), is("New Name"));
- assertThat(objectRepr.getRepresentation("members[propertyId=%s].value", "flag").asBoolean(), is(true));
- }
-
- private JsonRepresentation givenAction(final String serviceId, final String actionId) throws JsonParseException, JsonMappingException, IOException {
- final String href = givenHrefToService(serviceId);
-
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, href).withArg(RequestParameter.FOLLOW_LINKS, "members[id=%s].links[rel=details]", actionId);
- 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=details].value");
- }
-
- private String givenHrefToService(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("values[id=%s]", serviceId).asLink().getHref();
- }
-
- private LinkRepresentation givenLinkToSimpleEntity(final int num) throws JsonParseException, JsonMappingException, IOException, Exception {
- // given
- final JsonRepresentation givenAction = givenAction("simples", "list");
- final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);
-
- // when
- final LinkRepresentation invokeLink = actionRepr.getInvoke();
-
- // then
- final RestfulResponse<ListRepresentation> restfulResponse = client.followT(invokeLink);
- final ListRepresentation listRepr = restfulResponse.getEntity();
-
- return listRepr.getValue().arrayGet(num).asLink();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/1b9a2a74/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_accept.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_accept.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_accept.java
deleted file mode 100644
index 730c0c2..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_accept.java
+++ /dev/null
@@ -1,102 +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.resources.service.serviceId;
-
-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.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.webserver.WebServer;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.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.tck.IsisWebServerRule;
-
-public class DomainServiceResourceTest_serviceId_accept {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
-
- @Before
- public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
- }
-
- @Test
- public void applicationJson() throws Exception {
-
- final String href = givenLinkToService();
-
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, href).withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
- final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_profileList() throws Exception {
-
- final String href = givenLinkToService();
-
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, href).withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.DOMAIN_OBJECT.getMediaType());
- final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_invalid() throws Exception {
-
- final String href = givenLinkToService();
-
- final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, href).withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
- final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
- }
-
- private String givenLinkToService() throws JsonParseException, JsonMappingException, IOException {
- final DomainServiceResource resource = client.getDomainServiceResource();
- final Response response = resource.services();
- final ListRepresentation services = RestfulResponse.<ListRepresentation> ofT(response).getEntity();
-
- final String href = services.getRepresentation("values[id=%s]", "simples").asLink().getHref();
- return href;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/1b9a2a74/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_notFound.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_notFound.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_notFound.java
deleted file mode 100644
index 13b6aff..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_notFound.java
+++ /dev/null
@@ -1,65 +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.resources.service.serviceId;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-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.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.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-
-public class DomainServiceResourceTest_serviceId_notFound {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private DomainServiceResource resource;
-
- @Before
- public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
-
- resource = client.getDomainServiceResource();
- }
-
- @Test
- public void notFound() throws Exception {
-
- // when
- final Response resp = resource.service("nonExistentServiceId");
- final RestfulResponse<JsonRepresentation> jsonResp = RestfulResponse.of(resp);
-
- // then
- assertThat(jsonResp.getStatus(), is(HttpStatusCode.NOT_FOUND));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/1b9a2a74/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_representationAndHeaders.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_representationAndHeaders.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_representationAndHeaders.java
deleted file mode 100644
index b2cf19d..0000000
--- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_representationAndHeaders.java
+++ /dev/null
@@ -1,129 +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.resources.service.serviceId;
-
-import static org.apache.isis.core.commons.matchers.IsisMatchers.matches;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.assertThat;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isArray;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isFollowableLinkToSelf;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isLink;
-import static org.apache.isis.viewer.restfulobjects.tck.RepresentationMatchers.isMap;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.Response;
-
-import org.codehaus.jackson.JsonParseException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.isis.core.webserver.WebServer;
-import org.apache.isis.viewer.restfulobjects.applib.RepresentationType;
-import org.apache.isis.viewer.restfulobjects.applib.RestfulHttpMethod;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulClient;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse;
-import org.apache.isis.viewer.restfulobjects.applib.client.RestfulResponse.HttpStatusCode;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
-import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule;
-
-public class DomainServiceResourceTest_serviceId_representationAndHeaders {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private DomainServiceResource resource;
-
- @Before
- public void setUp() throws Exception {
- final WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
-
- resource = client.getDomainServiceResource();
- }
-
- @Test
- public void representation() throws Exception {
-
- // given
- final Response resp = resource.service("simples");
-
- // when
- final RestfulResponse<DomainObjectRepresentation> jsonResp = RestfulResponse.ofT(resp);
-
- // then
- assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
-
- final DomainObjectRepresentation repr = jsonResp.getEntity();
-
- assertThat(repr, isMap());
-
- assertThat(repr.getSelf(), isLink().httpMethod(RestfulHttpMethod.GET));
- assertThat(repr.getOid(), matches("OID[:].+"));
- assertThat(repr.getTitle(), matches("Simples"));
-
- assertThat(repr.getMembers(), isArray());
-
- assertThat(repr.getLinks(), isArray());
- assertThat(repr.getExtensions(), isMap());
- }
-
- @Test
- public void headers() throws Exception {
- // given
- final Response resp = resource.service("simples");
-
- // when
- final RestfulResponse<DomainObjectRepresentation> jsonResp = RestfulResponse.ofT(resp);
-
- // then
- assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
- assertThat(jsonResp.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.DOMAIN_OBJECT.getMediaType()));
- assertThat(jsonResp.getHeader(RestfulResponse.Header.CACHE_CONTROL).getMaxAge(), is(24 * 60 * 60));
- }
-
- @Test
- public void self_isFollowable() throws Exception {
- // given
- final DomainObjectRepresentation repr = givenRepresentation("simples");
-
- // when, then
- assertThat(repr, isFollowableLinkToSelf(client));
- }
-
- @Test
- public void links() throws Exception {
- // given, when
- final DomainObjectRepresentation repr = givenRepresentation("simples");
-
- // then
- assertThat(repr.getLinks().size(), is(3));
- }
-
- private DomainObjectRepresentation givenRepresentation(final String serviceId) throws JsonParseException, JsonMappingException, IOException {
- final RestfulResponse<DomainObjectRepresentation> jsonResp = RestfulResponse.ofT(resource.service(serviceId));
- return jsonResp.getEntity();
- }
-
-}