GeoServerSecurityManager secMgr = createNiceMock(GeoServerSecurityManager.class);
GeoServerRoleStore roleStore = createRoleStore("test", secMgr, "role1", "parent1");
expect(roleStore.removeRole(new GeoServerRole("unused"))).andReturn(true);
DataAccessRule dataAccessRule = createNiceMock(DataAccessRule.class);
expect(dataAccessRule.compareTo(dataAccessRule)).andReturn(0).anyTimes();
expect(dataAccessRule.getKey()).andReturn("foo").anyTimes();
expect(dataAccessRule.getRoles()).andReturn(new TreeSet<String>(Arrays.asList("role1"))).anyTimes();
replay(dataAccessRule);
DataAccessRuleDAO dataAccessDAO = createNiceMock(DataAccessRuleDAO.class);
expect(dataAccessDAO.getRulesAssociatedWithRole("role1")).andReturn(
new TreeSet<DataAccessRule>(Arrays.asList(dataAccessRule))).anyTimes();