Package com.cedarsolutions.exception

Examples of com.cedarsolutions.exception.InvalidDataException


    public void testShowValidationError8() {
        View view = new View();
        ValidationErrors details = new ValidationErrors();
        details.setSummary(new LocalizableMessage("summaryKey1", "summaryText1"));
        details.addMessage("detailKey1", "fieldX", "detailText1");
        InvalidDataException error = new InvalidDataException("message", details);
        ValidationUtils.getInstance().showValidationError(view, error, "style");
        assertTrue(view.validationErrorWidget.isVisible());
        assertEquals("__summaryKey1", view.validationErrorWidget.getErrorSummary());
        assertEquals(1, view.validationErrorWidget.getErrorList().size());
        assertEquals("__detailKey1", view.validationErrorWidget.getErrorList().get(0));    }
View Full Code Here


    public void testShowValidationError9() {
        View view = new View();
        ValidationErrors details = new ValidationErrors();
        details.setSummary(new LocalizableMessage("summaryKey1", "summaryText1"));
        details.addMessage("detailKey1", "field1", "detailText1");
        InvalidDataException error = new InvalidDataException("message", details);
        ValidationUtils.getInstance().showValidationError(view, error, "style");
        assertTrue(view.validationErrorWidget.isVisible());
        assertEquals("__summaryKey1", view.validationErrorWidget.getErrorSummary());
        assertEquals(1, view.validationErrorWidget.getErrorList().size());
        assertEquals("__detailKey1", view.validationErrorWidget.getErrorList().get(0));
View Full Code Here

        View view = new View();
        ValidationErrors details = new ValidationErrors();
        details.setSummary(new LocalizableMessage("summaryKey1", "summaryText1"));
        details.addMessage("detailKey1", "field1", "detailText1");
        details.addMessage("detailKey2", "field2", "detailText2");
        InvalidDataException error = new InvalidDataException("message", details);
        ValidationUtils.getInstance().showValidationError(view, error, "style");
        assertTrue(view.validationErrorWidget.isVisible());
        assertEquals("__summaryKey1", view.validationErrorWidget.getErrorSummary());
        assertEquals(2, view.validationErrorWidget.getErrorList().size());
        assertEquals("__detailKey1", view.validationErrorWidget.getErrorList().get(0));
View Full Code Here

        ValidationErrors details = new ValidationErrors();
        details.setSummary(new LocalizableMessage("summaryKey1", "summaryText1"));
        details.addMessage("detailKey1", "field1", "detailText1");
        details.addMessage("detailKey2", "field2", "detailText2");
        details.addMessage("detailKey3", "field3", "detailText3");
        InvalidDataException error = new InvalidDataException("message", details);
        ValidationUtils.getInstance().showValidationError(view, error, "style");
        assertTrue(view.validationErrorWidget.isVisible());
        assertEquals("__summaryKey1", view.validationErrorWidget.getErrorSummary());
        assertEquals(3, view.validationErrorWidget.getErrorList().size());
        assertEquals("__detailKey1", view.validationErrorWidget.getErrorList().get(0));
View Full Code Here

        verify(caller).onSuccessResult("hello");
    }

    /** Test onFailure(), validation error, handled by child. */
    @Test public void testOnFailureValidationHandled() {
        InvalidDataException caught = new InvalidDataException("caught");

        IRpcCaller<String> caller = mock(IRpcCaller.class);
        when(caller.getDescriptiveCallerId()).thenReturn("Caller");
        when(caller.getDescriptiveCallState()).thenReturn(" (1 of 2)");
        when(caller.getElapsedTime()).thenReturn(", elapsed");
View Full Code Here

        verify(caller).log("Caller: validation error (1 of 2), elapsed");
    }

    /** Test onFailure(), validation error, not handled by child, no retry allowed. */
    @Test public void testOnFailureValidationNotHandledNoRetryAllowed() {
        InvalidDataException caught = new InvalidDataException("caught");

        IRpcCaller<String> caller = mock(IRpcCaller.class);
        when(caller.getDescriptiveCallerId()).thenReturn("Caller");
        when(caller.getDescriptiveCallState()).thenReturn(" (1 of 2)");
        when(caller.getElapsedTime()).thenReturn(", elapsed");
View Full Code Here

        verify(caller).onUnhandledError(caught);
    }

    /** Test onFailure(), validation error, not handled by child, retry allowed. */
    @Test public void testOnFailureValidationNotHandledRetryAllowed() {
        InvalidDataException caught = new InvalidDataException("caught");

        IRpcCaller<String> caller = mock(IRpcCaller.class);
        when(caller.getDescriptiveCallerId()).thenReturn("Caller");
        when(caller.getDescriptiveCallState()).thenReturn(" (1 of 2)");
        when(caller.getElapsedTime()).thenReturn(", elapsed");
View Full Code Here

        assertNull(caller.result);
    }

    /** Test onUnhandledError() for general RPC error (unhandled validation error). */
    @Test public void testOnUnhandledError8() {
        Throwable exception = new InvalidDataException("Whatever");
        Caller caller = new Caller();
        caller.onUnhandledError(exception);

        assertEquals("generateGeneralRpcError", caller.error.getMessage());
        assertNull(caller.statusCode);
View Full Code Here

                return element.getValue();
            }
        } catch (JAXBException e) {
            throw translateJaxbUnmarshalError(type, e);
        } catch (SAXException e) {
            InvalidDataException invalid = getUnmarshalError(type, e);
            invalid.getDetails().addMessage(ERROR_KEY, e.getMessage());
            throw invalid;
        }
    }
View Full Code Here

    }

    /** Get a "raw" invalid data exception for a class, with empty details attached. */
    private static <T> InvalidDataException getUnmarshalError(Class<T> type, Throwable cause) {
        ValidationErrors details = new ValidationErrors(ERROR_KEY, "Error unmarshalling XML for " + type.getSimpleName());
        return new InvalidDataException("Error unmarshalling XML for " + type.getSimpleName(), details);
    }
View Full Code Here

TOP

Related Classes of com.cedarsolutions.exception.InvalidDataException

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.