use of com.yahoo.bullet.result.Meta in project bullet-storm by yahoo.
the class JoinBoltTest method testQueryIdentifierMetadata.
@Test
public void testQueryIdentifierMetadata() {
config = configWithRawMaxAndEmptyMeta();
enableMetadataInConfig(config, Concept.QUERY_METADATA.getName(), "meta");
enableMetadataInConfig(config, Concept.QUERY_ID.getName(), "id");
setup(new JoinBolt(config));
Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "{}", EMPTY);
bolt.execute(query);
List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42");
Meta meta = new Meta();
meta.add("meta", singletonMap("id", "42"));
Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42", Clip.of(sent).add(meta).asJSON(), COMPLETED);
Assert.assertTrue(wasResultEmittedTo(TopologyConstants.RESULT_STREAM, expected));
Tuple metadata = TupleUtils.makeTuple(TupleClassifier.Type.FEEDBACK_TUPLE, "42", new Metadata(Metadata.Signal.COMPLETE, null));
Assert.assertTrue(wasMetadataEmittedTo(TopologyConstants.FEEDBACK_STREAM, metadata));
Assert.assertEquals(collector.getAllEmittedTo(TopologyConstants.RESULT_STREAM).count(), 1);
Assert.assertEquals(collector.getAllEmittedTo(TopologyConstants.FEEDBACK_STREAM).count(), 1);
}
use of com.yahoo.bullet.result.Meta in project bullet-storm by yahoo.
the class JoinBoltTest method testUnknownAggregation.
@Test
public void testUnknownAggregation() {
// Lowercase "top" is not valid and will not be parsed since there is no enum for it
// In this case aggregation type should be set to null and an error should be emitted
Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "{\"aggregation\": {\"type\": \"garbage\"}}", EMPTY);
bolt.execute(query);
Assert.assertEquals(collector.getEmittedCount(), 1);
BulletError expectedError = Aggregation.TYPE_NOT_SUPPORTED_ERROR;
Meta expectedMetadata = Meta.of(expectedError);
List<Object> expected = TupleUtils.makeTuple("42", Clip.of(expectedMetadata).asJSON(), FAILED).getValues();
List<Object> actual = collector.getNthTupleEmittedTo(TopologyConstants.RESULT_STREAM, 1).get();
Assert.assertTrue(isSameResult(actual, expected));
}
use of com.yahoo.bullet.result.Meta in project bullet-storm by yahoo.
the class JoinBoltTest method testErrorEmittedProperly.
@Test
public void testErrorEmittedProperly() {
Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "garbage", EMPTY);
bolt.execute(query);
Assert.assertEquals(collector.getEmittedCount(), 1);
String error = ParsingError.GENERIC_JSON_ERROR + ":\ngarbage\n" + "IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $";
BulletError expectedError = ParsingError.makeError(error, ParsingError.GENERIC_JSON_RESOLUTION);
Meta expectedMetadata = Meta.of(expectedError);
List<Object> expected = TupleUtils.makeTuple("42", Clip.of(expectedMetadata).asJSON(), FAILED).getValues();
List<Object> actual = collector.getNthTupleEmittedTo(TopologyConstants.RESULT_STREAM, 1).get();
Assert.assertTrue(isSameResult(actual, expected));
}
use of com.yahoo.bullet.result.Meta in project bullet-storm by yahoo.
the class JoinBoltTest method testUnhandledExceptionErrorEmitted.
@Test
public void testUnhandledExceptionErrorEmitted() {
// An empty query should throw an null-pointer exception which should be caught in JoinBolt
// and an error should be emitted
Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "", EMPTY);
bolt.execute(query);
sendRawRecordTuplesTo(bolt, "42");
Assert.assertEquals(collector.getEmittedCount(), 1);
String error = ParsingError.GENERIC_JSON_ERROR + ":\n\nNullPointerException: ";
BulletError expectedError = ParsingError.makeError(error, ParsingError.GENERIC_JSON_RESOLUTION);
Meta expectedMetadata = Meta.of(expectedError);
List<Object> expected = TupleUtils.makeTuple("42", Clip.of(expectedMetadata).asJSON(), FAILED).getValues();
List<Object> actual = collector.getNthTupleEmittedTo(TopologyConstants.RESULT_STREAM, 1).get();
Assert.assertTrue(isSameResult(actual, expected));
}
Aggregations