@Test public void testProperConfiguration() throws NoSuchFieldException, IllegalAccessException { PolicyEngine testResult = PolicyEngineConfigurator.configure(PolicyEngineTestdata.RULESET_CONFIG); assertThat(testResult).isNotNull(); Collection<RuleExecutor> createdExecutor = extractExecutor(testResult); assertThat(createdExecutor.size()).isEqualTo(1); assertThat(identifyExecutors(createdExecutor, SingleArtifactExecutor.class.getName())).isTrue(); assertThat(identifyExecutors(createdExecutor, CompareArtifactExecutor.class.getName())).isFalse(); Collection<Rule> createdRules = extractRules(createdExecutor); assertThat(createdRules.size()).isEqualTo(2); createdRules.forEach(rule -> assertThat(rule).isInstanceOf(SingleArtifactRule.class)); }
public static PolicyEngine configure(final Collection<String> rulesetRefs) throws IllegalArgumentException { if (rulesetRefs == null || rulesetRefs.isEmpty()) { throw new IllegalArgumentException("Configuration Error: No rule set reference given"); } final Map<String, Set<Rule>> executorToRuleMapping = rulesetRefs.stream() .map(PolicyEngineConfigurator::createRuleset) .map(Ruleset::getRules) .flatMap(Collection::stream) .map(PolicyEngineConfigurator::mapRuleToExecutor) .collect(Collectors.groupingBy(RuleToExecutor::getExecutorClass, Collectors.mapping(RuleToExecutor::getRule, Collectors.toSet()))); PolicyEngine resultEngine = new PolicyEngine(createExecutors(executorToRuleMapping)); return resultEngine; }
PolicyEngineConfigurator { public static PolicyEngine configure(final Collection<String> rulesetRefs) throws IllegalArgumentException { if (rulesetRefs == null || rulesetRefs.isEmpty()) { throw new IllegalArgumentException("Configuration Error: No rule set reference given"); } final Map<String, Set<Rule>> executorToRuleMapping = rulesetRefs.stream() .map(PolicyEngineConfigurator::createRuleset) .map(Ruleset::getRules) .flatMap(Collection::stream) .map(PolicyEngineConfigurator::mapRuleToExecutor) .collect(Collectors.groupingBy(RuleToExecutor::getExecutorClass, Collectors.mapping(RuleToExecutor::getRule, Collectors.toSet()))); PolicyEngine resultEngine = new PolicyEngine(createExecutors(executorToRuleMapping)); return resultEngine; } }
PolicyEngineConfigurator { public static PolicyEngine configure(final Collection<String> rulesetRefs) throws IllegalArgumentException { if (rulesetRefs == null || rulesetRefs.isEmpty()) { throw new IllegalArgumentException("Configuration Error: No rule set reference given"); } final Map<String, Set<Rule>> executorToRuleMapping = rulesetRefs.stream() .map(PolicyEngineConfigurator::createRuleset) .map(Ruleset::getRules) .flatMap(Collection::stream) .map(PolicyEngineConfigurator::mapRuleToExecutor) .collect(Collectors.groupingBy(RuleToExecutor::getExecutorClass, Collectors.mapping(RuleToExecutor::getRule, Collectors.toSet()))); PolicyEngine resultEngine = new PolicyEngine(createExecutors(executorToRuleMapping)); return resultEngine; }  }
PolicyEngineConfigurator { public static PolicyEngine configure(final Collection<String> rulesetRefs) throws IllegalArgumentException { if (rulesetRefs == null || rulesetRefs.isEmpty()) { throw new IllegalArgumentException("Configuration Error: No rule set reference given"); } final Map<String, Set<Rule>> executorToRuleMapping = rulesetRefs.stream() .map(PolicyEngineConfigurator::createRuleset) .map(Ruleset::getRules) .flatMap(Collection::stream) .map(PolicyEngineConfigurator::mapRuleToExecutor) .collect(Collectors.groupingBy(RuleToExecutor::getExecutorClass, Collectors.mapping(RuleToExecutor::getRule, Collectors.toSet()))); PolicyEngine resultEngine = new PolicyEngine(createExecutors(executorToRuleMapping)); return resultEngine; }  static PolicyEngine configure(final Collection<String> rulesetRefs); }
PolicyEngineConfigurator { public static PolicyEngine configure(final Collection<String> rulesetRefs) throws IllegalArgumentException { if (rulesetRefs == null || rulesetRefs.isEmpty()) { throw new IllegalArgumentException("Configuration Error: No rule set reference given"); } final Map<String, Set<Rule>> executorToRuleMapping = rulesetRefs.stream() .map(PolicyEngineConfigurator::createRuleset) .map(Ruleset::getRules) .flatMap(Collection::stream) .map(PolicyEngineConfigurator::mapRuleToExecutor) .collect(Collectors.groupingBy(RuleToExecutor::getExecutorClass, Collectors.mapping(RuleToExecutor::getRule, Collectors.toSet()))); PolicyEngine resultEngine = new PolicyEngine(createExecutors(executorToRuleMapping)); return resultEngine; }  static PolicyEngine configure(final Collection<String> rulesetRefs);  }