### Question:
HSAdminServer extends AbstractService implements HSAdminProtocol { @Override public void refreshUserToGroupsMappings() throws IOException { UserGroupInformation user = checkAcls("refreshUserToGroupsMappings"); Groups.getUserToGroupsMappingService().refresh(); HSAuditLogger.logSuccess(user.getShortUserName(), "refreshUserToGroupsMappings", HISTORY_ADMIN_SERVER); } HSAdminServer(AggregatedLogDeletionService aggLogDelService,
      JobHistory jobHistoryService); @Override void serviceInit(Configuration conf); @Override String[] getGroupsForUser(String user); @Override void refreshUserToGroupsMappings(); @Override void refreshSuperUserGroupsConfiguration(); @Override void refreshAdminAcls(); @Override void refreshLoadedJobCache(); @Override void refreshLogRetentionSettings(); @Override void refreshJobRetentionSettings();  }### Answer:
@Test public void testRefreshUserToGroupsMappings() throws Exception { String[] args = new String[] { "-refreshUserToGroupsMappings" }; Groups groups = Groups.getUserToGroupsMappingService(conf); String user = UserGroupInformation.getCurrentUser().getUserName(); System.out.println("first attempt:"); List<String> g1 = groups.getGroups(user); String[] str_groups = new String[g1.size()]; g1.toArray(str_groups); System.out.println(Arrays.toString(str_groups)); System.out.println("second attempt, should be same:"); List<String> g2 = groups.getGroups(user); g2.toArray(str_groups); System.out.println(Arrays.toString(str_groups)); for (int i = 0; i < g2.size(); i++) { assertEquals("Should be same group ", g1.get(i), g2.get(i)); } hsAdminClient.run(args); System.out .println("third attempt(after refresh command), should be different:"); List<String> g3 = groups.getGroups(user); g3.toArray(str_groups); System.out.println(Arrays.toString(str_groups)); for (int i = 0; i < g3.size(); i++) { assertFalse( "Should be different group: " + g1.get(i) + " and " + g3.get(i), g1 .get(i).equals(g3.get(i))); } }