Skip to content

Commit

Permalink
FRI-621 Truncate the full component text if it's too long while creat…
Browse files Browse the repository at this point in the history
…ing JIRA ticket for RVF failures
  • Loading branch information
QuyenLy87 committed Mar 14, 2023
1 parent 99e8f93 commit 90f8a75
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private String generateDescription(Build build, ValidationReport.RvfValidationRe
List<ValidationReport.RvfValidationResult.TestResult.TestRunItem.FailureDetail> firstNInstances = getFirstNInstances(testRunItem.getFirstNInstances(), 10);
result += "First " + firstNInstances.size() + " failures: \n";
for (ValidationReport.RvfValidationResult.TestResult.TestRunItem.FailureDetail failureDetail: firstNInstances) {
result += "* " + failureDetail.toString() + "\n";
result += "* " + failureDetail.toStringAndTruncateIfTextTooLong() + "\n";
}

return result;
Expand Down Expand Up @@ -328,6 +328,7 @@ public String toString() {
}

private static final class FailureDetail {
private static final int FULL_COMPONENT_MAX_LENGTH = 1000;
private String conceptId;
private String conceptFsn;
private String detail;
Expand Down Expand Up @@ -364,6 +365,16 @@ public String toString() {
"\"fullComponent\": " + (fullComponent != null ? '\"' + fullComponent + '\"' : null) + "\n" +
"}";
}

public String toStringAndTruncateIfTextTooLong() {
return "{\n\t" +
"\"conceptId\": " + (conceptId != null ? '\"' + conceptId + '\"' : null) + ",\n\t" +
"\"conceptFsn\": " + (conceptFsn != null ? '\"' + conceptFsn + '\"' : null) + ",\n\t" +
"\"detail\": " + (detail != null ? '\"' + detail + '\"' : null) + ",\n\t" +
"\"componentId\": " + (componentId != null ? '\"' + componentId + '\"' : null) + ",\n\t" +
"\"fullComponent\": " + (fullComponent != null ? '\"' + (fullComponent.length() <= FULL_COMPONENT_MAX_LENGTH ? fullComponent : fullComponent.substring(0, FULL_COMPONENT_MAX_LENGTH)) + "..." + '\"' : null) + "\n" +
"}";
}
}
}
}
Expand Down

0 comments on commit 90f8a75

Please sign in to comment.