@Test
public void testGetResources_Status_Alert() throws Exception {

  Resource.Type type = Resource.Type.Host;
  Injector injector = createInjector();
  AmbariManagementController managementController = injector.getInstance(AmbariManagementController.class);
  Clusters clusters = injector.getInstance(Clusters.class);
  Cluster cluster = createMock(Cluster.class);
  HostHealthStatus healthStatus = createNiceMock(HostHealthStatus.class);
  AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);
  ComponentInfo componentInfo = createNiceMock(ComponentInfo.class);
  HostResponse hostResponse1 = createNiceMock(HostResponse.class);
  ResourceProviderFactory resourceProviderFactory = createNiceMock(ResourceProviderFactory.class);
  ResourceProvider hostResourceProvider = getHostProvider(injector);
  Host host100 = createMockHost("Host100", "Cluster100", null, "ALERT", "RECOVERABLE", null);
  AbstractControllerResourceProvider.init(resourceProviderFactory);
  Set<Cluster> clusterSet = new HashSet<Cluster>();
  clusterSet.add(cluster);
  ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component100", "Component 100",
      "Host100", "Host100", "STARTED", "", null, null, null);
  ServiceComponentHostResponse shr2 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component102", "Component 102",
      "Host100", "Host100", "INSTALLED", "", null, null, null);
  ServiceComponentHostResponse shr3 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component103", "Component 103",
      "Host100", "Host100", "STARTED", "", null, null, null);
  Set<ServiceComponentHostResponse> responses = new HashSet<ServiceComponentHostResponse>();
  responses.add(shr1);
  responses.add(shr2);
  responses.add(shr3);
  // set expectations
  expect(host100.getMaintenanceState(2)).andReturn(MaintenanceState.OFF).anyTimes();
  expect(managementController.getClusters()).andReturn(clusters).anyTimes();
  expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
  expect(managementController.getHostComponents(EasyMock.<Set<ServiceComponentHostRequest>>anyObject()))
      .andReturn(responses).anyTimes();
  expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
  expect(clusters.getClustersForHost("Host100")).andReturn(clusterSet).anyTimes();
  expect(clusters.getHosts()).andReturn(Arrays.asList(host100)).anyTimes();
  expect(cluster.getClusterId()).andReturn(2L).anyTimes();
  expect(cluster.getDesiredConfigs()).andReturn(new HashMap<String, DesiredConfig>()).anyTimes();
  expect(hostResponse1.getClusterName()).andReturn("Cluster100").anyTimes();
  expect(hostResponse1.getHostname()).andReturn("Host100").anyTimes();
  expect(hostResponse1.getHealthStatus()).andReturn(healthStatus).anyTimes();
  expect(hostResponse1.getStatus()).andReturn(HealthStatus.ALERT.name()).anyTimes();
  expect(healthStatus.getHealthStatus()).andReturn(HostHealthStatus.HealthStatus.HEALTHY).anyTimes();
  expect(healthStatus.getHealthReport()).andReturn("HEALTHY").anyTimes();
  expect(ambariMetaInfo.getComponent((String) anyObject(), (String) anyObject(),
      (String) anyObject(), (String) anyObject())).andReturn(componentInfo).anyTimes();
  expect(componentInfo.getCategory()).andReturn("SLAVE").anyTimes();
  expect(resourceProviderFactory.getHostResourceProvider(EasyMock.<Set<String>>anyObject(),
      EasyMock.<Map<Resource.Type, String>>anyObject(),
      eq(managementController))).andReturn(hostResourceProvider).anyTimes();
  Set<String> propertyIds = new HashSet<String>();
  propertyIds.add(HostResourceProvider.HOST_CLUSTER_NAME_PROPERTY_ID);
  propertyIds.add(HostResourceProvider.HOST_NAME_PROPERTY_ID);
  propertyIds.add(HostResourceProvider.HOST_HOST_STATUS_PROPERTY_ID);
  Predicate predicate = buildPredicate("Cluster100", null);
  Request request = PropertyHelper.getReadRequest(propertyIds);
  // replay
  replayAll();
  SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator());
  ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
      type,
      PropertyHelper.getPropertyIds(type),
      PropertyHelper.getKeyPropertyIds(type),
      managementController);
  Set<Resource> resources = provider.getResources(request, predicate);
  Assert.assertEquals(1, resources.size());
  for (Resource resource : resources) {
    String clusterName = (String) resource.getPropertyValue(HostResourceProvider.HOST_CLUSTER_NAME_PROPERTY_ID);
    Assert.assertEquals("Cluster100", clusterName);
    String status = (String) resource.getPropertyValue(HostResourceProvider.HOST_HOST_STATUS_PROPERTY_ID);
    Assert.assertEquals("ALERT", status);
  }
  // verify
  verifyAll();
}