use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class RateLimitErrorTest method testMetaAndRateConversion.
@Test
public void testMetaAndRateConversion() {
BulletConfig config = new BulletConfig();
RateLimitError error = new RateLimitError(19.34, config);
Map<String, Object> actual = error.makeMeta().asMap();
Assert.assertTrue(actual.containsKey(Meta.ERROR_KEY));
Assert.assertTrue(((List<BulletError>) actual.get(Meta.ERROR_KEY)).get(0) == error);
String asJSON = error.asJSON();
double defaultRate = (DEFAULT_RATE_LIMIT_MAX_EMIT_COUNT / DEFAULT_RATE_LIMIT_TIME_INTERVAL) * RateLimiter.SECOND;
double actualRate = 19.34 * RateLimiter.SECOND;
assertJSONEquals(asJSON, "{'error': '" + String.format(RateLimitError.ERROR_FORMAT, defaultRate, actualRate) + "', " + "'resolutions': ['" + RateLimitError.NARROW_FILTER + "', '" + RateLimitError.TIME_WINDOW + "']" + "}");
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class RunningQueryTest method testStartTime.
@Test
public void testStartTime() {
long start = System.currentTimeMillis();
BulletConfig config = new BulletConfig();
RunningQuery runningQuery = new RunningQuery("foo", "{}", config);
Assert.assertFalse(runningQuery.initialize().isPresent());
long end = System.currentTimeMillis();
Assert.assertTrue(runningQuery.getStartTime() >= start);
Assert.assertTrue(runningQuery.getStartTime() <= end);
Assert.assertFalse(runningQuery.isTimedOut());
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class WindowingOperationsTest method testTumblingWindow.
@Test
public void testTumblingWindow() {
BulletConfig config = new BulletConfig();
Query query = new Query();
Window window = WindowUtils.makeTumblingWindow(1000);
window.configure(config);
query.setWindow(window);
Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), Tumbling.class);
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class WindowingOperationsTest method testNoWindow.
@Test
public void testNoWindow() {
BulletConfig config = new BulletConfig();
Query query = new Query();
Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), Basic.class);
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class WindowingOperationsTest method testNotForcingRawToReactive.
@Test
public void testNotForcingRawToReactive() {
BulletConfig config = new BulletConfig();
Query query = new Query();
Window window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.ALL, null);
window.configure(config);
query.setWindow(window);
Aggregation aggregation = new Aggregation();
aggregation.setType(Aggregation.Type.RAW);
query.setAggregation(aggregation);
Assert.assertEquals(WindowingOperations.findScheme(query, null, config).getClass(), AdditiveTumbling.class);
}
Aggregations