From 29b9357d5fb35cab819176de4e8d9ad250198962 Mon Sep 17 00:00:00 2001 From: Ben Fortuna Date: Wed, 18 May 2022 00:26:36 +1000 Subject: [PATCH] Refine validation reporting --- .../fortuna/ical4j/validate/ValidationEntry.java | 2 +- .../fortuna/ical4j/validate/ValidationReport.java | 2 +- .../fortuna/ical4j/validate/ValidationRule.java | 14 +++++++------- .../ical4j/validate/ValidationReportTest.groovy | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/fortuna/ical4j/validate/ValidationEntry.java b/src/main/java/net/fortuna/ical4j/validate/ValidationEntry.java index 7aabb793c..f83e5afd0 100644 --- a/src/main/java/net/fortuna/ical4j/validate/ValidationEntry.java +++ b/src/main/java/net/fortuna/ical4j/validate/ValidationEntry.java @@ -54,7 +54,7 @@ public ValidationEntry(String message, Severity severity, String context) { this.context = context; } - public ValidationEntry(ValidationRule rule, String context, String...instances) { + public ValidationEntry(ValidationRule rule, String context, String...instances) { this.message = rule.getMessage(instances); this.severity = rule.getSeverity(); this.context = context; diff --git a/src/main/java/net/fortuna/ical4j/validate/ValidationReport.java b/src/main/java/net/fortuna/ical4j/validate/ValidationReport.java index 795254c6f..0778e42fb 100644 --- a/src/main/java/net/fortuna/ical4j/validate/ValidationReport.java +++ b/src/main/java/net/fortuna/ical4j/validate/ValidationReport.java @@ -79,7 +79,7 @@ private void outputHtml(ValidationResult result, Writer out) throws IOException private void outputText(ValidationResult result, Writer out) throws IOException { for (ValidationEntry entry : result.getEntries()) { - out.write(String.format("%s: %s - %s\n", entry.getContext(), entry.getSeverity(), entry.getMessage())); + out.write(String.format("- %s: %s - %s\n", entry.getSeverity(), entry.getContext(), entry.getMessage())); } } } diff --git a/src/main/java/net/fortuna/ical4j/validate/ValidationRule.java b/src/main/java/net/fortuna/ical4j/validate/ValidationRule.java index 313aeefef..16f5de0ba 100644 --- a/src/main/java/net/fortuna/ical4j/validate/ValidationRule.java +++ b/src/main/java/net/fortuna/ical4j/validate/ValidationRule.java @@ -17,13 +17,13 @@ public class ValidationRule implements Serializable { public enum ValidationType { - None("The following MUST NOT be present."), - One("The following are REQUIRED, but MUST NOT occur more than once."), - OneOrLess("The following are OPTIONAL, but MUST NOT occur more than once."), - OneOrMore("The following are OPTIONAL, and MAY occur more than once."), - OneExclusive("If one is present, ALL others MUST NOT be present."), - AllOrNone("If one is present, ALL must be present."), - ValueMatch("Value MUST match expression."); + None("The following MUST NOT be present:"), + One("The following are REQUIRED, but MUST NOT occur more than once:"), + OneOrLess("The following are OPTIONAL, but MUST NOT occur more than once:"), + OneOrMore("The following are OPTIONAL, and MAY occur more than once:"), + OneExclusive("If one is present, ALL others MUST NOT be present:"), + AllOrNone("If one is present, ALL must be present:"), + ValueMatch("Value MUST match expression:"); private final String description; diff --git a/src/test/groovy/net/fortuna/ical4j/validate/ValidationReportTest.groovy b/src/test/groovy/net/fortuna/ical4j/validate/ValidationReportTest.groovy index ae9d06cfa..c06d18b79 100644 --- a/src/test/groovy/net/fortuna/ical4j/validate/ValidationReportTest.groovy +++ b/src/test/groovy/net/fortuna/ical4j/validate/ValidationReportTest.groovy @@ -63,7 +63,7 @@ class ValidationReportTest extends Specification { new ValidationReport(TEXT).output(result, writer) then: 'output matches expected' - writer as String == 'VCALENDAR: ERROR - Missing mandatory properties\n' + writer as String == '- ERROR: VCALENDAR - Missing mandatory properties\n' } def 'generate multiline text format report'() { @@ -79,7 +79,7 @@ class ValidationReportTest extends Specification { new ValidationReport(TEXT).output(result, writer) then: 'output matches expected' - writer as String == 'DTSTART: WARNING - Invalid parameter\nVCALENDAR: ERROR - Missing mandatory properties\n' + writer as String == '- WARNING: DTSTART - Invalid parameter\n- ERROR: VCALENDAR - Missing mandatory properties\n' } def 'generate multiline html format report'() {