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

Examples of org.apache.isis.viewer.json.viewer.JsonApplicationException


    @Test
    public void simpleNoMessage() throws Exception {

        // given
        final HttpStatusCode status = HttpStatusCode.BAD_REQUEST;
        final JsonApplicationException ex = JsonApplicationException.create(status);

        // when
        final Response response = exceptionMapper.toResponse(ex);

        // then
View Full Code Here


    @Test
    public void entity_withMessage() throws Exception {

        // givens
        final JsonApplicationException ex = JsonApplicationException.create(HttpStatusCode.BAD_REQUEST, "foobar");

        // when
        final Response response = exceptionMapper.toResponse(ex);

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

    @Test
    public void entity_withCause() throws Exception {
        // given
        final Exception cause = new Exception("barfoo");
        final JsonApplicationException ex = JsonApplicationException.create(HttpStatusCode.BAD_REQUEST, cause, "foobar");

        // 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.viewer.JsonApplicationException

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.