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);
}
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));
}
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;
}
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);
}
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);
}
Aggregations