UberfireRoleManager implements RoleManager,
                                            ContextualManager { @Override public SearchResponse<Role> search(SearchRequest request) throws SecurityManagementException { return rolesSearchEngine.search(RoleRegistry.get().getRegisteredRoles(), request); }  @Override void initialize(final UserSystemManager userSystemManager); @Override SearchResponse<Role> search(SearchRequest request); @Override Role get(String identifier); @Override List<Role> getAll(); @Override Role create(Role entity); @Override Role update(Role entity); @Override void delete(String... identifiers); @Override RoleManagerSettings getSettings(); @Override void destroy();  }
@Test public void testSearch() { GroupManager groupManager = mock(GroupManager.class); doAnswer(new Answer<Group>() { @Override public Group answer(InvocationOnMock invocationOnMock) throws Throwable { String name = (String) invocationOnMock.getArguments()[0]; Group g = mock(Group.class); when(g.getName()).thenReturn(name); return g; } }).when(groupManager).get(anyString()); when(userSystemManager.groups()).thenReturn(groupManager); AbstractEntityManager.SearchResponse<Role> response = tested.search(new SearchRequestImpl("", 1, 10)); assertNotNull(response); int total = response.getTotal(); assertEquals(total, 3); boolean hasNextPage = response.hasNextPage(); assertEquals(hasNextPage, false); List<Role> results = response.getResults(); assertEquals(results.size(), 3); }