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

This commit is contained in:
Andrea Boriero 2017-01-31 17:57:18 +00:00
parent bb0b3e8c43
commit f007dc7c90
1 changed files with 21 additions and 15 deletions

View File

@ -261,25 +261,13 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
} }
} }
boolean foundMatch = false;
// @RequiresDialects & @RequiresDialect // @RequiresDialects & @RequiresDialect
final List<RequiresDialect> requiresDialects = Helper.collectAnnotations( final List<RequiresDialect> requiresDialects = Helper.collectAnnotations(
RequiresDialect.class, RequiresDialects.class, frameworkMethod, getTestClass() RequiresDialect.class, RequiresDialects.class, frameworkMethod, getTestClass()
); );
for ( RequiresDialect requiresDialectAnn : requiresDialects ) {
for ( Class<? extends Dialect> dialectClass : requiresDialectAnn.value() ) { if ( !requiresDialects.isEmpty() && !isDialectMatchingRequired( requiresDialects ) ) {
foundMatch = requiresDialectAnn.strictMatching()
? dialectClass.equals( dialect.getClass() )
: dialectClass.isInstance( dialect );
if ( foundMatch ) {
break;
}
}
if ( foundMatch ) {
break;
}
}
if ( !foundMatch ) {
return buildIgnore( requiresDialects ); return buildIgnore( requiresDialects );
} }
@ -308,6 +296,24 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
return null; return null;
} }
private boolean isDialectMatchingRequired(List<RequiresDialect> requiresDialects) {
boolean foundMatch = false;
for ( RequiresDialect requiresDialectAnn : requiresDialects ) {
for ( Class<? extends Dialect> dialectClass : requiresDialectAnn.value() ) {
foundMatch = requiresDialectAnn.strictMatching()
? dialectClass.equals( dialect.getClass() )
: dialectClass.isInstance( dialect );
if ( foundMatch ) {
break;
}
}
if ( foundMatch ) {
break;
}
}
return foundMatch;
}
private Ignore buildIgnore(Skip skip) { private Ignore buildIgnore(Skip skip) {
return new IgnoreImpl( "@Skip : " + skip.message() ); return new IgnoreImpl( "@Skip : " + skip.message() );
} }