@Test(expected = InvalidTopologyException.class) public void testValidateTopology_basic_negative() throws Exception { group1Components.add("component2"); services.addAll(Collections.singleton("service1")); expect(stack.getComponents("service1")).andReturn(Arrays.asList("component1", "component2")).anyTimes(); expect(blueprint.getHostGroupsForComponent("component1")).andReturn(Collections.<HostGroup>emptyList()).anyTimes(); expect(blueprint.getHostGroupsForComponent("component2")).andReturn(Arrays.asList(group1, group2)).anyTimes(); replay(blueprint, stack, group1, group2, dependency1); BlueprintValidator validator = new BlueprintValidatorImpl(blueprint); validator.validateTopology(); }
@Override public void validateTopology() throws InvalidTopologyException { LOGGER.info("Validating topology for blueprint: [{}]", blueprint.getName()); Collection<HostGroup> hostGroups = blueprint.getHostGroups().values(); Map<String, Map<String, Collection<DependencyInfo>>> missingDependencies = new HashMap<String, Map<String, Collection<DependencyInfo>>>(); for (HostGroup group : hostGroups) { Map<String, Collection<DependencyInfo>> missingGroupDependencies = validateHostGroup(group); if (! missingGroupDependencies.isEmpty()) { missingDependencies.put(group.getName(), missingGroupDependencies); } } Collection<String> cardinalityFailures = new HashSet<String>(); Collection<String> services = blueprint.getServices(); for (String service : services) { for (String component : stack.getComponents(service)) { Cardinality cardinality = stack.getCardinality(component); AutoDeployInfo autoDeploy = stack.getAutoDeployInfo(component); if (cardinality.isAll()) { cardinalityFailures.addAll(verifyComponentInAllHostGroups(component, autoDeploy)); } else { cardinalityFailures.addAll(verifyComponentCardinalityCount( component, cardinality, autoDeploy)); } } } if (! missingDependencies.isEmpty() || ! cardinalityFailures.isEmpty()) { generateInvalidTopologyException(missingDependencies, cardinalityFailures); } }
BlueprintValidatorImpl implements BlueprintValidator { @Override public void validateTopology() throws InvalidTopologyException { LOGGER.info("Validating topology for blueprint: [{}]", blueprint.getName()); Collection<HostGroup> hostGroups = blueprint.getHostGroups().values(); Map<String, Map<String, Collection<DependencyInfo>>> missingDependencies = new HashMap<String, Map<String, Collection<DependencyInfo>>>(); for (HostGroup group : hostGroups) { Map<String, Collection<DependencyInfo>> missingGroupDependencies = validateHostGroup(group); if (! missingGroupDependencies.isEmpty()) { missingDependencies.put(group.getName(), missingGroupDependencies); } } Collection<String> cardinalityFailures = new HashSet<String>(); Collection<String> services = blueprint.getServices(); for (String service : services) { for (String component : stack.getComponents(service)) { Cardinality cardinality = stack.getCardinality(component); AutoDeployInfo autoDeploy = stack.getAutoDeployInfo(component); if (cardinality.isAll()) { cardinalityFailures.addAll(verifyComponentInAllHostGroups(component, autoDeploy)); } else { cardinalityFailures.addAll(verifyComponentCardinalityCount( component, cardinality, autoDeploy)); } } } if (! missingDependencies.isEmpty() || ! cardinalityFailures.isEmpty()) { generateInvalidTopologyException(missingDependencies, cardinalityFailures); } } }
BlueprintValidatorImpl implements BlueprintValidator { @Override public void validateTopology() throws InvalidTopologyException { LOGGER.info("Validating topology for blueprint: [{}]", blueprint.getName()); Collection<HostGroup> hostGroups = blueprint.getHostGroups().values(); Map<String, Map<String, Collection<DependencyInfo>>> missingDependencies = new HashMap<String, Map<String, Collection<DependencyInfo>>>(); for (HostGroup group : hostGroups) { Map<String, Collection<DependencyInfo>> missingGroupDependencies = validateHostGroup(group); if (! missingGroupDependencies.isEmpty()) { missingDependencies.put(group.getName(), missingGroupDependencies); } } Collection<String> cardinalityFailures = new HashSet<String>(); Collection<String> services = blueprint.getServices(); for (String service : services) { for (String component : stack.getComponents(service)) { Cardinality cardinality = stack.getCardinality(component); AutoDeployInfo autoDeploy = stack.getAutoDeployInfo(component); if (cardinality.isAll()) { cardinalityFailures.addAll(verifyComponentInAllHostGroups(component, autoDeploy)); } else { cardinalityFailures.addAll(verifyComponentCardinalityCount( component, cardinality, autoDeploy)); } } } if (! missingDependencies.isEmpty() || ! cardinalityFailures.isEmpty()) { generateInvalidTopologyException(missingDependencies, cardinalityFailures); } } BlueprintValidatorImpl(Blueprint blueprint); }
BlueprintValidatorImpl implements BlueprintValidator { @Override public void validateTopology() throws InvalidTopologyException { LOGGER.info("Validating topology for blueprint: [{}]", blueprint.getName()); Collection<HostGroup> hostGroups = blueprint.getHostGroups().values(); Map<String, Map<String, Collection<DependencyInfo>>> missingDependencies = new HashMap<String, Map<String, Collection<DependencyInfo>>>(); for (HostGroup group : hostGroups) { Map<String, Collection<DependencyInfo>> missingGroupDependencies = validateHostGroup(group); if (! missingGroupDependencies.isEmpty()) { missingDependencies.put(group.getName(), missingGroupDependencies); } } Collection<String> cardinalityFailures = new HashSet<String>(); Collection<String> services = blueprint.getServices(); for (String service : services) { for (String component : stack.getComponents(service)) { Cardinality cardinality = stack.getCardinality(component); AutoDeployInfo autoDeploy = stack.getAutoDeployInfo(component); if (cardinality.isAll()) { cardinalityFailures.addAll(verifyComponentInAllHostGroups(component, autoDeploy)); } else { cardinalityFailures.addAll(verifyComponentCardinalityCount( component, cardinality, autoDeploy)); } } } if (! missingDependencies.isEmpty() || ! cardinalityFailures.isEmpty()) { generateInvalidTopologyException(missingDependencies, cardinalityFailures); } } BlueprintValidatorImpl(Blueprint blueprint); @Override void validateTopology(); @Override void validateRequiredProperties(); Collection<String> verifyComponentCardinalityCount(String component,
                                                            Cardinality cardinality,
                                                            AutoDeployInfo autoDeploy); }
BlueprintValidatorImpl implements BlueprintValidator { @Override public void validateTopology() throws InvalidTopologyException { LOGGER.info("Validating topology for blueprint: [{}]", blueprint.getName()); Collection<HostGroup> hostGroups = blueprint.getHostGroups().values(); Map<String, Map<String, Collection<DependencyInfo>>> missingDependencies = new HashMap<String, Map<String, Collection<DependencyInfo>>>(); for (HostGroup group : hostGroups) { Map<String, Collection<DependencyInfo>> missingGroupDependencies = validateHostGroup(group); if (! missingGroupDependencies.isEmpty()) { missingDependencies.put(group.getName(), missingGroupDependencies); } } Collection<String> cardinalityFailures = new HashSet<String>(); Collection<String> services = blueprint.getServices(); for (String service : services) { for (String component : stack.getComponents(service)) { Cardinality cardinality = stack.getCardinality(component); AutoDeployInfo autoDeploy = stack.getAutoDeployInfo(component); if (cardinality.isAll()) { cardinalityFailures.addAll(verifyComponentInAllHostGroups(component, autoDeploy)); } else { cardinalityFailures.addAll(verifyComponentCardinalityCount( component, cardinality, autoDeploy)); } } } if (! missingDependencies.isEmpty() || ! cardinalityFailures.isEmpty()) { generateInvalidTopologyException(missingDependencies, cardinalityFailures); } } BlueprintValidatorImpl(Blueprint blueprint); @Override void validateTopology(); @Override void validateRequiredProperties(); Collection<String> verifyComponentCardinalityCount(String component,
                                                            Cardinality cardinality,
                                                            AutoDeployInfo autoDeploy);  }