Package org.apache.isis.viewer.restfulobjects.applib.domainobjects

Examples of org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation


    public void representation() throws Exception {

        // given
        final Response actionPromptResp = domainObjectResource.actionPrompt("RTNE", "78", "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);
View Full Code Here


    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);
View Full Code Here

        final Response actionPromptResp = domainObjectResource.actionPrompt("RTNE", "78", "contains");
        final RestfulResponse<ObjectActionRepresentation> actionPromptJsonResp = RestfulResponse.ofT(actionPromptResp);
        assertThat(actionPromptJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));

        // then
        final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity();

        assertThat(actionPromptRepr.getString("memberType"), is("action"));

        // self link
        final LinkRepresentation selfLink = actionPromptRepr.getLinkWithRel(Rel.SELF);
        assertThat(selfLink, isLink(client)
                                .httpMethod(RestfulHttpMethod.GET)
                                .href(endsWith("/objects/RTNE/78/actions/contains"))
                                .returning(HttpStatusCode.OK));

        // up link
        final LinkRepresentation upLink = actionPromptRepr.getLinkWithRel(Rel.UP);
        assertThat(upLink, isLink(client)
                                .httpMethod(RestfulHttpMethod.GET)
                                .href(endsWith("/objects/RTNE/78"))
                                .returning(HttpStatusCode.OK)
                                .type(RepresentationType.DOMAIN_OBJECT.getMediaType())
                                .title("Untitled Actions Entity"));

        //invoke link
        final LinkRepresentation invokeLink = actionPromptRepr.getLinkWithRel(Rel.INVOKE);
        assertThat(invokeLink, isLink(client)
                                .httpMethod(RestfulHttpMethod.GET)
                                .href(endsWith("/objects/RTNE/78/actions/contains/invoke")));

        assertThat(invokeLink.getArguments(), is(not(nullValue())));
        assertThat(invokeLink.getArguments().isArray(), is(false));
        assertThat(invokeLink.getArguments().size(), is(2));

     // described by link
        final LinkRepresentation describedByLink = actionPromptRepr.getLinkWithRel(Rel.DESCRIBEDBY);
        assertThat(describedByLink, isLink(client)
                                .returning(HttpStatusCode.OK)
                                .responseEntityWithSelfHref(describedByLink.getHref()));

        assertThat(actionPromptRepr.getExtensions().getString("actionType"), is("user"));
        assertThat(actionPromptRepr.getExtensions().getString("actionSemantics"), is("safe"));
        assertThat(actionPromptRepr.getMap("parameters").size(), is(2));
    }
View Full Code Here

    public void representation() throws Exception {

        // given
        final Response actionPromptResp = domainObjectResource.actionPrompt("RTNE", "78", "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);
View Full Code Here

    public void representation() throws Exception {

        // given
        final Response actionPromptResp = domainObjectResource.actionPrompt("RTNE", "78", "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);
View Full Code Here

    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);
View Full Code Here

    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);
View Full Code Here

        final LinkRepresentation firstChildRepr = collValue.arrayIterator(LinkRepresentation.class).next();
       
        // when
        final RestfulResponse<ObjectActionRepresentation> removeChildRestfulResponse =
                RestfulResponse.ofT(objectResource.actionPrompt("PRNT", "53", "removeChild"));
        final ObjectActionRepresentation removeChildRepr = removeChildRestfulResponse.getEntity();
       
        LinkRepresentation invokeLinkRepr = removeChildRepr.getLinkWithRel(Rel.INVOKE);
        JsonRepresentation args = invokeLinkRepr.getArguments();
        args.mapPut("childEntity.value", firstChildRepr);
        RestfulResponse<JsonRepresentation> invokeResp = client.follow(invokeLinkRepr, args);
       
        @SuppressWarnings("unused")
View Full Code Here

        LinkRepresentation nonExistentEntityLink = new LinkRepresentation()
            .withHref("http://localhost:39393/objects/NONEXISTENT/123");
       
        // and given a representation of the 'contains' action accepting a entity href
        final JsonRepresentation containsAction = Util.givenAction(client, "ActionsEntities", "contains");
        final ObjectActionRepresentation containsActionRepr = containsAction.as(ObjectActionRepresentation.class);
       
        final LinkRepresentation invokeLink = containsActionRepr.getInvoke();
        final JsonRepresentation args = invokeLink.getArguments();
       
        // when query the 'contains' action passing in the reference to the non-existent entity
        args.mapPut("searchFor.value", nonExistentEntityLink);
        args.mapPut("from.value", 0);
View Full Code Here

    @Test
    public void usingClientFollow() throws Exception {

        // given
        final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "list");
        final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);

        final LinkRepresentation invokeLink = actionRepr.getInvoke();
        final LinkRepresentation deleteLink = invokeLink.withMethod(RestfulHttpMethod.DELETE);

        // when
        final RestfulResponse<ActionResultRepresentation> restfulResponse = client.followT(invokeLink);
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.