Examples of ErrorMessageRepresentation


Examples of com.cumulocity.me.rest.representation.ErrorMessageRepresentation

    WebRequestBuilder requestBuilder = mock(WebRequestBuilder.class, doReturnsThis());
   
    @Test
    public void shouldGet() throws Exception {
        when(httpClient.request(path)).thenReturn(requestBuilder);
        when(requestBuilder.get(HttpConnection.HTTP_OK, responseEntityType)).thenReturn(new ErrorMessageRepresentation());
       
        ResourceRepresentation representation = restConnector.get(path, mediaType, responseEntityType);
       
        assertThat(representation).isInstanceOf(ErrorMessageRepresentation.class);
    }
View Full Code Here

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

Examples of com.cumulocity.rest.representation.ErrorMessageRepresentation

    @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
Copyright © 2018 www.massapi.com. 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.