Repository: isis Updated Branches: refs/heads/master d79c49f0a -> 1838ede3c
ISIS-421: more 405 tests. Also, remove the DomainServiceResource#property and #collection. Project: http://git-wip-us.apache.org/repos/asf/isis/repo Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/1838ede3 Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/1838ede3 Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/1838ede3 Branch: refs/heads/master Commit: 1838ede3cfe3dfce24e83db226ecf9b606bb7f87 Parents: d79c49f Author: Dan Haywood <[email protected]> Authored: Fri Mar 28 13:47:12 2014 +0000 Committer: Dan Haywood <[email protected]> Committed: Fri Mar 28 13:47:12 2014 +0000 ---------------------------------------------------------------------- .../domainobjects/DomainServiceResource.java | 32 ++++----- .../DomainServiceResourceServerside.java | 44 ++++-------- ...ObjectResource_thenResponseCode_405_bad.java | 72 +++++++++++++++++++ ...erviceResource_thenResponseCode_405_bad.java | 74 ++++++++++++++++++++ .../action/Delete_thenResponseCode_405_bad.java | 72 ------------------- ...ObjectResource_thenResponseCode_405_bad.java | 72 +++++++++++++++++++ ...erviceResource_thenResponseCode_405_bad.java | 74 ++++++++++++++++++++ .../action/Post_thenResponseCode_405_bad.java | 72 ------------------- ...ObjectResource_thenResponseCode_405_bad.java | 72 +++++++++++++++++++ ...erviceResource_thenResponseCode_405_bad.java | 73 +++++++++++++++++++ .../id/action/Put_thenResponseCode_405_bad.java | 72 ------------------- 11 files changed, 464 insertions(+), 265 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/isis/blob/1838ede3/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainServiceResource.java ---------------------------------------------------------------------- diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainServiceResource.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainServiceResource.java index 819b633..772298d 100644 --- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainServiceResource.java +++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainServiceResource.java @@ -79,27 +79,7 @@ public interface DomainServiceResource { @Path("/{serviceId}") public Response postServiceNotAllowed(@PathParam("serviceId") final String serviceId); - // ////////////////////////////////////////////////////////// - // domain service property - // ////////////////////////////////////////////////////////// - - @GET - @Path("/{serviceId}/properties/{propertyId}") - @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_PROPERTY, RestfulMediaType.APPLICATION_JSON_ERROR }) - @ClientResponseType(entityType = String.class) - public Response propertyDetails(@PathParam("serviceId") final String serviceId, @PathParam("propertyId") final String propertyId); - - // ////////////////////////////////////////////////////////// - // domain service collection - // ////////////////////////////////////////////////////////// - - @GET - @Path("/{serviceId}/collections/{collectionId}") - @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_COLLECTION, RestfulMediaType.APPLICATION_JSON_ERROR }) - @ClientResponseType(entityType = String.class) - public Response accessCollection(@PathParam("serviceId") final String serviceId, @PathParam("collectionId") final String collectionId); - // ////////////////////////////////////////////////////////// // domain service action // ////////////////////////////////////////////////////////// @@ -110,6 +90,18 @@ public interface DomainServiceResource { @ClientResponseType(entityType = String.class) public Response actionPrompt(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId); + @DELETE + @Path("/{serviceId}/actions/{actionId}") + public Response deleteActionPromptNotAllowed(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId); + + @PUT + @Path("/{serviceId}/actions/{actionId}") + public Response putActionPromptNotAllowed(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId); + + @POST + @Path("/{serviceId}/actions/{actionId}") + public Response postActionPromptNotAllowed(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId); + // ////////////////////////////////////////////////////////// // domain service action invoke // ////////////////////////////////////////////////////////// http://git-wip-us.apache.org/repos/asf/isis/blob/1838ede3/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainServiceResourceServerside.java ---------------------------------------------------------------------- diff --git a/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainServiceResourceServerside.java b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainServiceResourceServerside.java index 91b01ac..4ea81e9 100644 --- a/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainServiceResourceServerside.java +++ b/component/viewer/restfulobjects/server/src/main/java/org/apache/isis/viewer/restfulobjects/server/resources/DomainServiceResourceServerside.java @@ -116,35 +116,6 @@ public class DomainServiceResourceServerside extends ResourceAbstract implements throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Posting to a service resource is not allowed."); } - // ////////////////////////////////////////////////////////// - // domain service property - // ////////////////////////////////////////////////////////// - - @Override - @GET - @Path("/{serviceId}/properties/{propertyId}") - @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_PROPERTY, RestfulMediaType.APPLICATION_JSON_ERROR }) - public Response propertyDetails(@PathParam("serviceId") final String serviceId, @PathParam("propertyId") final String propertyId) { - init(RepresentationType.OBJECT_PROPERTY, Where.OBJECT_FORMS); - - final ObjectAdapter serviceAdapter = getServiceAdapter(serviceId); - final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), serviceAdapter).using(new DomainServiceLinkTo()); - - return helper.propertyDetails(propertyId, MemberMode.NOT_MUTATING, Caching.ONE_DAY, getResourceContext().getWhere()); - } - - @Override - @GET - @Path("/{serviceId}/collections/{collectionId}") - @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_COLLECTION, RestfulMediaType.APPLICATION_JSON_ERROR }) - public Response accessCollection(@PathParam("serviceId") final String serviceId, @PathParam("collectionId") String collectionId) { - init(RepresentationType.OBJECT_COLLECTION, Where.PARENTED_TABLES); - - final ObjectAdapter serviceAdapter = getServiceAdapter(serviceId); - final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext(), serviceAdapter); - - return helper.collectionDetails(collectionId, MemberMode.NOT_MUTATING, Caching.NONE, getResourceContext().getWhere()); - } // ////////////////////////////////////////////////////////// // domain service action @@ -163,6 +134,21 @@ public class DomainServiceResourceServerside extends ResourceAbstract implements return helper.actionPrompt(actionId, getResourceContext().getWhere()); } + @Override + public Response deleteActionPromptNotAllowed(@PathParam("serviceId") String serviceId, @PathParam("actionId") String actionId) { + throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Deleting action prompt resource is not allowed."); + } + + @Override + public Response putActionPromptNotAllowed(@PathParam("serviceId") String serviceId, @PathParam("actionId") String actionId) { + throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Putting to an action prompt resource is not allowed."); + } + + @Override + public Response postActionPromptNotAllowed(@PathParam("serviceId") String serviceId, @PathParam("actionId") String actionId) { + throw RestfulObjectsApplicationException.createWithMessage(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED, "Posting to an action prompt resource is not allowed."); + } + // ////////////////////////////////////////////////////////// // domain service action invoke // ////////////////////////////////////////////////////////// http://git-wip-us.apache.org/repos/asf/isis/blob/1838ede3/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Delete_givenObjectResource_thenResponseCode_405_bad.java ---------------------------------------------------------------------- diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Delete_givenObjectResource_thenResponseCode_405_bad.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Delete_givenObjectResource_thenResponseCode_405_bad.java new file mode 100644 index 0000000..13cbdc3 --- /dev/null +++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Delete_givenObjectResource_thenResponseCode_405_bad.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action; + +import 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.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.RestfulResponse; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation; +import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public class Delete_givenObjectResource_thenResponseCode_405_bad { + + @Rule + public IsisWebServerRule webServerRule = new IsisWebServerRule(); + + protected RestfulClient client; + private DomainObjectResource domainObjectResource; + + @Before + public void setUp() throws Exception { + final WebServer webServer = webServerRule.getWebServer(); + client = new RestfulClient(webServer.getBase()); + domainObjectResource = client.getDomainObjectResource(); + } + + @Test + public void representation() throws Exception { + + // given + final Response actionPromptResp = domainObjectResource.actionPrompt("RTNE", "67", "contains"); + final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp); + final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity(); + final LinkRepresentation selfLink = actionPromptRepr.getLinkWithRel(Rel.SELF); + final LinkRepresentation deleteLink = selfLink.withMethod(RestfulHttpMethod.DELETE); + + // when + final RestfulResponse<JsonRepresentation> restfulResponse = client.follow(deleteLink); + + // then + assertThat(restfulResponse.getStatus(), is(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED)); + assertThat(restfulResponse.getHeader(RestfulResponse.Header.WARNING), is("Deleting action prompt resource is not allowed.")); + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/1838ede3/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Delete_givenServiceResource_thenResponseCode_405_bad.java ---------------------------------------------------------------------- diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Delete_givenServiceResource_thenResponseCode_405_bad.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Delete_givenServiceResource_thenResponseCode_405_bad.java new file mode 100644 index 0000000..04c518e --- /dev/null +++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Delete_givenServiceResource_thenResponseCode_405_bad.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.domainobjectorservice.id.action; + +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.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.RestfulResponse; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation; +import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule; +import org.apache.isis.viewer.restfulobjects.tck.Util; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public class Delete_givenServiceResource_thenResponseCode_405_bad { + + @Rule + public IsisWebServerRule webServerRule = new IsisWebServerRule(); + + protected RestfulClient client; + private DomainServiceResource serviceResource; + + @Before + public void setUp() throws Exception { + final WebServer webServer = webServerRule.getWebServer(); + client = new RestfulClient(webServer.getBase()); + serviceResource = client.getDomainServiceResource(); + } + + @Test + public void followLink() throws Exception { + + // given + final Response actionPromptResp = serviceResource.actionPrompt("ActionsEntities", "subListWithOptionalRange"); + final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp); + final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity(); + final LinkRepresentation selfLink = actionPromptRepr.getLinkWithRel(Rel.SELF); + final LinkRepresentation deleteLink = selfLink.withMethod(RestfulHttpMethod.DELETE); + + // when + final RestfulResponse<JsonRepresentation> restfulResponse = client.follow(deleteLink); + + // then + assertThat(restfulResponse.getStatus(), is(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED)); + assertThat(restfulResponse.getHeader(RestfulResponse.Header.WARNING), is("Deleting action prompt resource is not allowed.")); + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/1838ede3/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Delete_thenResponseCode_405_bad.java ---------------------------------------------------------------------- diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Delete_thenResponseCode_405_bad.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Delete_thenResponseCode_405_bad.java deleted file mode 100644 index 58218e5..0000000 --- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Delete_thenResponseCode_405_bad.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action; - -import 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.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.RestfulResponse; -import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource; -import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation; -import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -public class Delete_thenResponseCode_405_bad { - - @Rule - public IsisWebServerRule webServerRule = new IsisWebServerRule(); - - protected RestfulClient client; - private DomainObjectResource domainObjectResource; - - @Before - public void setUp() throws Exception { - final WebServer webServer = webServerRule.getWebServer(); - client = new RestfulClient(webServer.getBase()); - domainObjectResource = client.getDomainObjectResource(); - } - - @Test - public void representation() throws Exception { - - // given - final Response actionPromptResp = domainObjectResource.actionPrompt("RTNE", "67", "contains"); - final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp); - final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity(); - final LinkRepresentation selfLink = actionPromptRepr.getLinkWithRel(Rel.SELF); - final LinkRepresentation deleteLink = selfLink.withMethod(RestfulHttpMethod.DELETE); - - // when - final RestfulResponse<JsonRepresentation> restfulResponse = client.follow(deleteLink); - - // then - assertThat(restfulResponse.getStatus(), is(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED)); - assertThat(restfulResponse.getHeader(RestfulResponse.Header.WARNING), is("Deleting action prompt resource is not allowed.")); - } - -} http://git-wip-us.apache.org/repos/asf/isis/blob/1838ede3/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Post_givenObjectResource_thenResponseCode_405_bad.java ---------------------------------------------------------------------- diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Post_givenObjectResource_thenResponseCode_405_bad.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Post_givenObjectResource_thenResponseCode_405_bad.java new file mode 100644 index 0000000..928db3d --- /dev/null +++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Post_givenObjectResource_thenResponseCode_405_bad.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action; + +import 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.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.RestfulResponse; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation; +import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public class Post_givenObjectResource_thenResponseCode_405_bad { + + @Rule + public IsisWebServerRule webServerRule = new IsisWebServerRule(); + + protected RestfulClient client; + private DomainObjectResource domainObjectResource; + + @Before + public void setUp() throws Exception { + final WebServer webServer = webServerRule.getWebServer(); + client = new RestfulClient(webServer.getBase()); + domainObjectResource = client.getDomainObjectResource(); + } + + @Test + public void representation() throws Exception { + + // given + final Response actionPromptResp = domainObjectResource.actionPrompt("RTNE", "67", "contains"); + final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp); + final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity(); + final LinkRepresentation selfLink = actionPromptRepr.getLinkWithRel(Rel.SELF); + final LinkRepresentation deleteLink = selfLink.withMethod(RestfulHttpMethod.POST); + + // when + final RestfulResponse<JsonRepresentation> restfulResponse = client.follow(deleteLink); + + // then + assertThat(restfulResponse.getStatus(), is(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED)); + assertThat(restfulResponse.getHeader(RestfulResponse.Header.WARNING), is("Posting to an action prompt resource is not allowed.")); + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/1838ede3/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Post_givenServiceResource_thenResponseCode_405_bad.java ---------------------------------------------------------------------- diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Post_givenServiceResource_thenResponseCode_405_bad.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Post_givenServiceResource_thenResponseCode_405_bad.java new file mode 100644 index 0000000..7ca58c3 --- /dev/null +++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Post_givenServiceResource_thenResponseCode_405_bad.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.domainobjectorservice.id.action; + +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.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.RestfulResponse; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation; +import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public class Post_givenServiceResource_thenResponseCode_405_bad { + + @Rule + public IsisWebServerRule webServerRule = new IsisWebServerRule(); + + protected RestfulClient client; + private DomainServiceResource serviceResource; + + @Before + public void setUp() throws Exception { + final WebServer webServer = webServerRule.getWebServer(); + client = new RestfulClient(webServer.getBase()); + serviceResource = client.getDomainServiceResource(); + } + + @Test + public void followLink() throws Exception { + + // given + final Response actionPromptResp = serviceResource.actionPrompt("ActionsEntities", "subListWithOptionalRange"); + final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp); + final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity(); + final LinkRepresentation selfLink = actionPromptRepr.getLinkWithRel(Rel.SELF); + final LinkRepresentation postLink = selfLink.withMethod(RestfulHttpMethod.POST); + + // when + final RestfulResponse<JsonRepresentation> restfulResponse = client.follow(postLink); + + // then + assertThat(restfulResponse.getStatus(), is(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED)); + assertThat(restfulResponse.getHeader(RestfulResponse.Header.WARNING), is("Posting to an action prompt resource is not allowed.")); + } + + +} http://git-wip-us.apache.org/repos/asf/isis/blob/1838ede3/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Post_thenResponseCode_405_bad.java ---------------------------------------------------------------------- diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Post_thenResponseCode_405_bad.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Post_thenResponseCode_405_bad.java deleted file mode 100644 index 352542b..0000000 --- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Post_thenResponseCode_405_bad.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action; - -import 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.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.RestfulResponse; -import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource; -import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation; -import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -public class Post_thenResponseCode_405_bad { - - @Rule - public IsisWebServerRule webServerRule = new IsisWebServerRule(); - - protected RestfulClient client; - private DomainObjectResource domainObjectResource; - - @Before - public void setUp() throws Exception { - final WebServer webServer = webServerRule.getWebServer(); - client = new RestfulClient(webServer.getBase()); - domainObjectResource = client.getDomainObjectResource(); - } - - @Test - public void representation() throws Exception { - - // given - final Response actionPromptResp = domainObjectResource.actionPrompt("RTNE", "67", "contains"); - final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp); - final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity(); - final LinkRepresentation selfLink = actionPromptRepr.getLinkWithRel(Rel.SELF); - final LinkRepresentation deleteLink = selfLink.withMethod(RestfulHttpMethod.POST); - - // when - final RestfulResponse<JsonRepresentation> restfulResponse = client.follow(deleteLink); - - // then - assertThat(restfulResponse.getStatus(), is(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED)); - assertThat(restfulResponse.getHeader(RestfulResponse.Header.WARNING), is("Posting to an action prompt resource is not allowed.")); - } - -} http://git-wip-us.apache.org/repos/asf/isis/blob/1838ede3/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Put_givenObjectResource_thenResponseCode_405_bad.java ---------------------------------------------------------------------- diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Put_givenObjectResource_thenResponseCode_405_bad.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Put_givenObjectResource_thenResponseCode_405_bad.java new file mode 100644 index 0000000..5a58dfd --- /dev/null +++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Put_givenObjectResource_thenResponseCode_405_bad.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action; + +import 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.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.RestfulResponse; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation; +import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public class Put_givenObjectResource_thenResponseCode_405_bad { + + @Rule + public IsisWebServerRule webServerRule = new IsisWebServerRule(); + + protected RestfulClient client; + private DomainObjectResource domainObjectResource; + + @Before + public void setUp() throws Exception { + final WebServer webServer = webServerRule.getWebServer(); + client = new RestfulClient(webServer.getBase()); + domainObjectResource = client.getDomainObjectResource(); + } + + @Test + public void representation() throws Exception { + + // given + final Response actionPromptResp = domainObjectResource.actionPrompt("RTNE", "67", "contains"); + final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp); + final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity(); + final LinkRepresentation selfLink = actionPromptRepr.getLinkWithRel(Rel.SELF); + final LinkRepresentation deleteLink = selfLink.withMethod(RestfulHttpMethod.PUT); + + // when + final RestfulResponse<JsonRepresentation> restfulResponse = client.follow(deleteLink); + + // then + assertThat(restfulResponse.getStatus(), is(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED)); + assertThat(restfulResponse.getHeader(RestfulResponse.Header.WARNING), is("Putting to an action prompt resource is not allowed.")); + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/1838ede3/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Put_givenServiceResource_thenResponseCode_405_bad.java ---------------------------------------------------------------------- diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Put_givenServiceResource_thenResponseCode_405_bad.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Put_givenServiceResource_thenResponseCode_405_bad.java new file mode 100644 index 0000000..a738420 --- /dev/null +++ b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Put_givenServiceResource_thenResponseCode_405_bad.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action; + +import 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.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.RestfulResponse; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource; +import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation; +import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +public class Put_givenServiceResource_thenResponseCode_405_bad { + + @Rule + public IsisWebServerRule webServerRule = new IsisWebServerRule(); + + protected RestfulClient client; + private DomainServiceResource serviceResource; + + @Before + public void setUp() throws Exception { + final WebServer webServer = webServerRule.getWebServer(); + client = new RestfulClient(webServer.getBase()); + serviceResource = client.getDomainServiceResource(); + } + + @Test + public void followLink() throws Exception { + + // given + final Response actionPromptResp = serviceResource.actionPrompt("ActionsEntities", "subListWithOptionalRange"); + final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp); + final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity(); + final LinkRepresentation selfLink = actionPromptRepr.getLinkWithRel(Rel.SELF); + final LinkRepresentation postLink = selfLink.withMethod(RestfulHttpMethod.PUT); + + // when + final RestfulResponse<JsonRepresentation> restfulResponse = client.follow(postLink); + + // then + assertThat(restfulResponse.getStatus(), is(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED)); + assertThat(restfulResponse.getHeader(RestfulResponse.Header.WARNING), is("Putting to an action prompt resource is not allowed.")); + } + +} http://git-wip-us.apache.org/repos/asf/isis/blob/1838ede3/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Put_thenResponseCode_405_bad.java ---------------------------------------------------------------------- diff --git a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Put_thenResponseCode_405_bad.java b/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Put_thenResponseCode_405_bad.java deleted file mode 100644 index 2bb6225..0000000 --- a/component/viewer/restfulobjects/tck/src/test/java/org/apache/isis/viewer/restfulobjects/tck/domainobjectorservice/id/action/Put_thenResponseCode_405_bad.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.isis.viewer.restfulobjects.tck.domainobjectorservice.id.action; - -import 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.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.RestfulResponse; -import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource; -import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation; -import org.apache.isis.viewer.restfulobjects.tck.IsisWebServerRule; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -public class Put_thenResponseCode_405_bad { - - @Rule - public IsisWebServerRule webServerRule = new IsisWebServerRule(); - - protected RestfulClient client; - private DomainObjectResource domainObjectResource; - - @Before - public void setUp() throws Exception { - final WebServer webServer = webServerRule.getWebServer(); - client = new RestfulClient(webServer.getBase()); - domainObjectResource = client.getDomainObjectResource(); - } - - @Test - public void representation() throws Exception { - - // given - final Response actionPromptResp = domainObjectResource.actionPrompt("RTNE", "67", "contains"); - final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp); - final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity(); - final LinkRepresentation selfLink = actionPromptRepr.getLinkWithRel(Rel.SELF); - final LinkRepresentation deleteLink = selfLink.withMethod(RestfulHttpMethod.PUT); - - // when - final RestfulResponse<JsonRepresentation> restfulResponse = client.follow(deleteLink); - - // then - assertThat(restfulResponse.getStatus(), is(RestfulResponse.HttpStatusCode.METHOD_NOT_ALLOWED)); - assertThat(restfulResponse.getHeader(RestfulResponse.Header.WARNING), is("Putting to an action prompt resource is not allowed.")); - } - -}
