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

Examples of org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectMemberRepresentation


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

        // then members (types)
        DomainObjectMemberRepresentation property;
        ScalarValueRepresentation scalarRepr;
       
        property = domainObjectRepr.getProperty("booleanProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is(nullValue()));
        assertThat(property.getXIsisFormat(), is("boolean"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isBoolean(), is(true));
        Boolean booleanValue = scalarRepr.asBoolean();
        assertThat(booleanValue, is(true));
       
        property = domainObjectRepr.getProperty("byteProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is(nullValue()));
        assertThat(property.getXIsisFormat(), is("byte"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isIntegralNumber(), is(true));
        Byte byteValue = scalarRepr.asByte();
        assertThat(byteValue, is((byte)123));

        property = domainObjectRepr.getProperty("shortProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is(nullValue()));
        assertThat(property.getXIsisFormat(), is("short"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isIntegralNumber(), is(true));
        Short shortValue = scalarRepr.asShort();
        assertThat(shortValue, is((short)32123));

        property = domainObjectRepr.getProperty("intProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("int"));
        assertThat(property.getXIsisFormat(), is("int"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isInt(), is(true));
        Integer intValue = scalarRepr.asInt();
        assertThat(intValue, is(987654321));

        property = domainObjectRepr.getProperty("longProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("int"));
        assertThat(property.getXIsisFormat(), is("long"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isLong(), is(true));
        Long longValue = scalarRepr.asLong();
        assertThat(longValue, is(2345678901234567890L));

        property = domainObjectRepr.getProperty("charProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is(nullValue()));
        assertThat(property.getXIsisFormat(), is("char"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isString(), is(true));
        Character charValue = scalarRepr.asChar();
        assertThat(charValue, is('a'));
       
        property = domainObjectRepr.getProperty("floatProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("decimal"));
        assertThat(property.getXIsisFormat(), is("float"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isNumber(), is(true));
        assertThat(scalarRepr.isIntegralNumber(), is(false));
        Float floatValue = scalarRepr.asFloat();
        assertThat(floatValue, is(12345678901234567890.1234567890F));
       
        property = domainObjectRepr.getProperty("doubleProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("decimal"));
        assertThat(property.getXIsisFormat(), is("double"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isDouble(), is(true));
        Double doubleValue = scalarRepr.asDouble();
        assertThat(doubleValue, is(12345678901234567890.1234567890));
       
       
        // and then member types have links to details (selected ones inspected only)
        property = domainObjectRepr.getProperty("booleanProperty");
        assertThat(property.getLinkWithRel(Rel.DETAILS),
                isLink()
                    .href(matches(".+\\/objects\\/PRMV\\/\\d+\\/properties\\/booleanProperty"))
                    .httpMethod(RestfulHttpMethod.GET)
                    .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));

        property = domainObjectRepr.getProperty("byteProperty");
        assertThat(property.getLinkWithRel(Rel.DETAILS),
                isLink()
                    .href(matches(".+\\/objects\\/PRMV\\/\\d+\\/properties\\/byteProperty"))
                    .httpMethod(RestfulHttpMethod.GET)
                    .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));

        property = domainObjectRepr.getProperty("shortProperty");
        assertThat(property.getLinkWithRel(Rel.DETAILS),
                isLink()
                    .href(matches(".+\\/objects\\/PRMV\\/\\d+\\/properties\\/shortProperty"))
                    .httpMethod(RestfulHttpMethod.GET)
                    .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));
    }
View Full Code Here


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

        // and then members (types)
        DomainObjectMemberRepresentation property;
        ScalarValueRepresentation scalarRepr;
       
        property = domainObjectRepr.getProperty("localDateProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("date"));
        assertThat(property.getXIsisFormat(), is("jodalocaldate"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isString(), is(true));
        java.util.Date dateValue = scalarRepr.asDate();
        assertThat(dateValue, is(asDate("2008-03-21")));
       
        property = domainObjectRepr.getProperty("localDateTimeProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("date-time"));
        assertThat(property.getXIsisFormat(), is("jodalocaldatetime"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isString(), is(true));
        java.util.Date dateTimeValue = scalarRepr.asDateTime();
        assertThat(dateTimeValue, is(not(nullValue())));
        assertThat(scalarRepr.asString(), IsisMatchers.startsWith("2009-04-29T13:45:22+0100"));

        // and then member types have links to details (selected ones inspected only)
        property = domainObjectRepr.getProperty("localDateProperty");
        assertThat(property.getLinkWithRel(Rel.DETAILS),
                isLink()
                    .href(matches(".+\\/objects\\/JODA\\/\\d+\\/properties\\/localDateProperty"))
                    .httpMethod(RestfulHttpMethod.GET)
                    .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));

        property = domainObjectRepr.getProperty("localDateTimeProperty");
        assertThat(property.getLinkWithRel(Rel.DETAILS),
                isLink()
                    .href(matches(".+\\/objects\\/JODA\\/\\d+\\/properties\\/localDateTimeProperty"))
                    .httpMethod(RestfulHttpMethod.GET)
                    .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));
    }
View Full Code Here

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

        // and then members (types)
        DomainObjectMemberRepresentation property;
        ScalarValueRepresentation scalarRepr;

       
        // copy from Get_givenEntityWithPrimitiveProperties_thenRepresentation_ok
    }
View Full Code Here

       
        assertThat(repr.getSelf(), isLink().httpMethod(RestfulHttpMethod.GET));
       
        assertThat(repr.getMembers(), isMap());
        assertThat(repr.getMembers().size(), is(2));
        DomainObjectMemberRepresentation listMemberRepr = repr.getAction("list");
       
        assertThat(listMemberRepr.getMemberType(), is("action"));
        assertThat(listMemberRepr.getDisabledReason(), is(nullValue()));
        assertThat(listMemberRepr.getLinks(), isArray());
        assertThat(listMemberRepr.getLinks().size(), is(1));
       
        LinkRepresentation listMemberReprDetailsLink = listMemberRepr.getLinkWithRel(Rel.DETAILS);
        assertThat(listMemberReprDetailsLink, isLink(client)
                                       .httpMethod(RestfulHttpMethod.GET)
                                       .href(endsWith("/services/JdkValuedEntities/actions/list"))
                                       .returning(HttpStatusCode.OK)
                                       .responseEntityWithSelfHref(listMemberReprDetailsLink.getHref()));
View Full Code Here

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

        assertThat(repr, isMap());

        final DomainObjectMemberRepresentation actionRepr = repr.getAction("visibleAndInvocableAction");
        assertThat(actionRepr, isMap());

        assertThat(actionRepr.getDisabledReason(), is(nullValue()));

        final LinkRepresentation actionDetailsLink = actionRepr.getLinkWithRel(Rel.DETAILS);
        assertThat(actionDetailsLink, isLink(this.client)
                                        .rel(Rel.DETAILS)
                                        .httpMethod(RestfulHttpMethod.GET)
                                        .href(Matchers.endsWith(":39393/services/BusinessRulesEntities/actions/visibleAndInvocableAction"))
                                        .returning(HttpStatusCode.OK));
View Full Code Here

        // then
        assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
        final DomainObjectRepresentation repr = jsonResp.getEntity();

        final DomainObjectMemberRepresentation actionRepr = repr.getAction("visibleButNotInvocableAction");
        assertThat(actionRepr, isMap());

        assertThat(actionRepr.getDisabledReason(), is("Always disabled"));

        final LinkRepresentation actionDetailsLink = actionRepr.getLinkWithRel(Rel.DETAILS);

        // even though not invocable, still can traverse to its details page
        assertThat(actionDetailsLink, isLink(this.client)
                                        .href(Matchers.endsWith(":39393/services/BusinessRulesEntities/actions/visibleButNotInvocableAction"))
                                        .returning(HttpStatusCode.OK));
View Full Code Here

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


        // and then members (types)
        DomainObjectMemberRepresentation property;
        ScalarValueRepresentation scalarRepr;
       
        property = domainObjectRepr.getProperty("booleanProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is(nullValue()));
        assertThat(property.getXIsisFormat(), is("boolean"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isBoolean(), is(true));
        Boolean booleanValue = scalarRepr.asBoolean();
        assertThat(booleanValue, is(true));
       
        property = domainObjectRepr.getProperty("byteProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is(nullValue()));
        assertThat(property.getXIsisFormat(), is("byte"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isIntegralNumber(), is(true));
        Byte byteValue = scalarRepr.asByte();
        assertThat(byteValue, is((byte)123));

        property = domainObjectRepr.getProperty("shortProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is(nullValue()));
        assertThat(property.getXIsisFormat(), is("short"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isIntegralNumber(), is(true));
        Short shortValue = scalarRepr.asShort();
        assertThat(shortValue, is((short)32123));

        property = domainObjectRepr.getProperty("integerProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("int"));
        assertThat(property.getXIsisFormat(), is("int"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isInt(), is(true));
        Integer intValue = scalarRepr.asInt();
        assertThat(intValue, is(987654321));

        property = domainObjectRepr.getProperty("longProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("int"));
        assertThat(property.getXIsisFormat(), is("long"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isLong(), is(true));
        Long longValue = scalarRepr.asLong();
        assertThat(longValue, is(2345678901234567890L));

        property = domainObjectRepr.getProperty("characterProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is(nullValue()));
        assertThat(property.getXIsisFormat(), is("char"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isString(), is(true));
        Character charValue = scalarRepr.asChar();
        assertThat(charValue, is('a'));
       
        property = domainObjectRepr.getProperty("floatProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("decimal"));
        assertThat(property.getXIsisFormat(), is("float"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isNumber(), is(true));
        assertThat(scalarRepr.isIntegralNumber(), is(false));
        Float floatValue = scalarRepr.asFloat();
        assertThat(floatValue, is(12345678901234567890.1234567890F));
       
        property = domainObjectRepr.getProperty("doubleProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("decimal"));
        assertThat(property.getXIsisFormat(), is("double"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isDouble(), is(true));
        Double doubleValue = scalarRepr.asDouble();
        assertThat(doubleValue, is(12345678901234567890.1234567890));
       
       
        // and then member types have links to details (selected ones inspected only)
        property = domainObjectRepr.getProperty("booleanProperty");
        assertThat(property.getLinkWithRel(Rel.DETAILS),
                isLink()
                    .href(matches(".+\\/objects\\/WRPV\\/\\d+\\/properties\\/booleanProperty"))
                    .httpMethod(RestfulHttpMethod.GET)
                    .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));

        property = domainObjectRepr.getProperty("byteProperty");
        assertThat(property.getLinkWithRel(Rel.DETAILS),
                isLink()
                    .href(matches(".+\\/objects\\/WRPV\\/\\d+\\/properties\\/byteProperty"))
                    .httpMethod(RestfulHttpMethod.GET)
                    .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));

        property = domainObjectRepr.getProperty("shortProperty");
        assertThat(property.getLinkWithRel(Rel.DETAILS),
                isLink()
                    .href(matches(".+\\/objects\\/WRPV\\/\\d+\\/properties\\/shortProperty"))
                    .httpMethod(RestfulHttpMethod.GET)
                    .type(RepresentationType.OBJECT_PROPERTY.getMediaType()));
    }
View Full Code Here

       
        assertThat(repr.getSelf(), isLink().httpMethod(RestfulHttpMethod.GET));
       
        assertThat(repr.getMembers(), isMap());
        assertThat(repr.getMembers().size(), is(2));
        DomainObjectMemberRepresentation listMemberRepr = repr.getAction("list");
       
        assertThat(listMemberRepr.getMemberType(), is("action"));
        assertThat(listMemberRepr.getDisabledReason(), is(nullValue()));
        assertThat(listMemberRepr.getLinks(), isArray());
        assertThat(listMemberRepr.getLinks().size(), is(1));
       
        LinkRepresentation listMemberReprDetailsLink = listMemberRepr.getLinkWithRel(Rel.DETAILS);
        assertThat(listMemberReprDetailsLink, isLink(client)
                                       .httpMethod(RestfulHttpMethod.GET)
                                       .href(endsWith("/services/JdkValuedEntities/actions/list"))
                                       .returning(HttpStatusCode.OK)
                                       .responseEntityWithSelfHref(listMemberReprDetailsLink.getHref()));
View Full Code Here

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

        assertThat(repr, isMap());

        final DomainObjectMemberRepresentation actionRepr = repr.getAction("visibleAndInvocableAction");
        assertThat(actionRepr, isMap());

        assertThat(actionRepr.getDisabledReason(), is(nullValue()));

        final LinkRepresentation actionDetailsLink = actionRepr.getLinkWithRel(Rel.DETAILS);
        assertThat(actionDetailsLink, isLink(this.client)
                                        .rel(Rel.DETAILS)
                                        .httpMethod(RestfulHttpMethod.GET)
                                        .href(Matchers.endsWith(":39393/services/BusinessRulesEntities/actions/visibleAndInvocableAction"))
                                        .returning(HttpStatusCode.OK));
View Full Code Here

        // then
        assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
        final DomainObjectRepresentation repr = jsonResp.getEntity();

        final DomainObjectMemberRepresentation actionRepr = repr.getAction("visibleButNotInvocableAction");
        assertThat(actionRepr, isMap());

        assertThat(actionRepr.getDisabledReason(), is("Always disabled"));

        final LinkRepresentation actionDetailsLink = actionRepr.getLinkWithRel(Rel.DETAILS);

        // even though not invocable, still can traverse to its details page
        assertThat(actionDetailsLink, isLink(this.client)
                                        .href(Matchers.endsWith(":39393/services/BusinessRulesEntities/actions/visibleButNotInvocableAction"))
                                        .returning(HttpStatusCode.OK));
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectMemberRepresentation

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.