AmbariManagementController managementController = createNiceMock(AmbariManagementController.class);
Clusters clusters = createNiceMock(Clusters.class);
Cluster cluster = createNiceMock(Cluster.class);
Service service = createNiceMock(Service.class);
StackId stackId = createNiceMock(StackId.class);
ServiceFactory serviceFactory = createNiceMock(ServiceFactory.class);
AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);
expect(managementController.getClusters()).andReturn(clusters);
expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo);
expect(managementController.getServiceFactory()).andReturn(serviceFactory);
expect(serviceFactory.createNew(cluster, "Service100")).andReturn(service);
expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
expect(cluster.getService("Service100")).andReturn(null);
expect(cluster.getDesiredStackVersion()).andReturn(stackId);