@Test public void testRuleEvaluationRun() { Collection<PolicyViolation> result = testee.evaluate(PolicyEngineTestdata.ARTIFACTS); assertThat(result).isNotNull(); assertThat(result.size()).isEqualTo(2); Collection<String> ruleIds = result.stream().map(PolicyViolation::getId).distinct().collect( Collectors.toList()); assertThat(ruleIds.size()).isEqualTo(1); ruleIds.forEach(ruleId -> assertThat(ruleId).isEqualTo(PolicyEngineTestdata.ALWAYS_VIOLATED_ID)); result.stream().forEach(hashbase -> assertThat(hashbase.getViolationHash()).isEqualTo("msVGMmZSMtsiR8fbvd31Sw==")); }
public Collection<PolicyViolation> evaluate(final Collection<ThirdPartyArtifact> thirdPartyArtifacts) { LOGGER.debug("Artifacts are " + thirdPartyArtifacts.stream() .map(ThirdPartyArtifact::getCoordinates) .flatMap(Collection::stream) .map(Coordinate::canonicalize) .collect(Collectors.joining(",", "[", "]"))); Collection<PolicyViolation> violations = executors.parallelStream() .map(executor -> executor.executeRules(thirdPartyArtifacts)) .flatMap(Collection::stream) .collect(Collectors.toList()); if (violations.size() > 0) { LOGGER.warn("Number of violations found: " + violations.size()); } else { LOGGER.info("No violations found"); } return violations; }
PolicyEngine { public Collection<PolicyViolation> evaluate(final Collection<ThirdPartyArtifact> thirdPartyArtifacts) { LOGGER.debug("Artifacts are " + thirdPartyArtifacts.stream() .map(ThirdPartyArtifact::getCoordinates) .flatMap(Collection::stream) .map(Coordinate::canonicalize) .collect(Collectors.joining(",", "[", "]"))); Collection<PolicyViolation> violations = executors.parallelStream() .map(executor -> executor.executeRules(thirdPartyArtifacts)) .flatMap(Collection::stream) .collect(Collectors.toList()); if (violations.size() > 0) { LOGGER.warn("Number of violations found: " + violations.size()); } else { LOGGER.info("No violations found"); } return violations; } }
PolicyEngine { public Collection<PolicyViolation> evaluate(final Collection<ThirdPartyArtifact> thirdPartyArtifacts) { LOGGER.debug("Artifacts are " + thirdPartyArtifacts.stream() .map(ThirdPartyArtifact::getCoordinates) .flatMap(Collection::stream) .map(Coordinate::canonicalize) .collect(Collectors.joining(",", "[", "]"))); Collection<PolicyViolation> violations = executors.parallelStream() .map(executor -> executor.executeRules(thirdPartyArtifacts)) .flatMap(Collection::stream) .collect(Collectors.toList()); if (violations.size() > 0) { LOGGER.warn("Number of violations found: " + violations.size()); } else { LOGGER.info("No violations found"); } return violations; } PolicyEngine(final Collection<RuleExecutor> executors); }
PolicyEngine { public Collection<PolicyViolation> evaluate(final Collection<ThirdPartyArtifact> thirdPartyArtifacts) { LOGGER.debug("Artifacts are " + thirdPartyArtifacts.stream() .map(ThirdPartyArtifact::getCoordinates) .flatMap(Collection::stream) .map(Coordinate::canonicalize) .collect(Collectors.joining(",", "[", "]"))); Collection<PolicyViolation> violations = executors.parallelStream() .map(executor -> executor.executeRules(thirdPartyArtifacts)) .flatMap(Collection::stream) .collect(Collectors.toList()); if (violations.size() > 0) { LOGGER.warn("Number of violations found: " + violations.size()); } else { LOGGER.info("No violations found"); } return violations; } PolicyEngine(final Collection<RuleExecutor> executors); Collection<PolicyViolation> evaluate(final Collection<ThirdPartyArtifact> thirdPartyArtifacts); Collection<Ruleset> getRulesets(); }
PolicyEngine { public Collection<PolicyViolation> evaluate(final Collection<ThirdPartyArtifact> thirdPartyArtifacts) { LOGGER.debug("Artifacts are " + thirdPartyArtifacts.stream() .map(ThirdPartyArtifact::getCoordinates) .flatMap(Collection::stream) .map(Coordinate::canonicalize) .collect(Collectors.joining(",", "[", "]"))); Collection<PolicyViolation> violations = executors.parallelStream() .map(executor -> executor.executeRules(thirdPartyArtifacts)) .flatMap(Collection::stream) .collect(Collectors.toList()); if (violations.size() > 0) { LOGGER.warn("Number of violations found: " + violations.size()); } else { LOGGER.info("No violations found"); } return violations; } PolicyEngine(final Collection<RuleExecutor> executors); Collection<PolicyViolation> evaluate(final Collection<ThirdPartyArtifact> thirdPartyArtifacts); Collection<Ruleset> getRulesets();  }