Examples of JsonRepresentation


Examples of org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation

        // given a reference to a non-existent entity
        LinkRepresentation nonExistentEntityLink = new LinkRepresentation()
            .withHref("http://localhost:39393/objects/NONEXISTENT/123");

        // when query the 'contains' action passing in the reference to the non-existent entity
        JsonRepresentation args = JsonRepresentation.newMap();
        args.mapPut("searchFor.value", nonExistentEntityLink);
        args.mapPut("from.value", 0);
        args.mapPut("to.value", 3);
        Response response = serviceResource.invokeActionQueryOnly("ActionsEntities", "contains", UrlEncodingUtils.urlEncode(args));
        RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
       
        // then
        then(args, restfulResponse);
View Full Code Here

Examples of org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation

        // hmmm... what is the media type, though?  the spec doesn't say.  testing for a generic one.
        assertThat(restfulResponse.getHeader(Header.CONTENT_TYPE), hasMediaTypeProfile(MediaType.APPLICATION_JSON));

        RestfulResponse<JsonRepresentation> restfulResponseOfError = restfulResponse.wraps(JsonRepresentation.class);
        JsonRepresentation repr = restfulResponseOfError.getEntity();
       
        assertThat(repr.getString("searchFor.value.href"), is(args.getString("searchFor.value.href")));
        assertThat(repr.getString("searchFor.invalidReason"), is("'href' does not reference a known entity"));
    }
View Full Code Here

Examples of org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation

    @Test
    public void usingClientFollow() throws Exception {

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

        final LinkRepresentation invokeLink = actionRepr.getInvoke();

        assertThat(invokeLink, isLink(client)
                                    .rel(Rel.INVOKE)
                                    .httpMethod(RestfulHttpMethod.GET)
                                    .href(Matchers.endsWith(":39393/services/ActionsEntities/actions/subList/invoke"))
                                    .build());
       
        JsonRepresentation args =invokeLink.getArguments();
        assertThat(args.size(), is(2));
        assertThat(args, RestfulMatchers.mapHas("from"));
        assertThat(args, RestfulMatchers.mapHas("to"));
       
        // when
        args.mapPut("from.value", 1);
        args.mapPut("to.value", 0);

        final RestfulResponse<ActionResultRepresentation> restfulResponse = client.followT(invokeLink, args);
       
        // then
        thenResponseIsErrorWithInvalidReason(restfulResponse);
View Full Code Here

Examples of org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation

    @Test
    public void usingResourceProxy() throws Exception {

        // given, when
        JsonRepresentation args = JsonRepresentation.newMap();
        args.mapPut("from.value", 1);
        args.mapPut("to.value", 0);
        Response response = serviceResource.invokeActionQueryOnly("ActionsEntities", "subList", UrlEncodingUtils.urlEncode(args));
        RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
       
        // then
        thenResponseIsErrorWithInvalidReason(restfulResponse);
View Full Code Here

Examples of org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation

        // then
        assertThat(result.getStatus(), is(RestfulResponse.HttpStatusCode.OK));

        // then also
        final JsonRepresentation jsonRepresentation = result.getEntity().as(ObjectPropertyRepresentation.class);
        assertThat(jsonRepresentation.getInt("value"), is(i));

    }
View Full Code Here

Examples of org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation

        // hmmm... what is the media type, though?  the spec doesn't say.  testing for a generic one.
        assertThat(restfulResponse.getHeader(Header.CONTENT_TYPE), hasMediaTypeProfile(MediaType.APPLICATION_JSON));

        RestfulResponse<JsonRepresentation> restfulResponseOfError = restfulResponse.wraps(JsonRepresentation.class);
        JsonRepresentation repr = restfulResponseOfError.getEntity();
       
        assertThat(repr.getString("x-ro-invalidReason"), is("'from' cannot be larger than 'to'"));
    }
View Full Code Here

Examples of org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation

   
    @Test
    public void usingClientFollow() throws Exception {

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

        final LinkRepresentation invokeLink = actionRepr.getInvoke();
        final JsonRepresentation args =invokeLink.getArguments();
       
        // when
        args.mapPut("id.value", 1);

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

Examples of org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation

    @Test
    public void usingResourceProxy() throws Exception {

        // given, when
        final JsonRepresentation args = JsonRepresentation.newMap();
        args.mapPut("id.value", 1);

        final Response response = serviceResource.invokeAction("ActionsEntities", "findByIdNotIdempotent", JsonNodeUtils.asInputStream(args));
        final RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
       
        // then
View Full Code Here

Examples of org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation

   
    @Test
    public void usingClientFollow() throws Exception {

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

        final LinkRepresentation invokeLink = actionRepr.getInvoke();

        assertThat(invokeLink, isLink(client)
                                    .rel(Rel.INVOKE)
                                    .httpMethod(RestfulHttpMethod.GET)
                                    .href(Matchers.endsWith(":39393/services/ActionsEntities/actions/subList/invoke"))
                                    .build());
       
        JsonRepresentation args =invokeLink.getArguments();
        assertThat(args.size(), is(2));
        assertThat(args, RestfulMatchers.mapHas("from"));
        assertThat(args, RestfulMatchers.mapHas("to"));
       
        // when
        args.mapPut("from.value", (Integer)null);
        args.mapPut("to.value", 0);

        final RestfulResponse<ActionResultRepresentation> restfulResponse = client.followT(invokeLink, args);
       
        // then
        thenResponseIsErrorWithInvalidReason(restfulResponse);
View Full Code Here

Examples of org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation

    @Test
    public void usingResourceProxy() throws Exception {

        // given, when
        JsonRepresentation args = JsonRepresentation.newMap();
        args.mapPut("from.value", (Integer)null);
        args.mapPut("to.value", 0);
        Response response = serviceResource.invokeActionQueryOnly("ActionsEntities", "subList", UrlEncodingUtils.urlEncode(args));
        RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
       
        // then
        thenResponseIsErrorWithInvalidReason(restfulResponse);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.