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

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


    private LinkRepresentation link;
    private JsonRepresentation jsonRepresentation;

    @Before
    public void setUp() throws Exception {
        link = new LinkRepresentation().withHref("http://foo/bar").withMethod(HttpMethod.GET);
        jsonRepresentation = new JsonRepresentation(readJson("map.json"));
    }
View Full Code Here


                @Override
                public boolean matchesSafely(final JsonRepresentation linkRepr) {
                    if (linkRepr == null) {
                        return false;
                    }
                    final LinkRepresentation link = linkRepr.asLink();
                    if (rel != null && !rel.equals(link.getRel())) {
                        return false;
                    }
                    if (href != null && !href.equals(link.getHref())) {
                        return false;
                    }
                    if (hrefMatcher != null && !hrefMatcher.matches(link.getHref())) {
                        return false;
                    }
                    if (httpMethod != null && !httpMethod.equals(link.getHttpMethod())) {
                        return false;
                    }
                    if (mediaType != null && !mediaType.isCompatible(mediaType)) {
                        return false;
                    }
                    if (typeParameterName != null) {
                        final MediaType mediaType = link.getType();
                        final String parameterValue = mediaType.getParameters().get(typeParameterName);
                        if (!typeParameterValue.equals(parameterValue)) {
                            return false;
                        }
                    }
                    if (novalue != null && novalue && link.getValue() != null) {
                        return false;
                    }
                    if (valueMatcher != null && !valueMatcher.matches(link)) {
                        return false;
                    }
View Full Code Here

        for (final LinkRepresentation link : values.arrayIterable(LinkRepresentation.class)) {
            final RestfulResponse<JsonRepresentation> followJsonResp = client.follow(link);
            assertThat(followJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));

            final JsonRepresentation followRepr = followJsonResp.getEntity();
            final LinkRepresentation self = followRepr.getLink("links[rel=self]");

            assertThat(self.getHref(), is(link.getHref()));
        }
    }
View Full Code Here

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

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

        // then
        assertThat(invokeLink, is(not(nullValue())));
        final RestfulResponse<ListRepresentation> restfulResponse = client.followT(invokeLink);
        final ListRepresentation listRepr = restfulResponse.getEntity();
View Full Code Here

        // 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
View Full Code Here

        // 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);
View Full Code Here

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

        // given simple entity with 'flag' property set to true
        final LinkRepresentation linkToSimpleEntity = givenLinkToSimpleEntity(0);
        final RestfulResponse<DomainObjectRepresentation> restfulResponseBefore = client.followT(linkToSimpleEntity);
        final DomainObjectRepresentation simpleEntityBefore = restfulResponseBefore.getEntity();
        final Boolean before = simpleEntityBefore.getProperty("flag").getBoolean("value");

        // and given 'toggle' action on repo
        final JsonRepresentation givenAction = givenAction("simples", "toggle");
        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(1));
        assertThat(args.mapHas("object"), is(true));

        // when
        args.mapPut("object", linkToSimpleEntity);
View Full Code Here

    @org.junit.Ignore("up to here")
    @Test
    public void invoke_withAllBuiltInArgs_usingClientFollow() throws Exception {

        // given simple entity with 'flag' property set to true
        final LinkRepresentation linkToSimpleEntity = givenLinkToSimpleEntity(0);

        // given
        final JsonRepresentation givenAction = givenAction("simples", "update");
        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));
        assertThat(args.mapHas("object"), is(true));
        assertThat(args.mapHas("name"), is(true));
        assertThat(args.mapHas("flag"), is(true));
        assertThat(args.mapHas("Boolean"), is(true));
View Full Code Here

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

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

        // then
        final RestfulResponse<ListRepresentation> restfulResponse = client.followT(invokeLink);
        final ListRepresentation listRepr = restfulResponse.getEntity();
View Full Code Here

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

        // then
        final LinkRepresentation self = domainObjectRepr.getSelf();
        assertThat(self, isLink().rel(Rel.SELF).href(matches(".+objects/OID:32")).httpMethod(HttpMethod.GET).type(MediaType.APPLICATION_JSON_TYPE).typeParameter("profile", "urn:org.restfulobjects/domainobject"));
        assertThat(domainObjectRepr.getLinkWithRel(Rel.DESCRIBEDBY), isLink().href(matches(".+" + ChildEntity.class.getName())).httpMethod(HttpMethod.GET).type(MediaType.APPLICATION_JSON_TYPE).typeParameter("profile", "urn:org.restfulobjects/domaintype"));

        assertThat(domainObjectRepr.getTitle(), is("parent 4 - child 2"));
        assertThat(domainObjectRepr.getOid(), is("OID:32"));

        // no icon
        final LinkRepresentation selfIcon = domainObjectRepr.getLinkWithRel(Rel.ICON);
        assertThat(selfIcon, is(nullValue()));
    }
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.