@Test
public void testGetClientHostForRunningAction_noClientComponent() throws Exception {

  Injector injector = createNiceMock(Injector.class);
  Cluster cluster = createNiceMock(Cluster.class);
  Service service = createNiceMock(Service.class);
  StackId stackId = createNiceMock(StackId.class);
  ServiceComponent component1 = createNiceMock(ServiceComponent.class);
  ServiceComponent component2 = createNiceMock(ServiceComponent.class);
  expect(service.getName()).andReturn("service");
  expect(service.getDesiredStackVersion()).andReturn(stackId);
  expect(stackId.getStackName()).andReturn("stack");
  expect(stackId.getStackVersion()).andReturn("1.0");
  Map<String, ServiceComponent> componentsMap = new HashMap<String, ServiceComponent>();
  componentsMap.put("component1", component1);
  componentsMap.put("component2", component2);
  expect(service.getServiceComponents()).andReturn(componentsMap);
  expect(component1.getServiceComponentHosts()).andReturn(Collections.<String, ServiceComponentHost>emptyMap());
  expect(component2.getServiceComponentHosts()).andReturn(
    Collections.<String, ServiceComponentHost>singletonMap("anyHost", null));
  ServiceInfo serviceInfo = createNiceMock(ServiceInfo.class);
  expect(serviceInfo.getClientComponent()).andReturn(null);
  expect(ambariMetaInfo.getService("stack", "1.0", "service")).andReturn(serviceInfo);
  replay(injector, cluster, service, component1, component2, serviceInfo, ambariMetaInfo, stackId);
  AmbariManagementControllerImpl controller = new AmbariManagementControllerImpl(null, clusters, injector);
  setAmbariMetaInfo(ambariMetaInfo, controller);
  ServiceComponent resultComponent = controller.getClientComponentForRunningAction(cluster, service);
  assertNotNull(resultComponent);
  assertEquals(component2, resultComponent);
  verify(injector, cluster, service, component1, component2, serviceInfo, ambariMetaInfo, stackId);
}