Search in sources :

Example 1 with TestEnvironment

use of org.apache.flink.connector.testframe.environment.TestEnvironment in project flink by apache.

the class TestCaseInvocationContextProvider method provideTestTemplateInvocationContexts.

@SuppressWarnings("unchecked")
@Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
    // Fetch test environment from store
    TestEnvironment testEnv = context.getStore(TEST_RESOURCE_NAMESPACE).get(TEST_ENV_STORE_KEY, TestEnvironment.class);
    // Fetch external context factories from store
    List<ExternalContextFactory<?>> externalContextFactories = (List<ExternalContextFactory<?>>) context.getStore(TEST_RESOURCE_NAMESPACE).get(EXTERNAL_CONTEXT_FACTORIES_STORE_KEY);
    // Fetch supported semantic from store
    CheckpointingMode[] semantics = (CheckpointingMode[]) context.getStore(TEST_RESOURCE_NAMESPACE).get(SUPPORTED_SEMANTIC_STORE_KEY);
    // Create an invocation context for each external context factory
    return externalContextFactories.stream().flatMap(factory -> {
        List<TestResourceProvidingInvocationContext> result = new LinkedList<>();
        for (CheckpointingMode semantic : semantics) {
            result.add(new TestResourceProvidingInvocationContext(testEnv, factory.createExternalContext(context.getDisplayName()), semantic));
        }
        return result.stream();
    });
}
Also used : TestEnvironment(org.apache.flink.connector.testframe.environment.TestEnvironment) ExternalContextFactory(org.apache.flink.connector.testframe.external.ExternalContextFactory) CheckpointingMode(org.apache.flink.streaming.api.CheckpointingMode) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 List (java.util.List)1 TestEnvironment (org.apache.flink.connector.testframe.environment.TestEnvironment)1 ExternalContextFactory (org.apache.flink.connector.testframe.external.ExternalContextFactory)1 CheckpointingMode (org.apache.flink.streaming.api.CheckpointingMode)1