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

Examples of org.apache.isis.viewer.json.applib.domainobjects.DomainObjectRepresentation


    private DomainObjectRepresentation representation;

    @Before
    public void setUp() throws Exception {
        representation = new DomainObjectRepresentation(readJson("domainObjectRepresentation.json"));
    }
View Full Code Here


        final RestfulResponse<DomainObjectRepresentation> jsonResp = RestfulResponse.ofT(resp);

        // then
        assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));

        final DomainObjectRepresentation repr = jsonResp.getEntity();

        assertThat(repr, isMap());

        assertThat(repr.getSelf(), isLink().httpMethod(HttpMethod.GET));
        assertThat(repr.getOid(), matches("OID[:].+"));
        assertThat(repr.getTitle(), matches("Simples"));

        assertThat(repr.getMembers(), isArray());

        assertThat(repr.getLinks(), isArray());
        assertThat(repr.getExtensions(), isMap());
    }
View Full Code Here

    }

    @Test
    public void self_isFollowable() throws Exception {
        // given
        final DomainObjectRepresentation repr = givenRepresentation("simples");

        // when, then
        assertThat(repr, isFollowableLinkToSelf(client));
    }
View Full Code Here

    }

    @Test
    public void links() throws Exception {
        // given, when
        final DomainObjectRepresentation repr = givenRepresentation("simples");

        // then
        assertThat(repr.getLinks().size(), is(3));
    }
View Full Code Here

        final Response domainObjectResp = domainObjectResource.object("OID:6");
        final RestfulResponse<DomainObjectRepresentation> domainObjectJsonResp = RestfulResponse.ofT(domainObjectResp);
        assertThat(domainObjectJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));

        // then
        final DomainObjectRepresentation domainObjectRepr = domainObjectJsonResp.getEntity();
        assertThat(domainObjectRepr, is(not(nullValue())));
    }
View Full Code Here

    @Test
    public void domainObjectRepresentationForPersistentObject_hasSelfAndOid() throws Exception {

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

        final RestfulResponse<ActionResultRepresentation> response = request.executeT();
        final ActionResultRepresentation actionResultRepr = response.getEntity();
        assertThat(actionResultRepr.getResultType(), is(ResultType.DOMAIN_OBJECT));
        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

    @Test
    public void domainObjectRepresentation_hasTitle() throws Exception {

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

        // then
        assertThat(domainObjectRepr.getTitle(), is("parent 4 - child 2"));
    }
View Full Code Here

    @Test
    public void domainObjectRepresentation_hasDescribedByLink() throws Exception {

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

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

        final RestfulRequest request = client.createRequest(HttpMethod.GET, href).withArg(RequestParameter.FOLLOW_LINKS, "members[id=%s].links[rel=details]", "list");
        final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();

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

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

        JsonRepresentation actionRepr;

        actionRepr = membersList.getRepresentation("[id=%s]", "list");
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.json.applib.domainobjects.DomainObjectRepresentation

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.