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

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


        // given
        final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "subList");
        final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);

        final LinkRepresentation invokeLink = actionRepr.getInvoke();

        assertThat(invokeLink, isLink(client)
                                    .rel(Rel.INVOKE)
                                    .httpMethod(RestfulHttpMethod.GET)
                                    .href(Matchers.endsWith(":39393/services/ActionsEntities/actions/subList/invoke"))
                                    .build());
       
        JsonRepresentation args =invokeLink.getArguments();
        assertThat(args.size(), is(2));
        assertThat(args, RestfulMatchers.mapHas("from"));
        assertThat(args, RestfulMatchers.mapHas("to"));
       
        // when
View Full Code Here


        // given
        final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "findByIdIdempotent");
        final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);

        final LinkRepresentation invokeLink = actionRepr.getInvoke();
        final JsonRepresentation args =invokeLink.getArguments();
       
        // when
        args.mapPut("id.value", 1);

        // when
View Full Code Here

        // given
        final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "findById");
        final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);

        final LinkRepresentation invokeLink = actionRepr.getInvoke();
        final JsonRepresentation args =invokeLink.getArguments();
       
        // when
        args.mapPut("id.value", 1);

        // when
View Full Code Here

        // given
        final JsonRepresentation givenAction = Util.givenAction(client, "ActionsEntities", "findById");
        final ObjectActionRepresentation actionRepr = givenAction.as(ObjectActionRepresentation.class);

        final LinkRepresentation invokeLink = actionRepr.getInvoke();
        final JsonRepresentation args =invokeLink.getArguments();
       
        // when
        args.mapPut("id.value", 999);

        // when
View Full Code Here

        final ObjectActionRepresentation actionPromptRepr = actionPromptJsonResp.getEntity();

        assertThat(actionPromptRepr.getString("memberType"), is("action"));

        // self link
        final LinkRepresentation selfLink = actionPromptRepr.getLinkWithRel(Rel.SELF);
        assertThat(selfLink, isLink(client)
                                .httpMethod(RestfulHttpMethod.GET)
                                .href(endsWith("/objects/RTNE/67/actions/contains"))
                                .returning(HttpStatusCode.OK));

        // up link
        final LinkRepresentation upLink = actionPromptRepr.getLinkWithRel(Rel.UP);
        assertThat(upLink, isLink(client)
                                .httpMethod(RestfulHttpMethod.GET)
                                .href(endsWith("/objects/RTNE/67"))
                                .returning(HttpStatusCode.OK)
                                .type(RepresentationType.DOMAIN_OBJECT.getMediaType())
                                .title("Untitled Actions Entity"));

        //invoke link
        final LinkRepresentation invokeLink = actionPromptRepr.getLinkWithRel(Rel.INVOKE);
        assertThat(invokeLink, isLink(client)
                                .httpMethod(RestfulHttpMethod.GET)
                                .href(endsWith("/services/ActionsEntities/actions/contains/invoke")));

        assertThat(invokeLink.getArguments(), is(not(nullValue())));
        assertThat(invokeLink.getArguments().isArray(), is(false));
        assertThat(invokeLink.getArguments().size(), is(3));

     // described by link
        final LinkRepresentation describedByLink = actionPromptRepr.getLinkWithRel(Rel.DESCRIBEDBY);
        assertThat(describedByLink, isLink(client)
                                .returning(HttpStatusCode.OK)
                                .responseEntityWithSelfHref(describedByLink.getHref()));

        assertThat(actionPromptRepr.getExtensions().getString("actionType"), is("user"));
        assertThat(actionPromptRepr.getExtensions().getString("actionSemantics"), is("safe"));
        assertThat(actionPromptRepr.getArray("parameters").size(), is(3));
    }
View Full Code Here

    @Test
    public void usingClientFollow() throws Exception {

        // given
        final LinkRepresentation link = Util.domainObjectLink(client, "PrimitiveValuedEntities");
        link.withHref("http://localhost:39393/objects/PRMV/nonExistent");
       
        // when
        final RestfulResponse<JsonRepresentation> restfulResp = client.follow(link);
       
        // then
View Full Code Here

    @Test
    public void thenMembers() throws Exception {

        // when
        final LinkRepresentation link = Util.domainObjectLink(client, "PrimitiveValuedEntities");
        domainObjectRepr = client.follow(link).getEntity().as(DomainObjectRepresentation.class);

        // then members (types)
        DomainObjectMemberRepresentation property;
        ScalarValueRepresentation scalarRepr;
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

    @Test
    public void thenMembers() throws Exception {

        // when
        final LinkRepresentation link = Util.domainObjectLink(client, "JodaValuedEntities");
        domainObjectRepr = client.follow(link).getEntity().as(DomainObjectRepresentation.class);

        // and then members (types)
        DomainObjectMemberRepresentation property;
        ScalarValueRepresentation scalarRepr;
View Full Code Here

    @Test
    public void thenTitle_andExtensions_andLinks() throws Exception {

        // when
        final LinkRepresentation link = Util.domainObjectLink(client, "PrimitiveValuedEntities");
        domainObjectRepr = client.follow(link).getEntity().as(DomainObjectRepresentation.class);

        // then has domain type, instanceId, title
        assertThat(domainObjectRepr, is(not(nullValue())));

        assertThat(domainObjectRepr.getTitle(), is("Primitive Valued Entity #0")); // running in-memory
        assertThat(domainObjectRepr.getDomainType(), is("PRMV"));
        assertThat(domainObjectRepr.getInstanceId(), is(not(nullValue())));
       
        // and then extensions
        assertThat(domainObjectRepr.getExtensions().getString("oid"), IsisMatchers.startsWith("PRMV:" + domainObjectRepr.getInstanceId()));
        assertThat(domainObjectRepr.getExtensions().getBoolean("isService"), is(false));
        assertThat(domainObjectRepr.getExtensions().getBoolean("isPersistent"), is(true));

        // and then has links
        final LinkRepresentation self = domainObjectRepr.getSelf();
        assertThat(self, isLink()
                            .rel(Rel.SELF)
                            .href(matches(".+\\/objects\\/PRMV\\/\\d+"))
                            .httpMethod(RestfulHttpMethod.GET)
                            .type(RepresentationType.DOMAIN_OBJECT.getMediaType()));
View Full Code Here

TOP

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