LdapRoleCheckingRequest extends HttpServletRequestWrapper { @Override public boolean isUserInRole(String role) { return userRoles.contains(role); } LdapRoleCheckingRequest(final HttpServletRequest request,
                                   final LDAPInterface ldapInterface,
                                   final String userDN,
                                   final LdapProperties ldapProperties); @Override boolean isUserInRole(String role);  }
@Test public void shouldCheckUserRoles() throws LDAPException { final HttpServletRequest mockRequest = mock(HttpServletRequest.class); final LDAPInterface ldap = someLdapInterfaceReturning("foo", "bar"); final LdapRoleCheckingRequest request = new LdapRoleCheckingRequest(mockRequest, ldap, "uid=test", someLdapProperties()); assertThat(request.isUserInRole("foo")).isEqualTo(true); assertThat(request.isUserInRole("foobar")).isEqualTo(false); }