@Test(expected = BadCredentialsException.class) public void handleBadResponseWithAuthGeneral() { handler.handleBadResponse(unauthorizedException, ErrorType.AUTH_GENERAL, GENERIC_LOG_MESSAGE, LOG_PARAMETERS); }
public void handleBadResponse(@NotNull Exception exception, ErrorType errorType, String genericLogErrorMessage, Object... logParameters) { if (exception instanceof HttpClientErrorException) { handleHttpClientError(exception, errorType, genericLogErrorMessage, logParameters); } else if (exception instanceof ResourceAccessException) { throw new GatewayNotAvailableException(ErrorType.GATEWAY_NOT_AVAILABLE.getDefaultMessage(), exception); } else if (exception instanceof HttpServerErrorException) { HttpServerErrorException hseException = (HttpServerErrorException) exception; if (hseException.getStatusCode().equals(HttpStatus.SERVICE_UNAVAILABLE)) { throw new ServiceNotAccessibleException(ErrorType.SERVICE_UNAVAILABLE.getDefaultMessage(), exception); } else { throw hseException; } } }
RestResponseHandler { public void handleBadResponse(@NotNull Exception exception, ErrorType errorType, String genericLogErrorMessage, Object... logParameters) { if (exception instanceof HttpClientErrorException) { handleHttpClientError(exception, errorType, genericLogErrorMessage, logParameters); } else if (exception instanceof ResourceAccessException) { throw new GatewayNotAvailableException(ErrorType.GATEWAY_NOT_AVAILABLE.getDefaultMessage(), exception); } else if (exception instanceof HttpServerErrorException) { HttpServerErrorException hseException = (HttpServerErrorException) exception; if (hseException.getStatusCode().equals(HttpStatus.SERVICE_UNAVAILABLE)) { throw new ServiceNotAccessibleException(ErrorType.SERVICE_UNAVAILABLE.getDefaultMessage(), exception); } else { throw hseException; } } } }
RestResponseHandler { public void handleBadResponse(@NotNull Exception exception, ErrorType errorType, String genericLogErrorMessage, Object... logParameters) { if (exception instanceof HttpClientErrorException) { handleHttpClientError(exception, errorType, genericLogErrorMessage, logParameters); } else if (exception instanceof ResourceAccessException) { throw new GatewayNotAvailableException(ErrorType.GATEWAY_NOT_AVAILABLE.getDefaultMessage(), exception); } else if (exception instanceof HttpServerErrorException) { HttpServerErrorException hseException = (HttpServerErrorException) exception; if (hseException.getStatusCode().equals(HttpStatus.SERVICE_UNAVAILABLE)) { throw new ServiceNotAccessibleException(ErrorType.SERVICE_UNAVAILABLE.getDefaultMessage(), exception); } else { throw hseException; } } }  }
RestResponseHandler { public void handleBadResponse(@NotNull Exception exception, ErrorType errorType, String genericLogErrorMessage, Object... logParameters) { if (exception instanceof HttpClientErrorException) { handleHttpClientError(exception, errorType, genericLogErrorMessage, logParameters); } else if (exception instanceof ResourceAccessException) { throw new GatewayNotAvailableException(ErrorType.GATEWAY_NOT_AVAILABLE.getDefaultMessage(), exception); } else if (exception instanceof HttpServerErrorException) { HttpServerErrorException hseException = (HttpServerErrorException) exception; if (hseException.getStatusCode().equals(HttpStatus.SERVICE_UNAVAILABLE)) { throw new ServiceNotAccessibleException(ErrorType.SERVICE_UNAVAILABLE.getDefaultMessage(), exception); } else { throw hseException; } } }  void handleBadResponse(@NotNull Exception exception, ErrorType errorType, String genericLogErrorMessage, Object... logParameters); }
RestResponseHandler { public void handleBadResponse(@NotNull Exception exception, ErrorType errorType, String genericLogErrorMessage, Object... logParameters) { if (exception instanceof HttpClientErrorException) { handleHttpClientError(exception, errorType, genericLogErrorMessage, logParameters); } else if (exception instanceof ResourceAccessException) { throw new GatewayNotAvailableException(ErrorType.GATEWAY_NOT_AVAILABLE.getDefaultMessage(), exception); } else if (exception instanceof HttpServerErrorException) { HttpServerErrorException hseException = (HttpServerErrorException) exception; if (hseException.getStatusCode().equals(HttpStatus.SERVICE_UNAVAILABLE)) { throw new ServiceNotAccessibleException(ErrorType.SERVICE_UNAVAILABLE.getDefaultMessage(), exception); } else { throw hseException; } } }  void handleBadResponse(@NotNull Exception exception, ErrorType errorType, String genericLogErrorMessage, Object... logParameters);  }