Skip to content

Commit

Permalink
Refine validation reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed May 17, 2022
1 parent 231a394 commit 29b9357
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Expand Up @@ -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;
Expand Down
Expand Up @@ -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()));
}
}
}
14 changes: 7 additions & 7 deletions src/main/java/net/fortuna/ical4j/validate/ValidationRule.java
Expand Up @@ -17,13 +17,13 @@
public class ValidationRule<T> 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;

Expand Down
Expand Up @@ -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'() {
Expand All @@ -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'() {
Expand Down

0 comments on commit 29b9357

Please sign in to comment.