use of com.yahoo.bullet.common.BulletError in project bullet-core by yahoo.
the class GroupAllTest method testAttributeOperationBadFormat.
@Test
public void testAttributeOperationBadFormat() {
Aggregation aggregation = makeAggregation(singletonMap(GroupOperation.OPERATIONS, asList("foo")));
GroupAll groupAll = new GroupAll(aggregation);
Optional<List<BulletError>> optionalErrors = groupAll.initialize();
Assert.assertTrue(optionalErrors.isPresent());
List<BulletError> errors = optionalErrors.get();
Assert.assertEquals(errors.size(), 1);
Assert.assertEquals(errors.get(0), GroupOperation.REQUIRES_FIELD_OR_OPERATION_ERROR);
}
use of com.yahoo.bullet.common.BulletError 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.common.BulletError 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.common.BulletError 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