mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#34 Asserting line and source type of diagnostics only when specified via @Diagnostic
This commit is contained in:
parent
cd14bd368f
commit
785ccece90
@ -168,8 +168,12 @@ public abstract class MapperTestBase {
|
||||
DiagnosticDescriptor actual = actualIterator.next();
|
||||
DiagnosticDescriptor expected = expectedIterator.next();
|
||||
|
||||
assertThat( actual.getSourceFileName() ).isEqualTo( expected.getSourceFileName() );
|
||||
assertThat( actual.getLine() ).isEqualTo( expected.getLine() );
|
||||
if ( expected.getSourceFileName() != null ) {
|
||||
assertThat( actual.getSourceFileName() ).isEqualTo( expected.getSourceFileName() );
|
||||
}
|
||||
if ( expected.getLine() != null ) {
|
||||
assertThat( actual.getLine() ).isEqualTo( expected.getLine() );
|
||||
}
|
||||
assertThat( actual.getKind() ).isEqualTo( expected.getKind() );
|
||||
assertThat( actual.getMessage() ).describedAs(
|
||||
String.format(
|
||||
|
@ -32,7 +32,7 @@ public @interface Diagnostic {
|
||||
*
|
||||
* @return The type for which the diagnostic was created.
|
||||
*/
|
||||
Class<?> type() default Diagnostic.class;
|
||||
Class<?> type() default void.class;
|
||||
|
||||
/**
|
||||
* The expected kind of diagnostic.
|
||||
@ -46,7 +46,7 @@ public @interface Diagnostic {
|
||||
*
|
||||
* @return The expected line number of the diagnostic.
|
||||
*/
|
||||
int line() default -1;
|
||||
long line() default -1;
|
||||
|
||||
/**
|
||||
* A regular expression matching the expected message of the diagnostic.
|
||||
|
@ -37,10 +37,10 @@ public class DiagnosticDescriptor {
|
||||
|
||||
private final String sourceFileName;
|
||||
private final Kind kind;
|
||||
private final long line;
|
||||
private final Long line;
|
||||
private final String message;
|
||||
|
||||
private DiagnosticDescriptor(String sourceFileName, Kind kind, long line, String message) {
|
||||
private DiagnosticDescriptor(String sourceFileName, Kind kind, Long line, String message) {
|
||||
this.sourceFileName = sourceFileName;
|
||||
this.kind = kind;
|
||||
this.line = line;
|
||||
@ -48,13 +48,13 @@ public class DiagnosticDescriptor {
|
||||
}
|
||||
|
||||
public static DiagnosticDescriptor forDiagnostic(Diagnostic diagnostic) {
|
||||
String soureFileName = diagnostic.type() != Diagnostic.class
|
||||
String soureFileName = diagnostic.type() != void.class
|
||||
? diagnostic.type().getName().replace( ".", File.separator ) + ".java"
|
||||
: null;
|
||||
return new DiagnosticDescriptor(
|
||||
soureFileName,
|
||||
diagnostic.kind(),
|
||||
diagnostic.line(),
|
||||
diagnostic.line() != -1 ? diagnostic.line() : null,
|
||||
diagnostic.messageRegExp()
|
||||
);
|
||||
}
|
||||
@ -111,7 +111,7 @@ public class DiagnosticDescriptor {
|
||||
return kind;
|
||||
}
|
||||
|
||||
public long getLine() {
|
||||
public Long getLine() {
|
||||
return line;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user