HHH-11428 - When multiple @RequiresDialect annotation is applied the test is ignored

This commit is contained in:
Andrea Boriero 2017-01-26 15:13:58 +00:00 committed by Vlad Mihalcea
parent b19d76f2cc
commit e547ee0793
1 changed files with 28 additions and 9 deletions

View File

@ -261,11 +261,12 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
}
}
boolean foundMatch = false;
// @RequiresDialects & @RequiresDialect
for ( RequiresDialect requiresDialectAnn : Helper.collectAnnotations(
final List<RequiresDialect> requiresDialects = Helper.collectAnnotations(
RequiresDialect.class, RequiresDialects.class, frameworkMethod, getTestClass()
) ) {
boolean foundMatch = false;
);
for ( RequiresDialect requiresDialectAnn : requiresDialects ) {
for ( Class<? extends Dialect> dialectClass : requiresDialectAnn.value() ) {
foundMatch = requiresDialectAnn.strictMatching()
? dialectClass.equals( dialect.getClass() )
@ -274,10 +275,13 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
break;
}
}
if ( !foundMatch ) {
return buildIgnore( requiresDialectAnn );
if ( foundMatch ) {
break;
}
}
if ( !foundMatch ) {
return buildIgnore( requiresDialects );
}
// @RequiresDialectFeature
RequiresDialectFeature requiresDialectFeatureAnn = Helper.locateAnnotation(
@ -287,10 +291,8 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
);
if ( requiresDialectFeatureAnn != null ) {
try {
boolean foundMatch = false;
for ( Class<? extends DialectCheck> checkClass : requiresDialectFeatureAnn.value() ) {
foundMatch = checkClass.newInstance().isMatch( dialect );
if ( !foundMatch ) {
if ( !checkClass.newInstance().isMatch( dialect ) ) {
return buildIgnore( requiresDialectFeatureAnn );
}
}
@ -315,6 +317,10 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
}
private Ignore buildIgnore(String reason, String comment, String jiraKey) {
return new IgnoreImpl( getIgnoreMessage( reason, comment, jiraKey ) );
}
private String getIgnoreMessage(String reason, String comment, String jiraKey) {
StringBuilder buffer = new StringBuilder( reason );
if ( StringHelper.isNotEmpty( comment ) ) {
buffer.append( "; " ).append( comment );
@ -324,13 +330,26 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
buffer.append( " (" ).append( jiraKey ).append( ')' );
}
return new IgnoreImpl( buffer.toString() );
return buffer.toString();
}
private Ignore buildIgnore(RequiresDialect requiresDialect) {
return buildIgnore( "@RequiresDialect non-match", requiresDialect.comment(), requiresDialect.jiraKey() );
}
private Ignore buildIgnore(List<RequiresDialect> requiresDialects) {
String ignoreMessage = "";
for ( RequiresDialect requiresDialect : requiresDialects ) {
ignoreMessage += getIgnoreMessage(
"@RequiresDialect non-match",
requiresDialect.comment(),
requiresDialect.jiraKey()
);
ignoreMessage += System.lineSeparator();
}
return new IgnoreImpl( ignoreMessage );
}
private Ignore buildIgnore(RequiresDialectFeature requiresDialectFeature) {
return buildIgnore(
"@RequiresDialectFeature non-match",