public void testCommandReport() throws AmbariException {
injector.injectMembers(this);
clusters.addHost(DummyHostname1);
clusters.getHost(DummyHostname1).persist();
clusters.addCluster(DummyCluster);
ActionDBAccessor db = injector.getInstance(ActionDBAccessorImpl.class);
ActionManager am = new ActionManager(5000, 1200000, new ActionQueue(), clusters, db,
new HostsMap((String) null), null, unitOfWork, null);
populateActionDB(db, DummyHostname1);
Stage stage = db.getAllStages(requestId).get(0);
Assert.assertEquals(stageId, stage.getStageId());
stage.setHostRoleStatus(DummyHostname1, HBASE_MASTER, HostRoleStatus.QUEUED);
db.hostRoleScheduled(stage, DummyHostname1, HBASE_MASTER);
List<CommandReport> reports = new ArrayList<CommandReport>();
CommandReport cr = new CommandReport();
cr.setActionId(StageUtils.getActionId(requestId, stageId));
cr.setTaskId(1);
cr.setRole(HBASE_MASTER);
cr.setStatus("COMPLETED");
cr.setStdErr("");
cr.setStdOut("");
cr.setExitCode(215);
cr.setConfigurationTags(new HashMap<String, Map<String,String>>() {{
put("global", new HashMap<String,String>() {{ put("tag", "version1"); }});
}});
reports.add(cr);
am.processTaskResponse(DummyHostname1, reports);
assertEquals(215,
am.getAction(requestId, stageId).getExitCode(DummyHostname1, HBASE_MASTER));
assertEquals(HostRoleStatus.COMPLETED, am.getAction(requestId, stageId)
.getHostRoleStatus(DummyHostname1, HBASE_MASTER));
Stage s = db.getAllStages(requestId).get(0);
assertEquals(HostRoleStatus.COMPLETED,
s.getHostRoleStatus(DummyHostname1, HBASE_MASTER));
assertEquals(215,
s.getExitCode(DummyHostname1, HBASE_MASTER));
}