Package ninja.exceptions

Examples of ninja.exceptions.BadRequestException


            if (result.supportedContentTypes().contains(context.getAcceptContentType())) {
                result.contentType(context.getAcceptContentType());
            } else if (result.fallbackContentType().isPresent()) {
                result.contentType(result.fallbackContentType().get());
            } else {
                throw new BadRequestException(
                    "No idea how to handle incoming request with Accept:" + context.getAcceptContentType()
                    + " at route " + context.getRequestPath());
            }
        }
           
View Full Code Here


   
    @FilterWith(Async.class)
    public Result throwException() {
       
        // just make sure that Async handles exceptions well.
        throw new BadRequestException();
   
    }
View Full Code Here

    }
   
    @Timed
    public Result badRequest() {
   
        throw new BadRequestException("Just a test to make sure 400 bad request works :)");
       
    }
View Full Code Here

    public void testOnRouteRequestWhenOnBadRequest() throws Exception {
   
        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);
       
        ninjaDefault.onRouteRequest(contextImpl);
       
View Full Code Here

    }
   
    @Test
    public void testOnExceptionBadRequest() {
       
        Exception badRequestException = new BadRequestException();
   
        Result result = ninjaDefault.onException(contextImpl, badRequestException);
       
        verify(ninjaDefault).getBadRequestResult(contextImpl, badRequestException);
        assertThat(result.getStatusCode(), equalTo(Result.SC_400_BAD_REQUEST));
View Full Code Here

    public void testGetBadRequest() throws Exception {
       
        // real test:
        Result result = ninjaDefault.getBadRequestResult(
                contextImpl,
                new BadRequestException("not important"));
       
        assertThat(result.getStatusCode(), equalTo(Result.SC_400_BAD_REQUEST));
        assertThat(result.getTemplate(), equalTo(NinjaConstant.LOCATION_VIEW_FTL_HTML_BAD_REQUEST));
        assertTrue(result.getRenderable() instanceof Message);
View Full Code Here

TOP

Related Classes of ninja.exceptions.BadRequestException

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.