diff --git a/src/main/java/org/ihtsdo/rvf/core/service/DroolsRulesValidationService.java b/src/main/java/org/ihtsdo/rvf/core/service/DroolsRulesValidationService.java index 9eab1a63..a2e2ebd7 100644 --- a/src/main/java/org/ihtsdo/rvf/core/service/DroolsRulesValidationService.java +++ b/src/main/java/org/ihtsdo/rvf/core/service/DroolsRulesValidationService.java @@ -132,9 +132,7 @@ private void convertDroolsRuleToAssertion(File droolsRulesSubfile) throws IOExce // check for severity severityWarning = severityWarning || detectSeverity(line, "Severity.WARNING"); severityError = severityError || detectSeverity(line, "Severity.ERROR"); - if (assertion != null && "end".equals(line.trim())) { - assertion.setSeverity(buildSeverity(severityWarning, severityError)); - } + setSeverityIfNeeded(assertion, line, severityWarning, severityError); } } } @@ -147,6 +145,12 @@ private static UUID extractUuid(String line) { return null; } + private void setSeverityIfNeeded(Assertion assertion, String line, boolean severityWarning, boolean severityError) { + if (assertion != null && "end".equals(line.trim()) && (severityWarning || severityError)) { + assertion.setSeverity(buildSeverity(severityWarning, severityError)); + } + } + private static boolean detectSeverity(String line, String type) { return line.contains(type); } @@ -217,6 +221,7 @@ private ValidationReport constructValidationReport(ValidationRunConfig validatio List warningAssertions = new ArrayList<>(); int failureExportMax = validationConfig.getFailureExportMax() != null ? validationConfig.getFailureExportMax() : 10; Map uuidToAssertionMap = assertions.stream().collect(Collectors.toMap(Assertion::getUuid, Function.identity())); + Set failedAssertionUUIDs = new HashSet<>(); // Convert the Drools validation report into RVF report format invalidContentMap.keySet().forEach(ruleId -> { @@ -247,10 +252,24 @@ private ValidationReport constructValidationReport(ValidationRunConfig validatio } else { failedAssertions.add(validationRule); } + failedAssertionUUIDs.add(validationRule.getAssertionUuid()); }); ValidationReport validationReport = new ValidationReport(); validationReport.addFailedAssertions(failedAssertions); validationReport.addWarningAssertions(warningAssertions); + + Set passedAssertions = assertions.stream().filter(item -> validationConfig.getDroolsRulesGroupList().stream().anyMatch(item.getGroups()::contains) && !failedAssertionUUIDs.contains(item.getUuid())).collect(Collectors.toSet()); + validationReport.addPassedAssertions(passedAssertions.stream().map(item -> { + TestRunItem testRunItem = new TestRunItem(); + testRunItem.setFailureCount(0L); + testRunItem.setTestCategory(""); + testRunItem.setTestType(TestType.DROOL_RULES); + testRunItem.setSeverity(item.getSeverity()); + testRunItem.setAssertionUuid(item.getUuid()); + testRunItem.setAssertionText(item.getAssertionText()); + return testRunItem; + }).toList()); + return validationReport; }