Examples of JsonRepresentation


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

        // given, when
        final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("BSRL","74");

        // property ('invisibleProperty')
        final JsonRepresentation properties = domainObjectRepr.getProperties();
        final JsonRepresentation nameProperty = properties.getRepresentation("invisibleProperty");
        assertThat(nameProperty, is(nullValue()));
    }
View Full Code Here

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

        // given
        final RestfulResponse<ListRepresentation> jsonResp = RestfulResponse.ofT(resource.services());
        final ListRepresentation repr = jsonResp.getEntity();

        // when
        final JsonRepresentation values = repr.getValue();

        // then
        for (final LinkRepresentation link : values.arrayIterable(LinkRepresentation.class)) {
            assertThat("HiddenRepository should not show up in services list", false, is(link.getHref().endsWith("HiddenRepository")));
        }
       
        // and also
        for (final LinkRepresentation link : values.arrayIterable(LinkRepresentation.class)) {

            assertThat(link, isLink(client)
                    .rel(containsString(Rel.SERVICE.getName()))
                    .href(containsString(":39393/"))
                    .httpMethod(RestfulHttpMethod.GET)
View Full Code Here

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

        final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();

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

        final JsonRepresentation membersList = repr.getMembers();
        assertThat(membersList, isMap());

        JsonRepresentation actionRepr;

        actionRepr = membersList.getRepresentation("list");
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"]"), is(not(nullValue())));
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"].value"), is(not(nullValue()))); // followed

        actionRepr = membersList.getRepresentation("newEntity");
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"]"), is(not(nullValue())));
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.getName()+"].value"), is(not(nullValue()))); // also followed
    }
View Full Code Here

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

        final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();

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

        final JsonRepresentation membersList = repr.getMembers();
        assertThat(membersList, isMap());

        JsonRepresentation actionRepr;

        actionRepr = membersList.getRepresentation("list");
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "list")+"]"), is(not(nullValue())));
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "list")+"].value"), is(not(nullValue()))); // followed

        actionRepr = membersList.getRepresentation("newEntity");
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "newEntity")+"]"), is(not(nullValue())));
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "newEntity")+"].value"), is(nullValue())); // not followed
    }
View Full Code Here

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

        final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();

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

        final JsonRepresentation membersList = repr.getMembers();
        assertThat(membersList, isMap());

        JsonRepresentation actionRepr;

        actionRepr = membersList.getRepresentation("list");
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "list")+"]"), is(not(nullValue())));
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "list")+"].value"), is(not(nullValue()))); // followed

        actionRepr = membersList.getRepresentation("newEntity");
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "newEntity")+"]"), is(not(nullValue())));
        assertThat(actionRepr.getRepresentation("links[rel="+Rel.DETAILS.andParam("action", "newEntity")+"].value"), is(not(nullValue()))); // also followed
    }
View Full Code Here

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

    @Test
    public void allServices_Value() throws Exception {

        repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SERVICES.getName() + "].value");

        final JsonRepresentation servicesValue = repr.getServices().getValue();
        assertThat(servicesValue, is(not(nullValue())));
        assertThat(servicesValue, isMap());
        final JsonRepresentation serviceLinkList = servicesValue.getArray("value");
        assertThat(serviceLinkList, isArray());

        JsonRepresentation service;

        service = serviceLinkList.getRepresentation("[rel=%s;serviceId=\"%s\"]", Rel.SERVICE.getName(), "JdkValuedEntities");
        assertThat(service, isMap());
        assertThat(service.getRepresentation("value"), is(not(nullValue())));

        service = serviceLinkList.getRepresentation("[rel=%s;serviceId=\"%s\"]", Rel.SERVICE.getName(), "WrapperValuedEntities");
        assertThat(service, isMap());
        assertThat(service.getRepresentation("value"), is(not(nullValue())));
    }
View Full Code Here

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

    @Test
    public void selectedService_Value() throws Exception {

        repr = whenExecuteAndFollowLinksUsing("/", "links[rel=" + Rel.SERVICES.getName() + "].value[rel=" + Rel.SERVICE.andParam("serviceId", "WrapperValuedEntities")+"]");

        final JsonRepresentation servicesValue = repr.getServices().getValue();
        assertThat(servicesValue, is(not(nullValue())));
        assertThat(servicesValue, isMap());
        final JsonRepresentation serviceLinkList = servicesValue.getArray("value");
        assertThat(serviceLinkList, isArray());

        JsonRepresentation service;

        service = serviceLinkList.getRepresentation("[rel=%s;serviceId=\"%s\"]", Rel.SERVICE.getName(), "WrapperValuedEntities");
        assertThat(service, isMap());
        assertThat(service.getRepresentation("value"), is(not(nullValue())));

        service = serviceLinkList.getRepresentation("[rel=%s;serviceId=\"%s\"]", Rel.SERVICE.getName(), "JdkValuedEntities");
        assertThat(service.getRepresentation("value"), is(nullValue()));
    }
View Full Code Here

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

        // given
        RestfulResponse<ObjectCollectionRepresentation> childrenRestfulResponse =
                RestfulResponse.ofT(objectResource.accessCollection("PRNT", "53", "children"));
        ObjectCollectionRepresentation childrenRepr = childrenRestfulResponse.getEntity();

        JsonRepresentation collValue = childrenRepr.getValue();

        final int numChildren = collValue.size();
        assertThat(numChildren, is(IsisMatchers.greaterThan(0)));

        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")
        JsonRepresentation invokeRepr = invokeResp.getEntity();
        final HttpStatusCode status = invokeResp.getStatus();
        assertThat(status, is(HttpStatusCode.OK));

        // 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("str1.value", "abc+def");
        args.mapPut("str2.value", "HOORAY");

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

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");
       
        // 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);
        args.mapPut("to.value", 1);
       
        RestfulResponse<ActionResultRepresentation> restfulResponse = client.followT(invokeLink, args);

        // then
        then(args, 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.