use of org.apache.flink.connector.testframe.external.ExternalContextFactory 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();
});
}
Aggregations