@Test
public void testGetComponents() throws Exception {

  // member state mocks
  AmbariManagementController managementController = createMock(AmbariManagementController.class);
  Clusters clusters = createNiceMock(Clusters.class);
  AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);
  StackId stackId = createNiceMock(StackId.class);
  Cluster cluster = createNiceMock(Cluster.class);
  Service service = createNiceMock(Service.class);
  ComponentInfo componentInfo = createNiceMock(ComponentInfo.class);
  ServiceComponent component = createNiceMock(ServiceComponent.class);
  ServiceComponentResponse response = createNiceMock(ServiceComponentResponse.class);
  // requests
  ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
      null, String.valueOf(true /* recovery enabled */));
  Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
  setRequests.add(request1);
  // expectations
  // constructor init
  expect(managementController.getClusters()).andReturn(clusters).anyTimes();
  expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
  expect(stackId.getStackName()).andReturn("stackName").anyTimes();
  expect(stackId.getStackVersion()).andReturn("1").anyTimes();
  // getComponents
  expect(clusters.getCluster("cluster1")).andReturn(cluster);
  expect(cluster.getService("service1")).andReturn(service);
  expect(cluster.getDesiredStackVersion()).andReturn(stackId).anyTimes();
  expect(service.getName()).andReturn("service1").anyTimes();
  expect(service.getServiceComponent("component1")).andReturn(component);
  expect(ambariMetaInfo.getComponent("stackName", "1", "service1", "component1")).andReturn(componentInfo);
  expect(componentInfo.getCategory()).andReturn(null);
  expect(component.convertToResponse()).andReturn(response);
  // replay mocks
  replay(clusters, cluster, service, componentInfo, component, response, ambariMetaInfo, stackId, managementController);
  //test
  Set<ServiceComponentResponse> setResponses = getComponentResourceProvider(managementController).getComponents(setRequests);
  // assert and verify
  assertEquals(1, setResponses.size());
  assertTrue(setResponses.contains(response));
  verify(clusters, cluster, service, componentInfo, component, response, ambariMetaInfo, stackId, managementController);
}