use of org.junit.jupiter.api.extension.ExtensionContextException in project janusgraph by JanusGraph.
the class FeatureRequirementCondition method beforeTestExecution.
@Override
public void beforeTestExecution(ExtensionContext context) throws Exception {
FeatureFlag annotation = context.getTestMethod().flatMap(testMethods -> AnnotationSupport.findAnnotation(testMethods, FeatureFlag.class)).orElseThrow(() -> new ExtensionContextException("The extension should not be executed " + "unless the test method is annotated with @FeatureRequirement."));
Optional<Object> testInstance = context.getTestInstance();
JanusGraphBaseStoreFeaturesTest test = (JanusGraphBaseStoreFeaturesTest) testInstance.get();
switch(annotation.feature()) {
case CellTtl:
if (!test.getStoreFeatures().hasCellTTL()) {
throw new TestAbortedException("Database doesn't support CellTtl.");
}
break;
case Scan:
if (!test.getStoreFeatures().hasScan()) {
throw new TestAbortedException("Database doesn't support ordered/unordered scan.");
}
break;
case OrderedScan:
if (!test.getStoreFeatures().hasOrderedScan()) {
throw new TestAbortedException("Database doesn't support ordered scan.");
}
break;
case UnorderedScan:
if (!test.getStoreFeatures().hasUnorderedScan()) {
throw new TestAbortedException("Database doesn't support unordered scan.");
}
break;
default:
throw new UnsupportedOperationException("Feature Flag " + annotation.feature() + " is not supported.");
}
}
Aggregations