@Test
public void testGetGroups() throws Exception {

  when(admin.getGroupsForUser(eq("admin"))).thenReturn(
      new String[] {"group1", "group2"});
  PrintStream origOut = System.out;
  PrintStream out = mock(PrintStream.class);
  System.setOut(out);
  try {
    String[] args = { "-getGroups", "admin" };
    assertEquals(0, rmAdminCLI.run(args));
    verify(admin).getGroupsForUser(eq("admin"));
    verify(out).println(argThat(
        (ArgumentMatcher<StringBuilder>) arg ->
            ("" + arg).equals("admin : group1 group2")));
  } finally {
    System.setOut(origOut);
  }
}