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

Examples of org.apache.isis.viewer.json.applib.JsonRepresentation$LinksToSelf


        throw new IllegalStateException("Unable to locate contributing service");
    }

    @Override
    protected JsonRepresentation mutatorArgs(final MutatorSpec mutatorSpec) {
        final JsonRepresentation argMap = JsonRepresentation.newMap();
        final List<ObjectActionParameter> parameters = objectMember.getParameters();
        for (int i = 0; i < objectMember.getParameterCount(); i++) {
            argMap.mapPut(parameters.get(i).getId(), argValueFor(i));
        }
        return argMap;
    }
View Full Code Here


        representation.mapPut("parameters", parameters);
        return this;
    }

    private Object paramDetails(final ObjectActionParameter param) {
        final JsonRepresentation paramRep = JsonRepresentation.newMap();
        paramRep.mapPut("num", param.getNumber());
        paramRep.mapPut("id", param.getId());
        paramRep.mapPut("name", param.getName());
        paramRep.mapPut("description", param.getDescription());
        final Object paramChoices = choicesFor(param);
        if (paramChoices != null) {
            paramRep.mapPut("choices", paramChoices);
        }
        final Object paramDefault = defaultFor(param);
        if (paramDefault != null) {
            paramRep.mapPut("default", paramDefault);
        }
        return paramRep;
    }
View Full Code Here

    @Override
    protected void addLinksIsisProprietary() {
        if (objectMember.isContributed()) {
            final ObjectAdapter serviceAdapter = contributingServiceAdapter();
            final JsonRepresentation contributedByLink = DomainObjectReprRenderer.newLinkToBuilder(resourceContext, Rel.CONTRIBUTED_BY, serviceAdapter).build();
            getLinks().arrayAdd(contributedByLink);
        }
    }
View Full Code Here

public class UrlParserUtilsTest {

    @Test
    public void oidFromLink() throws Exception {
        final JsonRepresentation link = JsonRepresentation.newMap();
        link.mapPut("href", "http://localhost/objects/OID:1");
        final String oidFromHref = UrlParserUtils.oidFromLink(link);
        assertEquals("OID:1", oidFromHref);
    }
View Full Code Here

        assertEquals("OID:1", oidFromHref);
    }

    @Test
    public void domainTypeFromLink() throws Exception {
        final JsonRepresentation link = JsonRepresentation.newMap();
        link.mapPut("href", "http://localhost/domainTypes/com.mycompany.myapp.Customer");
        final String oidFromHref = UrlParserUtils.domainTypeFrom(link);
        assertEquals("com.mycompany.myapp.Customer", oidFromHref);
    }
View Full Code Here

        assertThat(response.getMetadata().get("Warning"), is(nullValue()));

        // and then
        final String entity = (String) response.getEntity();
        assertThat(entity, is(not(nullValue())));
        final JsonRepresentation jsonRepr = JsonMapper.instance().read(entity, JsonRepresentation.class);

        // then
        assertThat(jsonRepr.getString("message"), is(nullValue()));
        assertThat(jsonRepr.getArray("stackTrace"), is(not(nullValue())));
        assertThat(jsonRepr.getArray("stackTrace").size(), is(greaterThan(0)));
        assertThat(jsonRepr.getRepresentation("causedBy"), is(nullValue()));
    }
View Full Code Here

        assertEquals("com.mycompany.myapp.Customer", oidFromHref);
    }

    @Test
    public void domainTypeFromLinkTrailingSlash() throws Exception {
        final JsonRepresentation link = JsonRepresentation.newMap();
        link.mapPut("href", "http://localhost/domainTypes/com.mycompany.myapp.Customer/");
        final String oidFromHref = UrlParserUtils.domainTypeFrom(link);
        assertEquals("com.mycompany.myapp.Customer", oidFromHref);
    }
View Full Code Here

        assertEquals("com.mycompany.myapp.Customer", oidFromHref);
    }

    @Test
    public void domainTypeFromLinkFollowingStuff() throws Exception {
        final JsonRepresentation link = JsonRepresentation.newMap();
        link.mapPut("href", "http://localhost/domainTypes/com.mycompany.myapp.Customer/otherStuffHere");
        final String oidFromHref = UrlParserUtils.domainTypeFrom(link);
        assertEquals("com.mycompany.myapp.Customer", oidFromHref);
    }
View Full Code Here

        assertThat((String) response.getMetadata().get("Warning").get(0), is(ex.getMessage()));

        // and then
        final String entity = (String) response.getEntity();
        assertThat(entity, is(not(nullValue())));
        final JsonRepresentation jsonRepr = JsonMapper.instance().read(entity, JsonRepresentation.class);

        // then
        assertThat(jsonRepr.getString("message"), is(ex.getMessage()));
    }
View Full Code Here

        // when
        final Response response = exceptionMapper.toResponse(ex);
        final String entity = (String) response.getEntity();
        assertThat(entity, is(not(nullValue())));
        final JsonRepresentation jsonRepr = JsonMapper.instance().read(entity, JsonRepresentation.class);

        // then
        assertThat(jsonRepr.getString("message"), is(ex.getMessage()));
        final JsonRepresentation causedByRepr = jsonRepr.getRepresentation("causedBy");
        assertThat(causedByRepr, is(not(nullValue())));
        assertThat(causedByRepr.getString("message"), is(cause.getMessage()));
    }
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.json.applib.JsonRepresentation$LinksToSelf

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.