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

Examples of org.apache.isis.viewer.json.applib.links.LinkRepresentation


        assertThat(actionResultRepr.getResult(), is(not(nullValue())));

        final DomainObjectRepresentation domainObjectRepr = actionResultRepr.getResult().as(DomainObjectRepresentation.class);

        // then
        final LinkRepresentation self = domainObjectRepr.getSelf();
        assertThat(self, is(nullValue()));

        assertThat(domainObjectRepr.getOid(), is(nullValue()));
    }
View Full Code Here


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

        // then
        final LinkRepresentation selfIcon = domainObjectRepr.getLinkWithRel(Rel.ICON);
        assertThat(selfIcon, is(nullValue()));
    }
View Full Code Here

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

        // icon
        final LinkRepresentation selfIcon = domainObjectRepr.getLinkWithRel(Rel.ICON);
        assertThat(selfIcon, isLink().href(matches(".+" + "/images/" + "null\\.png")).httpMethod(HttpMethod.GET));

    }
View Full Code Here

    @Test
    public void domainObjectRepresentationContent_Properties() throws Exception {

        // 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

    @Test
    public void domainObjectRepresentationContent() throws Exception {

        // 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

        // then
        final ObjectPropertyRepresentation propertyDetailsRepr = idPropertyJsonResp.getEntity();

        // _self.link
        final LinkRepresentation selfLink = propertyDetailsRepr.getLink("_self.link");
        assertThat(selfLink.getRel(), is("member"));
        assertThat(selfLink.getHref(), matches(".+objects/OID:1/properties/id"));
        assertThat(selfLink.getHttpMethod(), is(HttpMethod.GET));

        // _self.object
        final LinkRepresentation selfObject = propertyDetailsRepr.getLink("_self.object");
        assertThat(selfObject.getRel(), is("object"));
        assertThat(selfObject.getHref(), matches(".+objects/OID:1"));
        assertThat(selfObject.getHttpMethod(), is(HttpMethod.GET));

        // type
        final LinkRepresentation type = propertyDetailsRepr.getLink("type");
        assertThat(type.getRel(), is("type"));
        assertThat(type.getHref(), matches(".+vnd\\.string\\+json"));
        assertThat(type.getHttpMethod(), is(HttpMethod.GET));

        assertThat(propertyDetailsRepr.getString("memberType"), is("property"));
        assertThat(propertyDetailsRepr.getString("value"), is(org.apache.isis.tck.objstore.dflt.scalars.ApplibValuedEntityRepositoryDefault.class.getName()));
        assertThat(propertyDetailsRepr.getString("disabledReason"), is(not(nullValue())));
    }
View Full Code Here

        // then
        final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity();

        // _self.link
        final LinkRepresentation selfLink = actionPromptRepr.getLink("_self.link");
        assertThat(selfLink.getRel(), is("member"));
        assertThat(selfLink.getHref(), matches(".+objects/OID:1/actions/list"));
        assertThat(selfLink.getHttpMethod(), is(HttpMethod.GET));

        // _self.object
        final LinkRepresentation selfObject = actionPromptRepr.getLink("_self.object");
        assertThat(selfObject.getRel(), is("object"));
        assertThat(selfObject.getHref(), matches(".+objects/OID:1"));
        assertThat(selfObject.getHttpMethod(), is(HttpMethod.GET));

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

        assertThat(actionPromptRepr.getString("memberType"), is("action"));
        assertThat(actionPromptRepr.getString("actionType"), is("USER"));
        assertThat(actionPromptRepr.getInt("numParameters"), is(0));
        assertThat(actionPromptRepr.getArray("parameters").size(), is(0));

        final LinkRepresentation invokeLink = actionPromptRepr.getLink("invoke");
        assertThat(invokeLink.getRel(), is("invoke"));
        assertThat(invokeLink.getHref(), matches(".+objects/OID:1/actions/list/invoke"));
        assertThat(invokeLink.getHttpMethod(), is(HttpMethod.POST));
        assertThat(invokeLink.getArguments(), is(not(nullValue())));
        assertThat(invokeLink.getArguments().isArray(), is(true));
        assertThat(invokeLink.getArguments().size(), is(0));
    }
View Full Code Here

        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

public class JsonRepresentationTest_urlEncoding {

    @Test
    public void test() throws UnsupportedEncodingException {
        final LinkRepresentation l = new LinkRepresentation().withRel("object").withHref("http://localhost:8080/objects/ABC:123").withMethod(HttpMethod.GET);

        final String expectedValue = "%7B%22method%22%3A%22GET%22%2C%22rel%22%3A%22object%22%2C%22href%22%3A%22http%3A%2F%2Flocalhost%3A8080%2Fobjects%2FABC%3A123%22%7D";
        @SuppressWarnings("unused")
        final String decoded = URLDecoder.decode(expectedValue, Charsets.UTF_8.name());

        assertThat(l.asUrlEncoded(), is(expectedValue));

    }
View Full Code Here

    }

    @Ignore("TODO")
    @Test
    public void follow_get() throws Exception {
        final LinkRepresentation link = jsonRepresentation.getLink("aLink");

        final String href = link.getHref();

        // when
        context.checking(new Expectations() {
            {
                one(mockExecutor).createRequest(with(any(UriBuilderImpl.class)));
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.json.applib.links.LinkRepresentation

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.