@Test
public void testHostsFilterUnhealthyComponent() throws Exception {

  // Set custom status to host
  clusters.getCluster("c1").getService("GANGLIA").getServiceComponent(
      "GANGLIA_MONITOR").getServiceComponentHost("c1-c6402").setState(State.UNKNOWN);
  Map<String, String> requestProperties = new HashMap<String, String>() {
    {
      put("context", "Restart all components for GANGLIA");
      put("operation_level/level", "SERVICE");
      put("operation_level/service_name", "GANGLIA");
      put("operation_level/cluster_name", "c1");
    }
  };
  ExecuteActionRequest actionRequest = new ExecuteActionRequest("c1", "RESTART", null,
      Arrays.asList(
          new RequestResourceFilter("GANGLIA", "GANGLIA_SERVER", Collections.singletonList("c1-c6401")),
          new RequestResourceFilter("GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6401")),
          new RequestResourceFilter("GANGLIA", "GANGLIA_MONITOR", Collections.singletonList("c1-c6402"))),
      new RequestOperationLevel(Resource.Type.Host, "c1", "GANGLIA", null, null),
      new HashMap<String, String>(), false);
  EasyMock.replay(hostRoleCommand, actionManager, configHelper);
  ambariManagementController.createAction(actionRequest, requestProperties);
  Request request = requestCapture.getValue();
  Assert.assertNotNull(request);
  Assert.assertNotNull(request.getStages());
  Assert.assertEquals(1, request.getStages().size());
  Stage stage = request.getStages().iterator().next();
  // Check if was generated command for one health host
  Assert.assertEquals(1, stage.getHostRoleCommands().size());
}