Search in sources :

Example 1 with JanusGraphBaseStoreFeaturesTest

use of org.janusgraph.JanusGraphBaseStoreFeaturesTest 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.");
    }
}
Also used : AnnotationSupport(org.junit.platform.commons.support.AnnotationSupport) JanusGraphBaseStoreFeaturesTest(org.janusgraph.JanusGraphBaseStoreFeaturesTest) ExtensionContextException(org.junit.jupiter.api.extension.ExtensionContextException) TestAbortedException(org.opentest4j.TestAbortedException) Optional(java.util.Optional) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) BeforeTestExecutionCallback(org.junit.jupiter.api.extension.BeforeTestExecutionCallback) ExtensionContextException(org.junit.jupiter.api.extension.ExtensionContextException) TestAbortedException(org.opentest4j.TestAbortedException) JanusGraphBaseStoreFeaturesTest(org.janusgraph.JanusGraphBaseStoreFeaturesTest)

Aggregations

Optional (java.util.Optional)1 JanusGraphBaseStoreFeaturesTest (org.janusgraph.JanusGraphBaseStoreFeaturesTest)1 BeforeTestExecutionCallback (org.junit.jupiter.api.extension.BeforeTestExecutionCallback)1 ExtensionContext (org.junit.jupiter.api.extension.ExtensionContext)1 ExtensionContextException (org.junit.jupiter.api.extension.ExtensionContextException)1 AnnotationSupport (org.junit.platform.commons.support.AnnotationSupport)1 TestAbortedException (org.opentest4j.TestAbortedException)1