@Test
@SuppressWarnings("unchecked")
public void testHeartbeatCustomCommandWithConfigs() throws Exception {

  Cluster cluster = heartbeatTestHelper.getDummyCluster();
  Service hdfs = cluster.addService(HDFS);
  hdfs.addServiceComponent(DATANODE);
  hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
  hdfs.addServiceComponent(NAMENODE);
  hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
  hdfs.addServiceComponent(SECONDARY_NAMENODE);
  hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1);
  ActionQueue aq = new ActionQueue();
  ServiceComponentHost serviceComponentHost1 = clusters.getCluster(DummyCluster).getService(HDFS).
      getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1);
  ServiceComponentHost serviceComponentHost2 = clusters.getCluster(DummyCluster).getService(HDFS).
      getServiceComponent(NAMENODE).getServiceComponentHost(DummyHostname1);
  serviceComponentHost1.setState(State.INSTALLED);
  serviceComponentHost2.setState(State.INSTALLED);
  HeartBeat hb = new HeartBeat();
  hb.setResponseId(0);
  hb.setNodeStatus(new HostStatus(HostStatus.Status.HEALTHY, DummyHostStatus));
  hb.setHostname(DummyHostname1);
  List<CommandReport> reports = new ArrayList<CommandReport>();
  CommandReport cr = new CommandReport();
  cr.setActionId(StageUtils.getActionId(requestId, stageId));
  cr.setServiceName(HDFS);
  cr.setRoleCommand("CUSTOM_COMMAND");
  cr.setCustomCommand("RESTART");
  cr.setTaskId(1);
  cr.setRole(DATANODE);
  cr.setStatus("COMPLETED");
  cr.setStdErr("");
  cr.setStdOut("");
  cr.setExitCode(215);
  cr.setClusterName(DummyCluster);
  cr.setConfigurationTags(new HashMap<String, Map<String,String>>() {{
    put("global", new HashMap<String,String>() {{ put("tag", "version1"); }});
  }});
  CommandReport crn = new CommandReport();
  crn.setActionId(StageUtils.getActionId(requestId, stageId));
  crn.setServiceName(HDFS);
  crn.setRoleCommand("CUSTOM_COMMAND");
  crn.setCustomCommand("START");
  crn.setTaskId(1);
  crn.setRole(NAMENODE);
  crn.setStatus("COMPLETED");
  crn.setStdErr("");
  crn.setStdOut("");
  crn.setExitCode(215);
  crn.setClusterName(DummyCluster);
  crn.setConfigurationTags(new HashMap<String, Map<String,String>>() {{
    put("global", new HashMap<String,String>() {{ put("tag", "version1"); }});
  }});
  reports.add(cr);
  reports.add(crn);
  hb.setReports(reports);
  final HostRoleCommand command = hostRoleCommandFactory.create(DummyHostname1,
      Role.DATANODE, null, null);
  ActionManager am = actionManagerTestHelper.getMockActionManager();
  expect(am.getTasks(EasyMock.<List<Long>>anyObject())).andReturn(
      new ArrayList<HostRoleCommand>() {{
        add(command);
        add(command);
      }});
  replay(am);
  HeartBeatHandler handler = heartbeatTestHelper.getHeartBeatHandler(am, aq);
  HeartbeatProcessor heartbeatProcessor = handler.getHeartbeatProcessor();
  heartbeatProcessor.processHeartbeat(hb);
  // the heartbeat test passed if actual configs is populated
  Assert.assertNotNull(serviceComponentHost1.getActualConfigs());
  Assert.assertEquals(serviceComponentHost1.getActualConfigs().size(), 1);
  Assert.assertNotNull(serviceComponentHost2.getActualConfigs());
  Assert.assertEquals(serviceComponentHost2.getActualConfigs().size(), 1);
}