use of ninja.exceptions.BadRequestException in project ninja by ninjaframework.
the class NinjaDefaultTest method testOnExceptionBadRequest.
@Test
public void testOnExceptionBadRequest() {
BadRequestException badRequestException = new BadRequestException();
Result result = ninjaDefault.onException(contextImpl, badRequestException);
verify(ninjaDefault).getBadRequestResult(contextImpl, badRequestException);
assertThat(result.getStatusCode(), equalTo(Result.SC_400_BAD_REQUEST));
}
use of ninja.exceptions.BadRequestException in project ninja by ninjaframework.
the class NinjaDefaultTest method testOnRouteRequestWhenOnBadRequestInDiagnosticMode.
@Test
public void testOnRouteRequestWhenOnBadRequestInDiagnosticMode() {
FilterChain filterChain = Mockito.mock(FilterChain.class);
Mockito.when(route.getFilterChain()).thenReturn(filterChain);
BadRequestException badRequest = new BadRequestException("That's a BadRequest that should be handled by onBadRequest");
Mockito.when(filterChain.next(contextImpl)).thenThrow(badRequest);
when(ninjaProperties.isDev()).thenReturn(true);
when(ninjaProperties.getBooleanWithDefault(NinjaConstant.DIAGNOSTICS_KEY_NAME, true)).thenReturn(true);
ninjaDefault.onRouteRequest(contextImpl);
Result localResult = ninjaDefault.getBadRequestResult(contextImpl, badRequest);
assertThat(localResult.getRenderable(), CoreMatchers.instanceOf(DiagnosticError.class));
}
Aggregations