CoordinatesValidator extends AbstractComplianceChecker { @Override public IPolicyEvaluation evaluate(Collection<Artifact> artifacts) { DefaultPolicyEvaluation policyEvaluation = new DefaultPolicyEvaluation(); artifacts.stream() .filter(artifact -> ! artifact.getFlag(Artifact.IS_PROPRIETARY_FLAG_KEY)) .filter(artifact -> artifact.askForAll(ArtifactCoordinates.class).size() == 0) .forEach(artifact -> policyEvaluation.addEvaluationResult("CoordinatesValidator::rule1", "Artifact has no Coordinates", missingCoordinatesSeverity, artifact)); return policyEvaluation; } CoordinatesValidator(); @Override IPolicyEvaluation evaluate(Collection<Artifact> artifacts); @Override String getRulesetDescription(); @Override void configure(Map<String, String> configMap);  }
@Test public void validateCoordinatesTestFalse() { assertThat(validator.evaluate(artifacts).getEvaluationResults().size()).isEqualTo(1); }
@Test public void validateCoordinatesTest() { assertThat(validator.evaluate(artifacts).getEvaluationResults().size()).isEqualTo(1); }
@Test public void validateCoordinatesTestMvn() { artifact.addCoordinate(new Coordinate(Coordinate.Types.MAVEN, "test", "test", "test")); assertThat(validator.evaluate(artifacts).getEvaluationResults().size()).isEqualTo(0); }
@Test public void validateCoordinatesTestP2() { artifact.addCoordinate(new Coordinate(Coordinate.Types.P2, "test", "test")); assertThat(validator.evaluate(artifacts).getEvaluationResults().size()).isEqualTo(0); }
@Test public void validateCoordinatesTestP2andMvn() { artifact.addCoordinate(new Coordinate(Coordinate.Types.MAVEN, "test", "test", "test")); artifact.addCoordinate(new Coordinate(Coordinate.Types.P2, "test", "test")); assertThat(validator.evaluate(artifacts).getEvaluationResults().size()).isEqualTo(0); }