### Question:
KeycloakPreAuthActionsFilter extends GenericFilterBean implements ApplicationContextAware { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpFacade facade = new SimpleHttpFacade((HttpServletRequest)request, (HttpServletResponse)response); KeycloakDeployment deployment = deploymentContext.resolveDeployment(facade); if (deployment == null) { return; } if (deployment.isConfigured()) { nodesRegistrationManagement.tryRegister(deploymentContext.resolveDeployment(facade)); } PreAuthActionsHandler handler = preAuthActionsHandlerFactory.createPreAuthActionsHandler(facade); if (handler.handleRequest()) { log.debug("Pre-auth filter handled request: {}", ((HttpServletRequest) request).getRequestURI()); } else { chain.doFilter(request, response); } } KeycloakPreAuthActionsFilter();  KeycloakPreAuthActionsFilter(UserSessionManagement userSessionManagement); @Override void destroy(); @Override void doFilter(ServletRequest request, ServletResponse response, FilterChain chain); void setUserSessionManagement(UserSessionManagement userSessionManagement); @Override void setApplicationContext(ApplicationContext applicationContext);  }### Answer:
@Test public void shouldIgnoreChainWhenPreAuthActionHandlerHandled() throws Exception { when(preAuthActionsHandler.handleRequest()).thenReturn(true); filter.doFilter(request, response, chain); verifyZeroInteractions(chain); verify(nodesRegistrationManagement).tryRegister(deployment); }
@Test public void shouldContinueChainWhenPreAuthActionHandlerDidNotHandle() throws Exception { when(preAuthActionsHandler.handleRequest()).thenReturn(false); filter.doFilter(request, response, chain); verify(chain).doFilter(request, response);; verify(nodesRegistrationManagement).tryRegister(deployment); }