@Test
public void testValidateTopology_autoDeploy_hasDependency() throws Exception {

  group1Components.add("component2");
  dependencies1.add(dependency1);
  services.addAll(Collections.singleton("service1"));
  expect(blueprint.getHostGroupsForComponent("component1")).andReturn(Collections.<HostGroup>emptyList()).anyTimes();
  expect(blueprint.getHostGroupsForComponent("component2")).andReturn(Arrays.asList(group1, group2)).anyTimes();
  expect(blueprint.getHostGroupsForComponent("component3")).andReturn(Collections.<HostGroup>emptyList()).anyTimes();
  expect(stack.getComponents("service1")).andReturn(Arrays.asList("component1", "component2")).anyTimes();
  expect(stack.getComponents("service2")).andReturn(Collections.singleton("component3")).anyTimes();
  expect(stack.getAutoDeployInfo("component1")).andReturn(autoDeploy).anyTimes();
  AutoDeployInfo dependencyAutoDeploy = new AutoDeployInfo();
  dependencyAutoDeploy.setEnabled(true);
  dependencyAutoDeploy.setCoLocate("service1/component1");
  expect(dependency1.getScope()).andReturn("host").anyTimes();
  expect(dependency1.getAutoDeploy()).andReturn(dependencyAutoDeploy).anyTimes();
  expect(dependency1.getComponentName()).andReturn("component3").anyTimes();
  expect(dependency1.getServiceName()).andReturn("service1").anyTimes();
  expect(dependency1.getName()).andReturn("dependency1").anyTimes();
  expect(dependencyComponentInfo.isClient()).andReturn(true).anyTimes();
  expect(stack.getComponentInfo("component3")).andReturn(dependencyComponentInfo).anyTimes();
  expect(group1.addComponent("component1")).andReturn(true).once();
  expect(group1.addComponent("component3")).andReturn(true).once();
  replay(blueprint, stack, group1, group2, dependency1, dependencyComponentInfo);
  BlueprintValidator validator = new BlueprintValidatorImpl(blueprint);
  validator.validateTopology();
  verify(group1);
}