TransactionTokenInterceptor implements HandlerInterceptor { @Override public void postHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler, final ModelAndView modelAndView) { logger.trace("postHandle"); if (!(handler instanceof HandlerMethod)) { return; } TransactionTokenContextImpl tokenContext = (TransactionTokenContextImpl) request .getAttribute(TOKEN_CONTEXT_REQUEST_ATTRIBUTE_NAME); switch (tokenContext.getReserveCommand()) { case CREATE_TOKEN: createToken(request, request.getSession(true), tokenContext .getTokenInfo(), generator, tokenStore); break; case UPDATE_TOKEN: updateToken(request, request.getSession(true), tokenContext .getReceivedToken(), tokenContext.getTokenInfo(), generator, tokenStore); break; case REMOVE_TOKEN: removeToken(tokenContext.getReceivedToken()); break; case KEEP_TOKEN: keepToken(request, tokenContext.getReceivedToken(), tokenContext .getTokenInfo(), tokenStore); break; default: break; } } TransactionTokenInterceptor();  TransactionTokenInterceptor(int sizePerTokenName);  TransactionTokenInterceptor(TokenStringGenerator generator,
            TransactionTokenInfoStore tokenInfoStore,
            TransactionTokenStore tokenStore); @Override boolean preHandle(final HttpServletRequest request,
            final HttpServletResponse response, final Object handler); @Override void postHandle(final HttpServletRequest request,
            final HttpServletResponse response, final Object handler,
            final ModelAndView modelAndView); @Override void afterCompletion(final HttpServletRequest request,
            final HttpServletResponse response, final Object handler,
            final Exception ex); static final String TOKEN_CONTEXT_REQUEST_ATTRIBUTE_NAME; static final String NEXT_TOKEN_REQUEST_ATTRIBUTE_NAME; static final String TOKEN_REQUEST_PARAMETER; }
@Test public void testPostHandleIncorrectHandler() throws Exception { try { interceptor.postHandle(request, response, null, null); } catch (Exception ex) { fail(); } }
@Test public void testPostHandleWithNoneOperation() throws Exception { TransactionTokenContextImpl context = mock( TransactionTokenContextImpl.class); request.setAttribute( TransactionTokenInterceptor.TOKEN_CONTEXT_REQUEST_ATTRIBUTE_NAME, context); when(context.getReserveCommand()).thenReturn( TransactionTokenContextImpl.ReserveCommand.NONE); try { interceptor.postHandle(request, response, new HandlerMethod(new TransactionTokenSampleController(), TransactionTokenSampleController.class .getDeclaredMethod("third", SampleForm.class, Model.class)), null); } catch (Exception e) { fail(); } }