Search in sources :

Example 11 with IsInstanceOf

use of org.hamcrest.core.IsInstanceOf in project beam by apache.

the class ShuffleReaderFactoryTest method runTestCreateShuffleReader.

<T extends NativeReader> T runTestCreateShuffleReader(byte[] shuffleReaderConfig, @Nullable String start, @Nullable String end, CloudObject encoding, BatchModeExecutionContext context, Class<T> shuffleReaderClass, String shuffleSourceAlias) throws Exception {
    CloudObject spec = CloudObject.forClassName(shuffleSourceAlias);
    addString(spec, "shuffle_reader_config", encodeBase64String(shuffleReaderConfig));
    if (start != null) {
        addString(spec, "start_shuffle_position", start);
    }
    if (end != null) {
        addString(spec, "end_shuffle_position", end);
    }
    Source cloudSource = new Source();
    cloudSource.setSpec(spec);
    cloudSource.setCodec(encoding);
    NativeReader<?> reader = ReaderRegistry.defaultRegistry().create(cloudSource, PipelineOptionsFactory.create(), context, null);
    assertThat(reader, new IsInstanceOf(shuffleReaderClass));
    return (T) reader;
}
Also used : CloudObject(org.apache.beam.runners.dataflow.util.CloudObject) IsInstanceOf(org.hamcrest.core.IsInstanceOf) Source(com.google.api.services.dataflow.model.Source)

Aggregations

IsInstanceOf (org.hamcrest.core.IsInstanceOf)11 Test (org.junit.Test)8 CloudObject (org.apache.beam.runners.dataflow.util.CloudObject)4 Source (com.google.api.services.dataflow.model.Source)3 PipelineOptions (org.apache.beam.sdk.options.PipelineOptions)2 StateStore (org.apache.kafka.streams.processor.StateStore)1