use of org.apache.storm.trident.state.StateUpdater in project storm by apache.
the class TestMongoDataSourcesProvider method testMongoSink.
@SuppressWarnings("unchecked")
@Test
public void testMongoSink() {
ISqlTridentDataSource ds = DataSourcesRegistry.constructTridentDataSource(URI.create("mongodb://127.0.0.1:27017/test"), null, null, TBL_PROPERTIES, FIELDS);
Assert.assertNotNull(ds);
ISqlTridentDataSource.SqlTridentConsumer consumer = ds.getConsumer();
Assert.assertEquals(MongoStateFactory.class, consumer.getStateFactory().getClass());
Assert.assertEquals(MongoStateUpdater.class, consumer.getStateUpdater().getClass());
MongoState state = (MongoState) consumer.getStateFactory().makeState(Collections.emptyMap(), null, 0, 1);
StateUpdater stateUpdater = consumer.getStateUpdater();
MongoDBClient mongoClient = mock(MongoDBClient.class);
Whitebox.setInternalState(state, "mongoClient", mongoClient);
List<TridentTuple> tupleList = mockTupleList();
for (TridentTuple t : tupleList) {
stateUpdater.updateState(state, Collections.singletonList(t), null);
verify(mongoClient).insert(argThat(new MongoArgMatcher(t)), eq(true));
}
verifyNoMoreInteractions(mongoClient);
}
Aggregations