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

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


        final JsonRepresentation entityRepr = restResp.getEntity();
        domainObjectRepr = entityRepr.as(DomainObjectRepresentation.class);

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

        property = domainObjectRepr.getProperty("bigDecimalProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("big-decimal(30,10)"));
        assertThat(property.getXIsisFormat(), is("javamathbigdecimal"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isString(), is(true));
        BigDecimal bigDecimal = scalarRepr.asBigDecimal(property.getFormat());
        assertThat(bigDecimal, is(new BigDecimal("12345678901234567890.1234567890")));

        property = domainObjectRepr.getProperty("bigDecimalProperty2");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("big-decimal(18,2)"));
        assertThat(property.getXIsisFormat(), is("javamathbigdecimal"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isString(), is(true));
        BigDecimal bigDecimal2 = scalarRepr.asBigDecimal(property.getFormat());
        assertThat(bigDecimal2, is(new BigDecimal("123.45")));

        property = domainObjectRepr.getProperty("bigIntegerProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("big-integer"));
        assertThat(property.getXIsisFormat(), is("javamathbiginteger"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isString(), is(true));
        BigInteger bigInteger = scalarRepr.asBigInteger(property.getFormat());
        assertThat(bigInteger, is(new BigInteger("123456789012345678")));

        property = domainObjectRepr.getProperty("bigIntegerProperty2");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("big-integer"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isString(), is(true));
        BigInteger bigInteger2 = scalarRepr.asBigInteger(property.getFormat());
        assertThat(bigInteger2, is(new BigInteger("12345")));

        property = domainObjectRepr.getProperty("javaSqlDateProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("date"));
        assertThat(property.getXIsisFormat(), is("javasqldate"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isString(), is(true));
        assertThat(scalarRepr.asString(), is("2014-04-24"));
        assertThat(scalarRepr.asDate(), is(asDate("2014-04-24")));

        property = domainObjectRepr.getProperty("javaSqlTimeProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("time"));
        assertThat(property.getXIsisFormat(), is("javasqltime"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isString(), is(true));
        assertThat(scalarRepr.asString(), is("12:34:45"));
        assertThat(scalarRepr.asTime(), is(asDateTime("1970-01-01T12:34:45Z")));

        property = domainObjectRepr.getProperty("javaSqlTimestampProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("utc-millisec"));
        assertThat(property.getXIsisFormat(), is("javasqltimestamp"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isInt() || scalarRepr.isLong(), is(true));
        Long aLong = scalarRepr.asLong();
        assertThat(aLong, is(new Long("1234567890")));

        property = domainObjectRepr.getProperty("javaUtilDateProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("date-time"));
        assertThat(property.getXIsisFormat(), is("javautildate"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isString(), is(true));
        Date utilDate = scalarRepr.asDateTime();
        assertThat(utilDate, is(asDateTime("2013-05-25T12:34:45Z")));
        assertThat(scalarRepr.asString(), is("2013-05-25T12:34:45Z"));

        property = domainObjectRepr.getProperty("myEnum");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("string"));
        assertThat(property.getXIsisFormat(), is("string"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isString(), is(true));
        String myEnumStr = scalarRepr.asString();
        assertThat(myEnumStr, is("RED"));
    }
View Full Code Here


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

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

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

        property = domainObjectRepr.getProperty("dateTimeProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("date-time"));
        assertThat(property.getXIsisFormat(), is("jodadatetime"));
        scalarRepr = property.getRepresentation("value").as(ScalarValueRepresentation.class);
        assertThat(scalarRepr.isString(), is(true));
        assertThat(scalarRepr.asDateTime(), is(asDateTime("2010-03-31T09:50:43Z")));
        assertThat(scalarRepr.asString(), is("2010-03-31T09:50:43Z"));

        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));
        assertThat(scalarRepr.asDate(), is(asDate("2008-03-21")));
        assertThat(scalarRepr.asString(), is("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));

        final LocalDateTime expected = new LocalDateTime(2009, 4, 29, 13, 45, 22);

        assertThat(scalarRepr.asDateTime(), is(expected.toDate()));
        assertThat(scalarRepr.asString(), is(ISODateTimeFormat.dateTimeNoMillis().withZoneUTC().print(expected.toDateTime())));

        // and then member types have links to details (selected ones inspected only)
        property = domainObjectRepr.getProperty("localDateProperty");
        assertThat(property.getLinkWithRel(Rel.DETAILS),
                isLink()
View Full Code Here

        final LinkRepresentation link = Util.serviceActionListInvokeFirstReference(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

        final LinkRepresentation link = Util.serviceActionListInvokeFirstReference(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(equalTo(Boolean.TRUE)));
       
        property = domainObjectRepr.getProperty("byteProperty");
        assertThat(property.getMemberType(), is("property"));
        assertThat(property.getFormat(), is("int"));
        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("int"));
        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)
View Full Code Here

        final RestfulResponse<ActionResultRepresentation> restfulResponse = RestfulResponse.ofT(response);
       
        // then
        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
        final ActionResultRepresentation entity = restfulResponse.getEntity();
        final ScalarValueRepresentation svr = entity.getResult().as(ScalarValueRepresentation.class);
        assertThat(svr.getValue().asString(), is("abc+defHOORAY"));
    }
View Full Code Here

    }

    private void then(RestfulResponse<ActionResultRepresentation> restfulResponse, final String expected) throws Exception {
        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
        final ActionResultRepresentation entity = restfulResponse.getEntity();
        final ScalarValueRepresentation svr = entity.getResult().as(ScalarValueRepresentation.class);
        assertThat(svr.getValue().asString(), is(expected));
    }
View Full Code Here

        ActionResultRepresentation actionResultRepr = restfulResponse.getEntity();
        assertThat(actionResultRepr.getResultType(), is(ResultType.SCALAR_VALUE));
        JsonRepresentation resultRepr = actionResultRepr.getResult();
        assertThat(resultRepr, is(not(nullValue())));
       
        ScalarValueRepresentation scalarValueRepr = resultRepr.as(ScalarValueRepresentation.class);
       
        LinkRepresentation returnTypeLink = scalarValueRepr.getLinkWithRel(Rel.RETURN_TYPE);
        assertThat(returnTypeLink, is(not(nullValue())));
        assertThat(returnTypeLink, isLink(client)
                                        .rel(Rel.RETURN_TYPE)
                                        .href(Matchers.endsWith(":39393/domain-types/boolean"))
                                        .returning(HttpStatusCode.OK)
                                        .build());
       
        assertThat(scalarValueRepr.getValue().asBoolean(), is(value));
    }
View Full Code Here

        final LinkRepresentation link = Util.domainObjectLink(client, "JdkValuedEntities");
        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

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

TOP

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

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.