Package com.cumulocity.rest.representation

Examples of com.cumulocity.rest.representation.ErrorMessageRepresentation


    private String getErrorMessage(ClientResponse response, int status) {
        String errorMessage = "Http status code: " + status;

        if (response.hasEntity()) {
            ErrorMessageRepresentation errorRepresentation = getErrorRepresentation(response);
            if (errorRepresentation == null) {
                return NO_ERROR_REPRESENTATION;
            }
            errorMessage += "\n" + errorRepresentation;
        }
View Full Code Here


    @Test
    public void shouldIncludeExistingErrorMessageInExceptionWhenStatusIsNotAsExpected() throws Exception {
        // Given
        when(response.getStatus()).thenReturn(ERROR_STATUS);
        ErrorMessageRepresentation errorRepresentation = new ErrorMessageRepresentation();
        when(response.hasEntity()).thenReturn(true);
        when(response.getEntity(ErrorMessageRepresentation.class)).thenReturn(errorRepresentation);

        // Then
        thrown.expect(SDKException.class);
        thrown.expectMessage("Http status code: " + ERROR_STATUS + "\n" + errorRepresentation.toString());

        // When
        parser.parse(response, EXPECTED_STATUS, BaseResourceRepresentation.class);
    }
View Full Code Here

TOP

Related Classes of com.cumulocity.rest.representation.ErrorMessageRepresentation

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.