use of org.apache.storm.hdfs.trident.HdfsState.HdfsFileOptions in project storm by apache.
the class TestHdfsDataSourcesProvider method testHdfsSink.
@SuppressWarnings("unchecked")
@Test
public void testHdfsSink() {
ISqlTridentDataSource ds = DataSourcesRegistry.constructTridentDataSource(URI.create(hdfsURI), null, null, TBL_PROPERTIES, FIELDS);
Assert.assertNotNull(ds);
ISqlTridentDataSource.SqlTridentConsumer consumer = ds.getConsumer();
Assert.assertEquals(HdfsStateFactory.class, consumer.getStateFactory().getClass());
Assert.assertEquals(HdfsUpdater.class, consumer.getStateUpdater().getClass());
HdfsState state = (HdfsState) consumer.getStateFactory().makeState(Collections.emptyMap(), null, 0, 1);
StateUpdater stateUpdater = consumer.getStateUpdater();
HdfsFileOptions options = mock(HdfsFileOptions.class);
Whitebox.setInternalState(state, "options", options);
List<TridentTuple> tupleList = mockTupleList();
for (TridentTuple t : tupleList) {
stateUpdater.updateState(state, Collections.singletonList(t), null);
try {
verify(options).execute(Collections.singletonList(t));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Aggregations