### Question:
LoginAuthenticationFilter extends AbstractAuthFilter { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; String login = obtainFromHeader(request, USER_LOGIN); String pin = obtainFromHeader(request, USER_PIN); if (StringUtils.isBlank(login) || StringUtils.isBlank(pin)) { chain.doFilter(request, response); return; } if (authenticationIsRequired()) { try { ResponseEntity<SCALoginResponseTO> loginResponse = userMgmtStaffRestClient.login(new UserCredentialsTO(login, pin, UserRoleTO.STAFF)); BearerTokenTO bearerTokenTO = Optional.ofNullable(loginResponse.getBody()) .map(SCAResponseTO::getBearerToken) .orElseThrow(() -> new RestException("Couldn't get bearer token")); fillSecurityContext(bearerTokenTO); addBearerTokenHeader(bearerTokenTO.getAccess_token(), response); } catch (FeignException | RestException e) { handleAuthenticationFailure(response, e); return; } } chain.doFilter(request, response); } LoginAuthenticationFilter(UserMgmtStaffRestClient userMgmtStaffRestClient); @Override void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain);  }### Answer:
@Test void doFilter() throws IOException, ServletException { SecurityContextHolder.clearContext(); when(request.getHeader("login")).thenReturn("anton.brueckner"); when(request.getHeader("pin")).thenReturn("12345"); when(userMgmtStaffRestClient.login(any())).thenReturn(ResponseEntity.ok(getScaLoginResponse())); filter.doFilter(request, response, chain); verify(userMgmtStaffRestClient, times(1)).login(any()); }