@Test(expected=InvalidTopologyException.class)
public void testWhenComponentIsConditionallyDependentAndOnlyOneOfTheConditionsIsSatisfied() throws Exception {

  // GIVEN
  hostGroups.clear();
  hostGroups.put("group1", group1);
  group1Components.add("component-1");
  dependencies1.add(dependency1);
  dependencies1.add(dependency2);
  services.addAll(Collections.singleton("service-1"));
  expect(blueprint.getHostGroupsForComponent("component-1")).andReturn(Arrays.asList(group1)).anyTimes();
  expect(blueprint.getName()).andReturn("blueprint-1").anyTimes();
  Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>();
  Map<String, String> typeProps = new HashMap<String, String>();
  typeProps.put("yarn.resourcemanager.hostname", "testhost");
  properties.put("yarn-site", typeProps);
  Configuration clusterConfig = new Configuration(properties,
     Collections.<String, Map<String, Map<String, String>>>emptyMap());
  Cardinality cardinality = new Cardinality("1");
  expect(stack.getComponents("service-1")).andReturn(Arrays.asList("component-1")).anyTimes();
  expect(stack.getAutoDeployInfo("component-1")).andReturn(autoDeploy).anyTimes();
  expect(stack.getDependenciesForComponent("component-1")).andReturn(dependencies1).anyTimes();
  expect(stack.getCardinality("component-1")).andReturn(cardinality).anyTimes();
  AutoDeployInfo dependencyAutoDeploy = null;
  expect(dependency1.getScope()).andReturn("host").anyTimes();
  expect(dependency1.getAutoDeploy()).andReturn(dependencyAutoDeploy).anyTimes();
  expect(dependency1.getComponentName()).andReturn("component-d").anyTimes();
  expect(dependency1.getServiceName()).andReturn("service-d").anyTimes();
  expect(dependency1.getName()).andReturn("dependency-1").anyTimes();
  expect(dependency1.hasDependencyConditions()).andReturn(true).anyTimes();
  expect(dependency1.getDependencyConditions()).andReturn(dependenciesConditionInfos1).anyTimes();
  expect(dependency2.getScope()).andReturn("host").anyTimes();
  expect(dependency2.getAutoDeploy()).andReturn(dependencyAutoDeploy).anyTimes();
  expect(dependency2.getComponentName()).andReturn("component-d").anyTimes();
  expect(dependency2.getServiceName()).andReturn("service-d").anyTimes();
  expect(dependency2.getName()).andReturn("dependency-2").anyTimes();
  expect(dependency2.hasDependencyConditions()).andReturn(false).anyTimes();
  expect(dependencyConditionInfo1.isResolved(EasyMock.<Map<String, Map<String, String>>>anyObject())).andReturn(true).anyTimes();
  expect(dependencyConditionInfo2.isResolved(EasyMock.<Map<String, Map<String, String>>>anyObject())).andReturn(false).anyTimes();
  expect(dependencyComponentInfo.isClient()).andReturn(false).anyTimes();
  expect(stack.getComponentInfo("component-d")).andReturn(dependencyComponentInfo).anyTimes();
  replay(blueprint, stack, group1, group2, dependency1, dependency2, dependencyComponentInfo,dependencyConditionInfo1,dependencyConditionInfo2);
  // WHEN
  BlueprintValidator validator = new BlueprintValidatorImpl(blueprint);
  validator.validateTopology();
  // THEN
  verify(group1);
}