Skip to content

Commit

Permalink
Issue #432: Standardize the messages for all the criteria tests
Browse files Browse the repository at this point in the history
* Made little changes to improve code.
* Added Javadoc.
* Tested on MetricsHub
  • Loading branch information
CherfaElyes committed Oct 22, 2024
1 parent 176a731 commit f425f37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ public CriterionTestResult process(@SpanAttribute("criterion.definition") Proces
final CriterionTestResult result = localOSVisitor.getCriterionTestResult();

if (result != null) {
return result.setCriterion(processCriterion);
result.setCriterion(processCriterion);
return result;
} else {
return CriterionTestResult.error(
processCriterion,
Expand Down Expand Up @@ -363,7 +364,10 @@ public CriterionTestResult processCriterionThroughExtension(
return maybeExtension
.map(extension -> {
CriterionTestResult result = extension.processCriterion(criterion, connectorId, telemetryManager);
return result != null ? result.setCriterion(criterion) : null;
if (result != null) {
result.setCriterion(criterion);
}
return result;
})
.orElseGet(CriterionTestResult::empty);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ public static CriterionTestResult success(final Criterion criterion, final Strin
return CriterionTestResult.builder().success(true).message(message).result(result).criterion(criterion).build();
}

/**
* Formats and displays the criterion message in a structured, readable format.
* The output includes information about the executed criterion, its details,
* the result, and an additional message, each presented in distinct sections.
* @return a formatted string that displays the criterion name, details, result, and message.
*/
public String displayCriterionMessage() {
return String.format(
"Executed %s Criterion:\n" +
Expand All @@ -172,9 +178,4 @@ public String displayCriterionMessage() {
message != null ? message : "N/A"
);
}

public CriterionTestResult setCriterion(final Criterion criterion) {
this.criterion = criterion;
return this;
}
}

0 comments on commit f425f37

Please sign in to comment.