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

Examples of org.apache.isis.viewer.restfulobjects.applib.client.RestfulRequest


    @Test
    public void runtimeException_isMapped() throws Exception {

        // given
        final RestfulRequest restfulReq = client.createRequest(RestfulHttpMethod.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


    public static JsonRepresentation givenAction(RestfulClient client, final String serviceId, final String actionId) throws JsonParseException, JsonMappingException, IOException {
        final String href = givenHrefToService(client, serviceId);
        final String detailRel = Rel.DETAILS.andParam("action", actionId);

        final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, href).withArg(RequestParameter.FOLLOW_LINKS, "members[%s].links[rel=%s]", actionId, detailRel);
        final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();

        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
        final DomainObjectRepresentation repr = restfulResponse.getEntity();

        final JsonRepresentation actionLinkRepr = repr.getAction(actionId);
View Full Code Here

    @Test
    public void applicationJson_profileIncorrect_returns406() throws Exception {

        // given
        final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "version");
        request.withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());

        // when
        final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();

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

    }

    private void givenWhenThen(String oid, RestfulResponse.HttpStatusCode statusCode1) {
        // given
        RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "objects/BSRL/" +
                oid +
                "/collections/visibleAndEditableCollection");

        // when
        RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();

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

    @Test
    public void returns404() throws Exception {

        // given
        RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "objects/BSRL/64/collections/invisibleCollection");

        // when
        final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();

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

    @Test
    public void returns404() throws Exception {

        // given
        RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "objects/BSRL/64/collections/nonExistentCollection");

        // when
        final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();

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

    @Test
    public void applicationJson_profileIncorrect_returns406() throws Exception {

        // given
        final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "user");
        request.withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.VERSION.getMediaType());

        // when
        final RestfulResponse<UserRepresentation> restfulResponse = request.executeT();

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

    @Ignore("to fix")
    @Test
    public void domainObjectRepresentationForTransient_hasNoSelf_andHasNoOid() throws Exception {

        // given, when
        final RestfulRequest request = this.client.createRequest(RestfulHttpMethod.POST, "services/simples/actions/newTransientEntity/invoke");
        final RestfulResponse<ActionResultRepresentation> response = request.executeT();
        final ActionResultRepresentation actionResultRepr = response.getEntity();
        assertThat(actionResultRepr.getResultType(), is(ResultType.DOMAIN_OBJECT));
        assertThat(actionResultRepr.getResult(), is(not(nullValue())));

        final DomainObjectRepresentation domainObjectRepr = actionResultRepr.getResult().as(DomainObjectRepresentation.class);
View Full Code Here

    @Test
    public void applicationJson_profileIncorrect_returns406() throws Exception {

        // given
        RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "objects/BSRL/64");
        request.withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());

        // when
        final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();

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

    @Test
    public void returns404() throws Exception {

        // given
        RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, "objects/BSRL/64/actions/invisibleAction");

        // when
        final RestfulResponse<VersionRepresentation> restfulResponse = request.executeT();

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

TOP

Related Classes of org.apache.isis.viewer.restfulobjects.applib.client.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.