예제 #1
0
 private Ignore buildIgnore(SkipForDialect skip) {
   return buildIgnore("@SkipForDialect match", skip.comment(), skip.jiraKey());
 }
예제 #2
0
  protected Ignore convertSkipToIgnore(FrameworkMethod frameworkMethod) {
    // @Skip
    Skip skip = Helper.locateAnnotation(Skip.class, frameworkMethod, getTestClass());
    if (skip != null) {
      if (isMatch(skip.condition())) {
        return buildIgnore(skip);
      }
    }

    // @SkipForDialects & @SkipForDialect
    for (SkipForDialect skipForDialectAnn :
        Helper.collectAnnotations(
            SkipForDialect.class, SkipForDialects.class, frameworkMethod, getTestClass())) {
      for (Class<? extends Dialect> dialectClass : skipForDialectAnn.value()) {
        if (skipForDialectAnn.strictMatching()) {
          if (dialectClass.equals(dialect.getClass())) {
            return buildIgnore(skipForDialectAnn);
          }
        } else {
          if (dialectClass.isInstance(dialect)) {
            return buildIgnore(skipForDialectAnn);
          }
        }
      }
    }

    // @RequiresDialects & @RequiresDialect
    for (RequiresDialect requiresDialectAnn :
        Helper.collectAnnotations(
            RequiresDialect.class, RequiresDialects.class, frameworkMethod, getTestClass())) {
      boolean foundMatch = false;
      for (Class<? extends Dialect> dialectClass : requiresDialectAnn.value()) {
        foundMatch =
            requiresDialectAnn.strictMatching()
                ? dialectClass.equals(dialect.getClass())
                : dialectClass.isInstance(dialect);
        if (foundMatch) {
          break;
        }
      }
      if (!foundMatch) {
        return buildIgnore(requiresDialectAnn);
      }
    }

    // @RequiresDialectFeature
    RequiresDialectFeature requiresDialectFeatureAnn =
        Helper.locateAnnotation(RequiresDialectFeature.class, frameworkMethod, getTestClass());
    if (requiresDialectFeatureAnn != null) {
      try {
        boolean foundMatch = false;
        for (Class<? extends DialectCheck> checkClass : requiresDialectFeatureAnn.value()) {
          foundMatch = checkClass.newInstance().isMatch(dialect);
          if (!foundMatch) {
            return buildIgnore(requiresDialectFeatureAnn);
          }
        }
      } catch (RuntimeException e) {
        throw e;
      } catch (Exception e) {
        throw new RuntimeException("Unable to instantiate DialectCheck", e);
      }
    }

    return null;
  }