private static HandlerMethod getHandlerMethod(MvcResult result) { Object handler = result.getHandler(); assertTrue("No handler", handler != null); if (!(handler instanceof HandlerMethod)) { fail("Not a HandlerMethod: " + handler); } return (HandlerMethod) handler; }
/** * Assert the type of the handler that processed the request. */ public ResultMatcher handlerType(final Class<?> type) { return result -> { Object handler = result.getHandler(); assertTrue("No handler", handler != null); if (handler != null) { Class<?> actual = handler.getClass(); if (HandlerMethod.class.isInstance(handler)) { actual = ((HandlerMethod) handler).getBeanType(); } assertEquals("Handler type", type, ClassUtils.getUserClass(actual)); } }; }
/** * Print {@link MvcResult} details. */ @Override public final void handle(MvcResult result) throws Exception { this.printer.printHeading("MockHttpServletRequest"); printRequest(result.getRequest()); this.printer.printHeading("Handler"); printHandler(result.getHandler(), result.getInterceptors()); this.printer.printHeading("Async"); printAsyncResult(result); this.printer.printHeading("Resolved Exception"); printResolvedException(result.getResolvedException()); this.printer.printHeading("ModelAndView"); printModelAndView(result.getModelAndView()); this.printer.printHeading("FlashMap"); printFlashMap(RequestContextUtils.getOutputFlashMap(result.getRequest())); this.printer.printHeading("MockHttpServletResponse"); printResponse(result.getResponse()); }
private static HandlerMethod getHandlerMethod(MvcResult result) { Object handler = result.getHandler(); assertTrue("No handler: ", handler != null); assertTrue("Not a HandlerMethod: " + handler, HandlerMethod.class.isInstance(handler)); return (HandlerMethod) handler; }
private static HandlerMethod getHandlerMethod(MvcResult result) { Object handler = result.getHandler(); assertTrue("No handler", handler != null); if (!(handler instanceof HandlerMethod)) { fail("Not a HandlerMethod: " + handler); } return (HandlerMethod) handler; }
@Override public void match(MvcResult result) throws Exception { Object handler = result.getHandler(); assertTrue("No handler", handler != null); Class<?> actual = handler.getClass(); if (HandlerMethod.class.isInstance(handler)) { actual = ((HandlerMethod) handler).getBeanType(); } assertEquals("Handler type", type, ClassUtils.getUserClass(actual)); } };
/** * Assert the type of the handler that processed the request. */ public ResultMatcher handlerType(final Class<?> type) { return result -> { Object handler = result.getHandler(); assertTrue("No handler", handler != null); if (handler != null) { Class<?> actual = handler.getClass(); if (HandlerMethod.class.isInstance(handler)) { actual = ((HandlerMethod) handler).getBeanType(); } assertEquals("Handler type", type, ClassUtils.getUserClass(actual)); } }; }
/** * Print {@link MvcResult} details. */ @Override public final void handle(MvcResult result) throws Exception { this.printer.printHeading("MockHttpServletRequest"); printRequest(result.getRequest()); this.printer.printHeading("Handler"); printHandler(result.getHandler(), result.getInterceptors()); this.printer.printHeading("Async"); printAsyncResult(result); this.printer.printHeading("Resolved Exception"); printResolvedException(result.getResolvedException()); this.printer.printHeading("ModelAndView"); printModelAndView(result.getModelAndView()); this.printer.printHeading("FlashMap"); printFlashMap(RequestContextUtils.getOutputFlashMap(result.getRequest())); this.printer.printHeading("MockHttpServletResponse"); printResponse(result.getResponse()); }
/** * Print {@link MvcResult} details. */ @Override public final void handle(MvcResult result) throws Exception { this.printer.printHeading("MockHttpServletRequest"); printRequest(result.getRequest()); this.printer.printHeading("Handler"); printHandler(result.getHandler(), result.getInterceptors()); this.printer.printHeading("Async"); printAsyncResult(result); this.printer.printHeading("Resolved Exception"); printResolvedException(result.getResolvedException()); this.printer.printHeading("ModelAndView"); printModelAndView(result.getModelAndView()); this.printer.printHeading("FlashMap"); printFlashMap(RequestContextUtils.getOutputFlashMap(result.getRequest())); this.printer.printHeading("MockHttpServletResponse"); printResponse(result.getResponse()); }