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

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


    @Test
    public void domainObjectRepresentation_noIcon() throws Exception {

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

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


    @Ignore("TODO")
    @Test
    public void domainObjectWithIcon() throws Exception {

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

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

        // then
        final DomainObjectRepresentation objectRepr = restfulResponse.getEntity();

        assertThat(objectRepr.getProperty("name").getString("value"), is("New Name"));
        assertThat(objectRepr.getProperty("flag").getBoolean("value"), is(true));
    }
View Full Code Here

    @Ignore("todo")
    @Test
    public void domainObjectRepresentationContent_Collections() throws Exception {

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

        // then collections

    }
View Full Code Here

    @Ignore("TODO")
    @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"));
View Full Code Here

    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);
        final RestfulResponse<JsonRepresentation> restfulResponse = client.followT(invokeLink, args);

        // then
        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NO_CONTENT));

        // and then simple entity 'flag' property set to false
        final RestfulResponse<DomainObjectRepresentation> restfulResponseAfter = client.followT(linkToSimpleEntity);
        final DomainObjectRepresentation simpleEntityAfter = restfulResponseAfter.getEntity();

        final Boolean after = simpleEntityAfter.getProperty("flag").getBoolean("value");
        assertThat(after, is(!before)); // ie has been toggled
    }
View Full Code Here

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

        // then
        final DomainObjectRepresentation objectRepr = restfulResponse.getEntity();

        assertThat(objectRepr.getRepresentation("members[propertyId=%s].value", "name").asString(), is("New Name"));
        assertThat(objectRepr.getRepresentation("members[propertyId=%s].value", "flag").asBoolean(), is(true));
    }
View Full Code Here

    @Ignore("TODO")
    @Test
    public void domainObjectWithDisabledMembers() throws Exception {

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

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

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

        final JsonRepresentation actionLinkRepr = repr.getAction(actionId);
        return actionLinkRepr.getRepresentation("links[rel=details].value");
    }
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.