use of com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple in project bullet-storm by yahoo.
the class FilterBoltTest method testRateLimiting.
@Test
public void testRateLimiting() {
config = new BulletStormConfig();
RateLimitError rateLimitError = new RateLimitError(42.0, config);
bolt = new RateLimitedFilterBolt(2, rateLimitError, config);
bolt = ComponentUtils.prepare(new HashMap<>(), bolt, collector);
Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeSimpleAggregationFilterQuery("field", singletonList("b235gf23b"), EQUALS, RAW, 100, Window.Unit.RECORD, 1, Window.Unit.RECORD, 1), METADATA);
bolt.execute(query);
BulletRecord record = RecordBox.get().add("field", "b235gf23b").getRecord();
Tuple matching = makeRecordTuple(record);
bolt.execute(matching);
bolt.execute(matching);
Tuple expected = makeSlidingTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 2, expected));
bolt.execute(matching);
Tuple error = TupleUtils.makeIDTuple(TupleClassifier.Type.ERROR_TUPLE, "42", rateLimitError);
Assert.assertTrue(collector.wasNthEmitted(error, 3));
}
Aggregations