Package org.apache.isis.viewer.json.applib

Examples of org.apache.isis.viewer.json.applib.RestfulRequest


    }

    @Test
    public void noMediaType() throws Exception {
        // given
        final RestfulRequest restfulReq = client.createRequest(HttpMethod.GET, "/");

        // when
        final RestfulResponse<HomePageRepresentation> restfulResp = restfulReq.executeT();

        // then
        assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
        assertThat(restfulResp.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.HOME_PAGE.getMediaType()));
    }
View Full Code Here


    @Test
    public void correctMediaType() throws Exception {

        // given
        final RestfulRequest restfulReq = client.createRequest(HttpMethod.GET, "/");
        restfulReq.withHeader(Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);

        // when
        final RestfulResponse<HomePageRepresentation> restfulResp = restfulReq.executeT();

        // then
        assertThat(restfulResp.getStatus(), is(HttpStatusCode.OK));
        assertThat(restfulResp.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.HOME_PAGE.getMediaType()));
    }
View Full Code Here

    @Test
    public void runtimeException_isMapped() throws Exception {

        // given
        final RestfulRequest restfulReq = client.createRequest(HttpMethod.GET, "version");
        final Header<Boolean> header = new Header<Boolean>("X-FAIL", Parser.forBoolean());
        restfulReq.withHeader(header, true);

        // when
        final RestfulResponse<JsonRepresentation> jsonResp = restfulReq.execute();

        // then
        assertThat(jsonResp.getStatus(), is(HttpStatusCode.METHOD_FAILURE));
    }
View Full Code Here

    }

    @Test
    public void applicationJson() throws Exception {

        final RestfulRequest request = client.createRequest(HttpMethod.GET, "services").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
        final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();

        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
    }
View Full Code Here

    }

    @Test
    public void applicationJson_profileList() throws Exception {

        final RestfulRequest request = client.createRequest(HttpMethod.GET, "services").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.LIST.getMediaType());
        final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();

        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
    }
View Full Code Here

    }

    @Test
    public void applicationJson_invalid() throws Exception {

        final RestfulRequest request = client.createRequest(HttpMethod.GET, "services").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
        final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();

        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
    }
View Full Code Here

    }

    @Test
    public void xrofollowLinks() throws Exception {

        RestfulRequest request;
        RestfulResponse<ListRepresentation> restfulResponse;
        ListRepresentation repr;

        request = client.createRequest(HttpMethod.GET, "services");
        restfulResponse = request.executeT();
        repr = restfulResponse.getEntity();

        assertThat(repr.getValues(), isArray());
        assertThat(repr.getValues().size(), is(greaterThan(0)));
        assertThat(repr.getValues().arrayGet(0), isLink().novalue());

        request = client.createRequest(HttpMethod.GET, "services").withArg(RequestParameter.FOLLOW_LINKS, "values");
        restfulResponse = request.executeT();
        repr = restfulResponse.getEntity();

        assertThat(repr.getValues().arrayGet(0), isLink().value(is(not(Matchers.<JsonRepresentation> nullValue()))));
        assertThat(repr.getValues().arrayGet(0).getRepresentation("value"), isMap());
    }
View Full Code Here

    }

    @Test
    public void applicationJson() throws Exception {

        final RestfulRequest request = client.createRequest(HttpMethod.GET, "/").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
        final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();

        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
    }
View Full Code Here

    }

    @Test
    public void applicationJson_profileHomePage() throws Exception {

        final RestfulRequest request = client.createRequest(HttpMethod.GET, "/").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.HOME_PAGE.getMediaType());
        final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();

        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
    }
View Full Code Here

    }

    @Test
    public void applicationJson_invalid() throws Exception {

        final RestfulRequest request = client.createRequest(HttpMethod.GET, "/").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
        final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();

        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.json.applib.RestfulRequest

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.