Examples of JsonRepresentation


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

    @Ignore("currently failing")
    @Test
    public void usingClientFollow() throws Exception {

        // given, when
        final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "subListWithOptionalRange");
        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/subListWithOptionalRange/invoke"))
                                    .build());

        invokeLink.withMethod(RestfulHttpMethod.POST);
       
        // when
        JsonRepresentation args = JsonRepresentation.newMap();
        args = JsonRepresentation.newMap();
        args.mapPut("id.value", 123);

        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 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 = JsonRepresentation.newMap();
        args.mapPut("from.value", 0);
        args.mapPut("to.value", 1);
        args.mapPut("nonExistent.value", 2);
        assertThat(args.size(), is(3));

        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", 0);
        args.mapPut("to.value", 1);
        args.mapPut("nonExistent.value", 2);
        assertThat(args.size(), is(3));

        Response response = serviceResource.invokeActionQueryOnly("ActionsEntities", "subList", UrlEncodingUtils.urlEncode(args));
        RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
       
        // then
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("Argument 'nonExistent' found but no such parameter"));
    }
View Full Code Here

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

    @Ignore("to write - copied from req_safe")
    @Test
    public void usingClientFollow() throws Exception {

        // given, when
        final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "subListWithOptionalRange");
        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/subListWithOptionalRange/invoke"))
                                    .build());

        invokeLink.withMethod(RestfulHttpMethod.POST);
       
        // when
        JsonRepresentation args = JsonRepresentation.newMap();
        args = JsonRepresentation.newMap();
        args.mapPut("id.value", 123);

        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 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 = JsonRepresentation.newMap();
        // nothing for 'from'
        args.mapPut("to.value", 0);
        assertThat(args.size(), is(1));

        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();
        // nothing for 'from'
        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

        // 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("No argument found for (mandatory) parameter 'from'"));
    }
View Full Code Here

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

    @Test
    public void usingClientFollow_whenImplicitlySetToNull() throws Exception {

        // given
        final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "subListWithOptionalRange");
        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/subListWithOptionalRange/invoke"))
                                    .build());
       
        // when
        JsonRepresentation args = JsonRepresentation.newMap();
        args.mapPut("from", JsonRepresentation.newMap());
        args.mapPut("to.value", (Integer)null);

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

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

   
    @Test
    public void usingResourceProxy_whenExplicitSetToNull() throws Exception {

        // given, when
        JsonRepresentation args = JsonRepresentation.newMap();
        args.mapPut("from", JsonRepresentation.newMap());
        args.mapPut("to.value", (Integer)null);

        Response response = serviceResource.invokeActionQueryOnly("ActionsEntities", "subListWithOptionalRange", UrlEncodingUtils.urlEncode(args));
        RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
       
        // then
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.