use of com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult in project riposte by Nike-Inc.
the class BackstopperRiposteFrameworkErrorHandlerListenerTest method verifyExceptionHandled.
private void verifyExceptionHandled(Throwable ex, SortedApiErrorSet expectedErrors) {
ApiExceptionHandlerListenerResult result = listener.shouldHandleException(ex);
assertThat(result.shouldHandleResponse).isTrue();
assertThat(result.errors).isEqualTo(expectedErrors);
}
use of com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult in project riposte by Nike-Inc.
the class BackstopperRiposteFrameworkErrorHandlerListenerTest method shouldHandleInvalidHttpRequestExceptionWithNullCause.
@Test
public void shouldHandleInvalidHttpRequestExceptionWithNullCause() {
ApiExceptionHandlerListenerResult result = listener.shouldHandleException(new InvalidHttpRequestException("message", null));
assertThat(result.shouldHandleResponse).isTrue();
assertThat(result.errors).isEqualTo(singletonError(testProjectApiErrors.getMalformedRequestApiError()));
assertThat(result.errors.first().getMetadata().get("cause")).isEqualTo("Invalid HTTP request");
assertThat(result.extraDetailsForLogging.get(0).getLeft()).isEqualTo("exception_message");
assertThat(result.extraDetailsForLogging.get(0).getRight()).isEqualTo("message");
assertThat(result.extraDetailsForLogging.get(1).getLeft()).isEqualTo("cause_details");
assertThat(result.extraDetailsForLogging.get(1).getRight()).isEqualTo("null");
}
use of com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult in project riposte by Nike-Inc.
the class BackstopperRiposteFrameworkErrorHandlerListenerTest method shouldIgnoreUnhandledErrors.
@Test
public void shouldIgnoreUnhandledErrors() {
ApiExceptionHandlerListenerResult result = listener.shouldHandleException(new Exception());
assertThat(result.shouldHandleResponse).isFalse();
}
use of com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult in project riposte by Nike-Inc.
the class BackstopperRiposteFrameworkErrorHandlerListenerTest method shouldHandleInvalidHttpRequestExceptionWithNonNullCause.
@Test
public void shouldHandleInvalidHttpRequestExceptionWithNonNullCause() {
ApiExceptionHandlerListenerResult result = listener.shouldHandleException(new InvalidHttpRequestException("message", new RuntimeException("runtime exception")));
assertThat(result.shouldHandleResponse).isTrue();
assertThat(result.errors).isEqualTo(singletonError(testProjectApiErrors.getMalformedRequestApiError()));
assertThat(result.errors.first().getMetadata().get("cause")).isEqualTo("Invalid HTTP request");
assertThat(result.extraDetailsForLogging.get(0).getLeft()).isEqualTo("exception_message");
assertThat(result.extraDetailsForLogging.get(0).getRight()).isEqualTo("message");
assertThat(result.extraDetailsForLogging.get(1).getLeft()).isEqualTo("cause_details");
assertThat(result.extraDetailsForLogging.get(1).getRight()).isEqualTo("java.lang.RuntimeException: runtime exception");
}
use of com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult in project riposte by Nike-Inc.
the class BackstopperRiposteFrameworkErrorHandlerListenerTest method shouldHandleTooLongFrameExceptionAndAddCauseMetadata.
@Test
public void shouldHandleTooLongFrameExceptionAndAddCauseMetadata() {
ApiExceptionHandlerListenerResult result = listener.shouldHandleException(new TooLongFrameException());
assertThat(result.shouldHandleResponse).isTrue();
assertThat(result.errors).isEqualTo(singletonError(testProjectApiErrors.getMalformedRequestApiError()));
assertThat(result.errors.first().getMetadata().get("cause")).isEqualTo("The request exceeded the maximum payload size allowed");
}
Aggregations