Skip to content

Commit

Permalink
VAL-406 Added the passed Drools assertions to RVF report
Browse files Browse the repository at this point in the history
  • Loading branch information
QuyenLy87 committed Sep 3, 2024
1 parent 5f3474a commit 63e8922
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +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())) {
if (assertion != null && "end".equals(line.trim()) && (severityWarning || severityError)) {
assertion.setSeverity(buildSeverity(severityWarning, severityError));
}
}
Expand Down Expand Up @@ -217,6 +217,7 @@ private ValidationReport constructValidationReport(ValidationRunConfig validatio
List<TestRunItem> warningAssertions = new ArrayList<>();
int failureExportMax = validationConfig.getFailureExportMax() != null ? validationConfig.getFailureExportMax() : 10;
Map<UUID, Assertion> uuidToAssertionMap = assertions.stream().collect(Collectors.toMap(Assertion::getUuid, Function.identity()));
Set<UUID> failedAssertionUUIDs = new HashSet<>();

// Convert the Drools validation report into RVF report format
invalidContentMap.keySet().forEach(ruleId -> {
Expand Down Expand Up @@ -247,10 +248,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<Assertion> 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;
}

Expand Down

0 comments on commit 63e8922

Please sign in to comment.