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

Examples of org.apache.isis.viewer.json.applib.JsonRepresentation$HasExtensions


    @Test
    public void servicesValues() throws Exception {

        repr = whenExecuteAndFollowLinksUsing("/", "links[rel=services].values");

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

        JsonRepresentation service;

        service = serviceLinkList.getRepresentation("[id=%s]", "simples");
        assertThat(service, isMap());
        assertThat(service.getString("id"), is("simples"));
        assertThat(service.getRepresentation("value"), is(not(nullValue())));

        service = serviceLinkList.getRepresentation("[id=%s]", "applibValuedEntities");
        assertThat(service, isMap());
        assertThat(service.getString("id"), is("applibValuedEntities"));
        assertThat(service.getRepresentation("value"), is(not(nullValue())));
    }
View Full Code Here


    @Test
    public void servicesValuesWithCriteria() throws Exception {

        repr = whenExecuteAndFollowLinksUsing("/", "links[rel=services].values[id=simples]");

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

        JsonRepresentation service;

        service = serviceLinkList.getRepresentation("[id=%s]", "simples");
        assertThat(service, isMap());
        assertThat(service.getString("id"), is("simples"));
        assertThat(service.getRepresentation("value"), is(not(nullValue())));

        service = serviceLinkList.getRepresentation("[id=%s]", "applibValuedEntities");
        assertThat(service.getRepresentation("value"), is(nullValue()));
    }
View Full Code Here

        // given, when
        final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID:32");
        final LinkRepresentation self = domainObjectRepr.getSelf();

        // then properties
        final JsonRepresentation properties = domainObjectRepr.getProperties();
        assertThat(properties.size(), is(2));

        // property ('name')
        final JsonRepresentation nameProperty = properties.getRepresentation("[id=name]");
        assertThat(nameProperty.getString("memberType"), is("property"));
        assertThat(nameProperty.getString("value"), is("child 2"));
        assertThat(nameProperty.getString("disabledReason"), is(nullValue()));

        final LinkRepresentation namePropertyDetails = nameProperty.getLink("links[rel=details]");
        assertThat(namePropertyDetails, isLink().rel("details").href(self.getHref() + "/properties/name").httpMethod(HttpMethod.GET));

    }
View Full Code Here

        // given, when
        final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID:32");
        final LinkRepresentation self = domainObjectRepr.getSelf();

        // then actions
        final JsonRepresentation actions = domainObjectRepr.getActions();
        assertThat(actions.size(), is(2));

        final JsonRepresentation listAction = actions.getRepresentation("list");
        assertThat(listAction.getString("memberType"), is("action"));
        assertThat(listAction.getString("actionId"), is("list"));
        assertThat(listAction.getString("actionType"), is("USER"));
        assertThat(listAction.getInt("numParameters"), is(0));

        final LinkRepresentation listActionType = listAction.getLink("type");
        assertThat(listActionType.getRel(), is("type"));
        assertThat(listActionType.getHref(), matches(".+vnd\\.list\\+json"));
        assertThat(listActionType.getHttpMethod(), is(HttpMethod.GET));

        final LinkRepresentation listActionDetails = listAction.getLink("details");
        assertThat(listActionDetails.getRel(), is("action"));
        assertThat(listActionDetails.getHref(), is(self.getHref() + "/actions/list"));
        assertThat(listActionDetails.getHttpMethod(), is(HttpMethod.GET));

        final JsonRepresentation newEntityAction = actions.getRepresentation("newEntity");
        assertThat(newEntityAction.getString("memberType"), is("action"));
        assertThat(newEntityAction.getString("actionType"), is("USER"));
        assertThat(newEntityAction.getInt("numParameters"), is(0));

        final LinkRepresentation newEntityActionType = newEntityAction.getLink("type");
        assertThat(newEntityActionType.getRel(), is("type"));
        assertThat(newEntityActionType.getHref(), matches(".+vnd\\." + ApplibValuedEntity.class.getName() + "\\+json"));
        assertThat(newEntityActionType.getHttpMethod(), is(HttpMethod.GET));

        final LinkRepresentation newEntityActionDetails = newEntityAction.getLink("details");
        assertThat(newEntityActionDetails.getRel(), is("action"));
        assertThat(newEntityActionDetails.getHref(), is(self.getHref() + "/actions/newEntity"));
        assertThat(newEntityActionDetails.getHttpMethod(), is(HttpMethod.GET));
    }
View Full Code Here

        assertThat(repr.getSelf(), isLink().httpMethod(HttpMethod.GET));

        assertThat(repr.getString("specVersion"), is("0.52"));
        assertThat(repr.getString("implVersion"), is(not(nullValue())));

        final JsonRepresentation optionalCapbilitiesRepr = repr.getOptionalCapabilities();
        assertThat(optionalCapbilitiesRepr, isMap());

        assertThat(optionalCapbilitiesRepr.getString("concurrencyChecking"), is("no"));
        assertThat(optionalCapbilitiesRepr.getString("transientObjects"), is("yes"));
        assertThat(optionalCapbilitiesRepr.getString("deleteObjects"), is("no"));
        assertThat(optionalCapbilitiesRepr.getString("simpleArguments"), is("no"));
        assertThat(optionalCapbilitiesRepr.getString("partialArguments"), is("no"));
        assertThat(optionalCapbilitiesRepr.getString("followLinks"), is("yes"));
        assertThat(optionalCapbilitiesRepr.getString("validateOnly"), is("no"));
        assertThat(optionalCapbilitiesRepr.getString("pagination"), is("no"));
        assertThat(optionalCapbilitiesRepr.getString("sorting"), is("no"));
        assertThat(optionalCapbilitiesRepr.getString("domainModel"), is("rich"));

        assertThat(repr.getLinks(), isArray());
        assertThat(repr.getExtensions(), is(not(nullValue())));
    }
View Full Code Here

    @Ignore("TODO - fix broken test resulting from introduction of actionresult repr")
    @Test
    public void invokeQueryOnly_noArg_usingClientFollow() throws Exception {

        // given
        final JsonRepresentation givenAction = givenAction("simples", "list");
        final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);

        // when
        final LinkRepresentation invokeLink = actionRepr.getInvoke();

        // then
View Full Code Here

    @Ignore("TODO - fix broken test resulting from introduction of actionresult repr")
    @Test
    public void invokeIdempotent_withArgs_usingClientFollow() throws Exception {

        // given action
        final JsonRepresentation givenAction = givenAction("simples", "newPersistentEntity");
        final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);

        // when
        final LinkRepresentation invokeLink = actionRepr.getInvoke();

        // then
        assertThat(invokeLink, is(not(nullValue())));

        final JsonRepresentation args = invokeLink.getArguments();
        assertThat(args.size(), is(2));
        assertThat(args.mapHas("name"), is(true));
        assertThat(args.mapHas("flag"), is(true));

        // when
        args.mapPut("name", "New Name");
        args.mapPut("flag", true);
        final RestfulResponse<DomainObjectRepresentation> restfulResponse = client.followT(invokeLink, args);

        // then
        final DomainObjectRepresentation objectRepr = restfulResponse.getEntity();
View Full Code Here

        // given, when
        final DomainObjectRepresentation domainObjectRepr = givenDomainObjectRepresentationFor("OID:xxx");

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

    public void actionPostInvoke_returningList() throws Exception {

        // given
        final DomainObjectResource domainObjectResource = client.getDomainObjectResource();

        final JsonRepresentation body = JsonRepresentation.newArray();

        // when
        final Response actionInvokeResp = domainObjectResource.invokeAction("OID:1", "list", body.asInputStream());
        final RestfulResponse<ScalarValueRepresentation> actionInvokeJsonResp = RestfulResponse.ofT(actionInvokeResp);
        assertThat(actionInvokeJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));

        // then
        final ScalarValueRepresentation actionInvokeRepr = actionInvokeJsonResp.getEntity();
        assertThat(actionInvokeRepr.isArray(), is(true));
        assertThat(actionInvokeRepr.size(), is(5));

        final JsonRepresentation domainObjectRefRepr = actionInvokeRepr.arrayGet(0);

        assertThat(domainObjectRefRepr, is(not(nullValue())));
        assertThat(domainObjectRefRepr.getString("title"), is("Untitled Applib Values Entity")); // TODO

        final LinkRepresentation domainObjectLink = domainObjectRefRepr.getLink("link");
        assertThat(domainObjectLink.getRel(), is("object"));
        assertThat(domainObjectLink.getHref(), matches("http://localhost:\\d+/objects/OID:7"));

        final LinkRepresentation domainObjectTypeLink = domainObjectRefRepr.getLink("type");
        assertThat(domainObjectTypeLink.getRel(), is("type"));
        assertThat(domainObjectTypeLink.getHref(), matches("http://localhost:\\d+/types/application/vnd." + org.apache.isis.tck.dom.scalars.ApplibValuedEntity.class.getName() + "\\+json"));

        final LinkRepresentation domainObjectIconLink = domainObjectRefRepr.getLink("icon");
        assertThat(domainObjectIconLink.getRel(), is("icon"));
        assertThat(domainObjectIconLink.getHref(), matches("http://localhost:\\d+/images/null.png")); // TODO
    }
View Full Code Here

    @Ignore("TODO - fix broken test resulting from introduction of actionresult repr")
    @Test
    public void invoke_returningScalar_withReferenceArgs_usingClientFollow() throws Exception {

        // given action
        final JsonRepresentation givenAction = givenAction("simples", "count");
        final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);

        // when
        final LinkRepresentation invokeLink = actionRepr.getInvoke();

        // then
        assertThat(invokeLink, is(not(nullValue())));
        final JsonRepresentation args = invokeLink.getArguments();
        assertThat(args.size(), is(0));

        // when
        final RestfulResponse<ScalarValueRepresentation> restfulResponse = client.followT(invokeLink, args);

        // then
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.json.applib.JsonRepresentation$HasExtensions

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.