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

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


        final RestfulRequest request = client.createRequest(RestfulHttpMethod.GET, href).withArg(RequestParameter.FOLLOW_LINKS, "members[%s].links[rel=%s]", actionId, detailRel);
        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=%s].value", detailRel);
    }
View Full Code Here


    /**
     * For resourceProxy tests; returns the Nth entity in the list returned by invoking the specified repo and action
     */
    public static RestfulResponse<DomainObjectRepresentation> domainObjectJaxrsResponse(RestfulClient client, String repoName, String actionName, int idx) throws Exception {
        final LinkRepresentation link = Util.serviceActionListInvokeFirstReference(client, repoName, actionName, idx);
        DomainObjectRepresentation domainObjectRepr = client.follow(link).getEntity().as(DomainObjectRepresentation.class);

        final Response jaxrsResponse = client.getDomainObjectResource().object(domainObjectRepr.getDomainType(), domainObjectRepr.getInstanceId());
        final RestfulResponse<DomainObjectRepresentation> restfulResponse = RestfulResponse.ofT(jaxrsResponse);
        return restfulResponse;
    }
View Full Code Here


        // given
        final Response serviceResp = domainServiceResource.service("ActionsEntities");
        final RestfulResponse<DomainObjectRepresentation> serviceJsonResp = RestfulResponse.ofT(serviceResp);
        final DomainObjectRepresentation serviceRepr = serviceJsonResp.getEntity();
        final LinkRepresentation selfLink = serviceRepr.getLinkWithRel(Rel.SELF);
        final LinkRepresentation postLink = selfLink.withMethod(RestfulHttpMethod.PUT);

        // when
        final RestfulResponse<JsonRepresentation> restfulResponse = client.follow(postLink);
View Full Code Here

    public void followLink() throws Exception {

        // given
        final Response serviceResp = domainServiceResource.service("ActionsEntities");
        final RestfulResponse<DomainObjectRepresentation> serviceJsonResp = RestfulResponse.ofT(serviceResp);
        final DomainObjectRepresentation servicesRepr = serviceJsonResp.getEntity();
        final LinkRepresentation selfLink = servicesRepr.getLinkWithRel(Rel.SELF);
        final LinkRepresentation postLink = selfLink.withMethod(RestfulHttpMethod.POST);

        // when
        final RestfulResponse<JsonRepresentation> restfulResponse = client.follow(postLink);
View Full Code Here

    public void followLink() throws Exception {

        // given
        final Response serviceResp = domainServiceResource.service("ActionsEntities");
        final RestfulResponse<DomainObjectRepresentation> serviceJsonResp = RestfulResponse.ofT(serviceResp);
        final DomainObjectRepresentation serviceRepr = serviceJsonResp.getEntity();
        final LinkRepresentation upLink = serviceRepr.getLinkWithRel(Rel.UP);
        final LinkRepresentation postLink = upLink.withMethod(RestfulHttpMethod.PUT);

        // when
        final RestfulResponse<JsonRepresentation> restfulResponse = client.follow(postLink);
View Full Code Here

   
    @Test
    public void primitivePropertiesUpdated() throws Exception {
       
        final DomainObjectRepresentation domainObjectRepr = getObjectRepr("PRMV", "43");
       
        final LinkRepresentation updateLink = domainObjectRepr.getLinkWithRel(Rel.UPDATE);
       
        final JsonRepresentation argRepr = updateLink.getArguments();
       
        final byte b = (byte)99;
        final char c = 'b';
        final double d = 12345.678;
        final float f = 54321.123F;
        final int i = 999999;
        final long l = 99999999999L;
        final short s = (short)999;
        final boolean z = false;
        argRepr.mapPut("byteProperty.value", b);
        argRepr.mapPut("charProperty.value", c);
        argRepr.mapPut("doubleProperty.value", d);
        argRepr.mapPut("floatProperty.value", f);
        argRepr.mapPut("intProperty.value", i);
        argRepr.mapPut("longProperty.value", l);
        argRepr.mapPut("shortProperty.value", s);
        argRepr.mapPut("booleanProperty.value", z);
        RestfulResponse<JsonRepresentation> result = client.follow(updateLink, argRepr);
        assertThat(result.getStatus(), is(HttpStatusCode.OK));
       
        final DomainObjectRepresentation afterResp = result.getEntity().as(DomainObjectRepresentation.class);
        assertThat(afterResp.getProperty("byteProperty").getByte("value"), is(b));
        assertThat(afterResp.getProperty("charProperty").getChar("value"), is(c));
        assertThat(afterResp.getProperty("doubleProperty").getDouble("value"), is(d));
        assertThat(afterResp.getProperty("floatProperty").getFloat("value"), is(f));
        assertThat(afterResp.getProperty("intProperty").getInt("value"), is(i));
        assertThat(afterResp.getProperty("longProperty").getLong("value"), is(l));
        assertThat(afterResp.getProperty("shortProperty").getShort("value"), is(s));
        assertThat(afterResp.getProperty("booleanProperty").getBoolean("value"), is(z));
    }
View Full Code Here

    }

    @Test
    public void jdkPropertiesUpdated() throws Exception {
       
        final DomainObjectRepresentation domainObjectRepr = getObjectRepr("JDKV", "38");
        final LinkRepresentation updateLink = domainObjectRepr.getLinkWithRel(Rel.UPDATE);
        final JsonRepresentation argRepr = updateLink.getArguments();

        final BigDecimal bd = new BigDecimal("12345678901234567.789");
        final BigInteger bi = new BigInteger("123456789012345678");
        final java.sql.Date sqld = new java.sql.Date(new DateTime(2014,5,1, 0,0, DateTimeZone.UTC).getMillis());
        final java.sql.Time sqlt = new java.sql.Time(13,0,0);
        final java.sql.Timestamp sqlts = new java.sql.Timestamp(114,4,1,13,0,0,0);
        final java.util.Date d = new DateTime(2014,5,1, 11,45, DateTimeZone.UTC).toDate();
        final String e = "ORANGE";
        final String s = "Tangerine";
       
        argRepr.mapPut("bigDecimalProperty.value", bd);
        argRepr.mapPut("bigIntegerProperty.value", bi);
        argRepr.mapPut("javaSqlDateProperty.value", asIsoNoT(sqld)); // 1-may-2014
        argRepr.mapPut("javaSqlTimeProperty.value", asIsoOnlyT(sqlt)); // 1 pm
        argRepr.mapPut("javaSqlTimestampProperty.value", sqlts.getTime());
        argRepr.mapPut("javaUtilDateProperty.value", asIso(d));
        argRepr.mapPut("myEnum.value", e);
        argRepr.mapPut("stringProperty.value", s);
       
        final RestfulResponse<JsonRepresentation> result = client.follow(updateLink, argRepr);
        assertThat(result.getStatus(), is(HttpStatusCode.OK));
       
        final DomainObjectRepresentation afterResp = result.getEntity().as(DomainObjectRepresentation.class);
       
        assertThat(afterResp.getProperty("bigDecimalProperty").getBigDecimal("value"), is(new BigDecimal("12345678901234567.7890000000"))); // big-decimal(30,10)
        assertThat(afterResp.getProperty("bigIntegerProperty").getBigInteger("value"), is(bi));
        assertThat(afterResp.getProperty("javaSqlDateProperty").getDate("value"), is((java.util.Date)sqld));
        assertThat(afterResp.getProperty("javaSqlTimeProperty").getTime("value"), is((java.util.Date)sqlt));
        assertThat(afterResp.getProperty("javaSqlTimestampProperty").getLong("value"), is(sqlts.getTime()));
        assertThat(afterResp.getProperty("javaUtilDateProperty").getDateTime("value"), is(d));
        assertThat(afterResp.getProperty("myEnum").getString("value"), is(e));
        assertThat(afterResp.getProperty("stringProperty").getString("value"), is(s));
       
    }
View Full Code Here

    }

    @Test
    public void jodaPropertiesUpdated() throws Exception {
       
        final DomainObjectRepresentation domainObjectRepr = getObjectRepr("JODA", "83");
       
        final LinkRepresentation updateLink = domainObjectRepr.getLinkWithRel(Rel.UPDATE);
       
        final JsonRepresentation argRepr = updateLink.getArguments();
       
        final LocalDate ld = new LocalDate(2013,5,1);
        final LocalDateTime ldt = new LocalDateTime(2013,2,1,14,15,0);
        final DateTime dt = new DateTime(2013,2,1,14,15,0, DateTimeZone.UTC);
        final String s = "New string";
       
        argRepr.mapPut("localDateProperty.value", "2013-05-01");
        argRepr.mapPut("localDateTimeProperty.value", "2013-02-01T14:15:00Z");
        argRepr.mapPut("dateTimeProperty.value", asIso(dt.toDate()));
        argRepr.mapPut("stringProperty.value", s);

        final RestfulResponse<JsonRepresentation> result = client.follow(updateLink, argRepr);
        assertThat(result.getStatus(), is(HttpStatusCode.OK));
       
        final DomainObjectRepresentation afterResp = result.getEntity().as(DomainObjectRepresentation.class);
       
        assertThat(afterResp.getProperty("localDateProperty").getString("value"), is("2013-05-01")); // being a bit hacky here...
        assertThat(afterResp.getProperty("localDateTimeProperty").getDateTime("value"), is(ldt.toDate()));
        assertThat(afterResp.getProperty("dateTimeProperty").getDateTime("value"), is(dt.toDate()));
        assertThat(afterResp.getProperty("stringProperty").getString("value"), is(s));
    }
View Full Code Here

    private DomainObjectRepresentation getObjectRepr(final String domainType, final String instanceId) throws JsonParseException, JsonMappingException, IOException {
        final Response domainObjectResp = domainObjectResource.object(domainType, instanceId);
        final RestfulResponse<DomainObjectRepresentation> domainObjectJsonResp = RestfulResponse.ofT(domainObjectResp);
        assertThat(domainObjectJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));

        final DomainObjectRepresentation domainObjectRepr = domainObjectJsonResp.getEntity();
        return domainObjectRepr;
    }
View Full Code Here

    @Ignore("TODO")
    @Test
    public void xxx() 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

TOP

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