Search in sources :

Example 1 with TupleUtils.makeRawTuple

use of com.yahoo.bullet.storm.testing.TupleUtils.makeRawTuple in project bullet-storm by yahoo.

the class FilterBoltTest method testTuplesCustomSource.

@Test
public void testTuplesCustomSource() {
    bolt = ComponentUtils.prepare(new FilterBolt("CustomSource", oneRecordConfig()), collector);
    Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeFieldFilterQuery("b235gf23b"), METADATA);
    bolt.execute(query);
    BulletRecord record = RecordBox.get().add("field", "b235gf23b").getRecord();
    Tuple matching = TupleUtils.makeRawTuple("CustomSource", TopologyConstants.RECORD_STREAM, record);
    bolt.execute(matching);
    Tuple tick = TupleUtils.makeTuple(TupleClassifier.Type.TICK_TUPLE);
    bolt.execute(tick);
    BulletRecord anotherRecord = RecordBox.get().add("field", "wontmatch").getRecord();
    Tuple nonMatching = TupleUtils.makeRawTuple("CustomSource", TopologyConstants.RECORD_STREAM, anotherRecord);
    bolt.execute(nonMatching);
    Tuple expected = makeDataTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
    Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 1, expected));
    Tuple notExpected = makeDataTuple(TupleClassifier.Type.DATA_TUPLE, "42", anotherRecord);
    Assert.assertFalse(wasRawRecordEmitted(notExpected));
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) TupleUtils.makeTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeTuple) TupleUtils.makeRawTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeRawTuple) Tuple(org.apache.storm.tuple.Tuple) TupleUtils.makeIDTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple) Test(org.testng.annotations.Test) DistributionTest(com.yahoo.bullet.aggregations.DistributionTest) TopKTest(com.yahoo.bullet.aggregations.TopKTest) CountDistinctTest(com.yahoo.bullet.aggregations.CountDistinctTest)

Aggregations

CountDistinctTest (com.yahoo.bullet.aggregations.CountDistinctTest)1 DistributionTest (com.yahoo.bullet.aggregations.DistributionTest)1 TopKTest (com.yahoo.bullet.aggregations.TopKTest)1 BulletRecord (com.yahoo.bullet.record.BulletRecord)1 TupleUtils.makeIDTuple (com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple)1 TupleUtils.makeRawTuple (com.yahoo.bullet.storm.testing.TupleUtils.makeRawTuple)1 TupleUtils.makeTuple (com.yahoo.bullet.storm.testing.TupleUtils.makeTuple)1 Tuple (org.apache.storm.tuple.Tuple)1 Test (org.testng.annotations.Test)1