Service service0 = createNiceMock(Service.class);
Service service1 = createNiceMock(Service.class);
Service service2 = createNiceMock(Service.class);
Service service3 = createNiceMock(Service.class);
Service service4 = createNiceMock(Service.class);
ServiceResponse serviceResponse0 = createNiceMock(ServiceResponse.class);
ServiceResponse serviceResponse1 = createNiceMock(ServiceResponse.class);
ServiceResponse serviceResponse2 = createNiceMock(ServiceResponse.class);
ServiceResponse serviceResponse3 = createNiceMock(ServiceResponse.class);
ServiceResponse serviceResponse4 = createNiceMock(ServiceResponse.class);
StackId stackId = createNiceMock(StackId.class);
ServiceFactory serviceFactory = createNiceMock(ServiceFactory.class);
AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);
Map<String, Service> allResponseMap = new HashMap<String, Service>();
allResponseMap.put("Service100", service0);
allResponseMap.put("Service101", service1);
allResponseMap.put("Service102", service2);
allResponseMap.put("Service103", service3);
allResponseMap.put("Service104", service4);
// set expectations
expect(managementController.getClusters()).andReturn(clusters).anyTimes();
expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
expect(managementController.getServiceFactory()).andReturn(serviceFactory).anyTimes();
expect(managementController.getHostComponents((Set<ServiceComponentHostRequest>) anyObject())).
andReturn(Collections.<ServiceComponentHostResponse>emptySet()).anyTimes();
expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
expect(cluster.getServices()).andReturn(allResponseMap).anyTimes();
expect(cluster.getService("Service102")).andReturn(service2);
expect(service0.convertToResponse()).andReturn(serviceResponse0).anyTimes();
expect(service1.convertToResponse()).andReturn(serviceResponse1).anyTimes();
expect(service2.convertToResponse()).andReturn(serviceResponse2).anyTimes();
expect(service3.convertToResponse()).andReturn(serviceResponse3).anyTimes();
expect(service4.convertToResponse()).andReturn(serviceResponse4).anyTimes();
expect(service0.getName()).andReturn("Service100").anyTimes();
expect(service1.getName()).andReturn("Service101").anyTimes();
expect(service2.getName()).andReturn("Service102").anyTimes();
expect(service3.getName()).andReturn("Service103").anyTimes();
expect(service4.getName()).andReturn("Service104").anyTimes();
expect(service0.getDesiredState()).andReturn(State.INIT);
expect(service1.getDesiredState()).andReturn(State.INSTALLED);
expect(service2.getDesiredState()).andReturn(State.INIT);
expect(service3.getDesiredState()).andReturn(State.INSTALLED);
expect(service4.getDesiredState()).andReturn(State.INIT);
expect(serviceResponse0.getClusterName()).andReturn("Cluster100").anyTimes();
expect(serviceResponse0.getServiceName()).andReturn("Service100").anyTimes();
expect(serviceResponse1.getClusterName()).andReturn("Cluster100").anyTimes();
expect(serviceResponse1.getServiceName()).andReturn("Service101").anyTimes();
expect(serviceResponse2.getClusterName()).andReturn("Cluster100").anyTimes();
expect(serviceResponse2.getServiceName()).andReturn("Service102").anyTimes();
expect(serviceResponse3.getClusterName()).andReturn("Cluster100").anyTimes();
expect(serviceResponse3.getServiceName()).andReturn("Service103").anyTimes();
expect(serviceResponse4.getClusterName()).andReturn("Cluster100").anyTimes();
expect(serviceResponse4.getServiceName()).andReturn("Service104").anyTimes();
// replay
replay(managementController, clusters, cluster,
service0, service1, service2, service3, service4,
serviceResponse0, serviceResponse1, serviceResponse2, serviceResponse3, serviceResponse4,