### Question:
UsernameFailedLoginOverThresholdFilter extends MetadataFilter { @Override protected void apply(final HttpServletRequest request) { final String username = request.getParameter(usernameParameter); final boolean overThreshold = username != null && usernameOverLoginThresholdRegistry.contains(username); request.setAttribute(RequestMetadata.USERNAME_FAILED_LOGIN_OVER_THRESHOLD, overThreshold); } UsernameFailedLoginOverThresholdFilter(UsernameOverLoginThresholdRegistry usernameOverLoginThresholdRegistry); void setUsernameParameter(final String usernameParameter);  }### Answer:
@Test public void shouldMarkRequestBasedOnUsername() { given(usernameOverLoginThresholdRegistry.contains("user")).willReturn(true); final MockHttpServletRequest request = new MockHttpServletRequest(); request.setMethod("POST"); request.setServletPath("/login"); request.setParameter("username", "user"); filter.apply(request); assertThat(request.getAttribute(RequestMetadata.USERNAME_FAILED_LOGIN_OVER_THRESHOLD)).isEqualTo(TRUE); }