@Test
public void testListGroups() throws Exception {

    Group group1 = Mockito.mock(Group.class);
    Mockito.when(group1.getType()).thenReturn(Role.GROUP);
    Mockito.when(group1.getName()).thenReturn("group1");
    Group group2 = Mockito.mock(Group.class);
    Mockito.when(group2.getType()).thenReturn(Role.GROUP);
    Mockito.when(group2.getName()).thenReturn("group2");
    Mockito.when(userAdmin.getRoles(null)).thenReturn(new Role[] { group1, group2 });
    String[] groups = mbean.listGroups();
    Assert.assertArrayEquals(new String[] { "group1", "group2" }, groups);
}