Search in sources :

Example 6 with IsInstanceOf

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

the class InMemoryReaderFactoryTest method runTestCreateInMemoryReader.

<T> void runTestCreateInMemoryReader(List<T> elements, Long start, Long end, int expectedStart, int expectedEnd, Coder<T> coder) throws Exception {
    Source cloudSource = createInMemoryCloudSource(elements, start, end, coder);
    NativeReader<?> reader = ReaderRegistry.defaultRegistry().create(cloudSource, PipelineOptionsFactory.create(), BatchModeExecutionContext.forTesting(PipelineOptionsFactory.create(), "testStage"), TestOperationContext.create());
    assertThat(reader, new IsInstanceOf(InMemoryReader.class));
    InMemoryReader<?> inMemoryReader = (InMemoryReader<?>) reader;
    Assert.assertEquals(InMemoryReaderTest.encodedElements(elements, coder), inMemoryReader.encodedElements);
    Assert.assertEquals(expectedStart, inMemoryReader.startIndex);
    Assert.assertEquals(expectedEnd, inMemoryReader.endIndex);
    Assert.assertEquals(coder, inMemoryReader.coder);
}
Also used : IsInstanceOf(org.hamcrest.core.IsInstanceOf) Source(com.google.api.services.dataflow.model.Source)

Example 7 with IsInstanceOf

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

the class ReaderFactoryTest method testCreateReader.

@Test
public void testCreateReader() throws Exception {
    CloudObject spec = CloudObject.forClass(TestReaderFactory.class);
    Source cloudSource = new Source();
    cloudSource.setSpec(spec);
    cloudSource.setCodec(CloudObjects.asCloudObject(BigEndianIntegerCoder.of(), /*sdkComponents=*/
    null));
    PipelineOptions options = PipelineOptionsFactory.create();
    ReaderRegistry registry = ReaderRegistry.defaultRegistry().register(TestReaderFactory.class.getName(), new TestReaderFactory());
    NativeReader<?> reader = registry.create(cloudSource, PipelineOptionsFactory.create(), BatchModeExecutionContext.forTesting(options, "testStage"), null);
    assertThat(reader, new IsInstanceOf(TestReader.class));
}
Also used : CloudObject(org.apache.beam.runners.dataflow.util.CloudObject) PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) IsInstanceOf(org.hamcrest.core.IsInstanceOf) Source(com.google.api.services.dataflow.model.Source) Test(org.junit.Test)

Example 8 with IsInstanceOf

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

the class ShuffleSinkFactoryTest method runTestCreateShuffleSinkHelper.

private ShuffleSink runTestCreateShuffleSinkHelper(byte[] shuffleWriterConfig, String shuffleKind, Coder<?> deserializedCoder, FullWindowedValueCoder<?> coder) throws Exception {
    CloudObject spec = CloudObject.forClassName("ShuffleSink");
    addString(spec, "shuffle_writer_config", encodeBase64String(shuffleWriterConfig));
    addString(spec, "shuffle_kind", shuffleKind);
    PipelineOptions options = PipelineOptionsFactory.create();
    ShuffleSinkFactory factory = new ShuffleSinkFactory();
    Sink<?> sink = factory.create(spec, deserializedCoder, options, BatchModeExecutionContext.forTesting(options, "testStage"), TestOperationContext.create());
    assertThat(sink, new IsInstanceOf(ShuffleSink.class));
    ShuffleSink shuffleSink = (ShuffleSink) sink;
    Assert.assertArrayEquals(shuffleWriterConfig, shuffleSink.shuffleWriterConfig);
    Assert.assertEquals(coder, shuffleSink.windowedElemCoder);
    return shuffleSink;
}
Also used : CloudObject(org.apache.beam.runners.dataflow.util.CloudObject) PipelineOptions(org.apache.beam.sdk.options.PipelineOptions) IsInstanceOf(org.hamcrest.core.IsInstanceOf)

Example 9 with IsInstanceOf

use of org.hamcrest.core.IsInstanceOf in project druid by druid-io.

the class StupidPoolTest method testTake.

@Test
public void testTake() {
    Assert.assertThat(resourceHolderObj, new IsInstanceOf(ResourceHolder.class));
    Object expectedObject = resourceHolderObj.get();
    Assert.assertEquals(expectedObject, defaultString);
}
Also used : IsInstanceOf(org.hamcrest.core.IsInstanceOf) Test(org.junit.Test)

Example 10 with IsInstanceOf

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

the class AvroByteSinkFactoryTest method testCreateAvroByteSink.

@Test
public void testCreateAvroByteSink() throws Exception {
    Coder<?> coder = WindowedValue.getFullCoder(BigEndianIntegerCoder.of(), GlobalWindow.Coder.INSTANCE);
    Sink<?> sink = runTestCreateAvroSink(pathToAvroFile, coder);
    assertThat(sink, new IsInstanceOf(AvroByteSink.class));
    AvroByteSink<?> avroSink = (AvroByteSink<?>) sink;
    Assert.assertEquals(pathToAvroFile, avroSink.resourceId.toString());
    Assert.assertEquals(coder, avroSink.coder);
}
Also used : IsInstanceOf(org.hamcrest.core.IsInstanceOf) Test(org.junit.Test)

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