From 03751c4c2924d7d81ac91e600f38091f1c4c3557 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Tue, 19 Apr 2022 18:06:28 +0200 Subject: [PATCH] HV-1863 Add the message in the diagnostic for easier error tracking --- .../validator/ap/testutil/CompilerTestHelper.java | 3 ++- .../validator/ap/util/DiagnosticExpectation.java | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/annotation-processor/src/test/java/org/hibernate/validator/ap/testutil/CompilerTestHelper.java b/annotation-processor/src/test/java/org/hibernate/validator/ap/testutil/CompilerTestHelper.java index c7d98b93aa..832a2b2be7 100644 --- a/annotation-processor/src/test/java/org/hibernate/validator/ap/testutil/CompilerTestHelper.java +++ b/annotation-processor/src/test/java/org/hibernate/validator/ap/testutil/CompilerTestHelper.java @@ -17,6 +17,7 @@ import java.util.EnumSet; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import javax.annotation.processing.Processor; @@ -253,7 +254,7 @@ private static Set asExpectations(Collection theValue = CollectionHelper.newTreeSet(); for ( Diagnostic diagnostic : diagnosticsList ) { - theValue.add( new DiagnosticExpectation( diagnostic.getKind(), diagnostic.getLineNumber() ) ); + theValue.add( new DiagnosticExpectation( diagnostic.getKind(), diagnostic.getLineNumber(), diagnostic.getMessage( Locale.ROOT ) ) ); } return theValue; diff --git a/annotation-processor/src/test/java/org/hibernate/validator/ap/util/DiagnosticExpectation.java b/annotation-processor/src/test/java/org/hibernate/validator/ap/util/DiagnosticExpectation.java index 3f9c1a391b..88aad3a29c 100644 --- a/annotation-processor/src/test/java/org/hibernate/validator/ap/util/DiagnosticExpectation.java +++ b/annotation-processor/src/test/java/org/hibernate/validator/ap/util/DiagnosticExpectation.java @@ -19,9 +19,18 @@ public class DiagnosticExpectation implements Comparable private final long lineNumber; + private final String message; + public DiagnosticExpectation(Kind kind, long lineNumber) { this.kind = kind; this.lineNumber = lineNumber; + this.message = null; + } + + public DiagnosticExpectation(Kind kind, long lineNumber, String message) { + this.kind = kind; + this.lineNumber = lineNumber; + this.message = message; } public Kind getKind() { @@ -34,7 +43,7 @@ public long getLineNumber() { @Override public String toString() { - return "DiagnosticExpectation [kind=" + kind + ", lineNumber=" + lineNumber + "]"; + return "DiagnosticExpectation [kind=" + kind + ", lineNumber=" + lineNumber + ", message=" + message + "]"; } @Override