use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class QueryTest method testInitializeNullValues.
@Test
public void testInitializeNullValues() {
Query query = new Query();
query.setProjection(null);
query.setFilters(null);
query.setAggregation(null);
query.configure(new BulletConfig());
Optional<List<BulletError>> errorList = query.initialize();
Assert.assertFalse(errorList.isPresent());
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class QueryTest method testWindowForced.
@Test
public void testWindowForced() {
BulletConfig config = new BulletConfig();
Query query = new Query();
query.setWindow(WindowUtils.makeReactiveWindow());
query.configure(config);
Assert.assertNotNull(query.getWindow());
config.set(BulletConfig.WINDOW_DISABLE, true);
config.validate();
query.setWindow(WindowUtils.makeReactiveWindow());
query.configure(config);
Assert.assertNull(query.getWindow());
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class QueryTest method testAggregationForced.
@Test
public void testAggregationForced() {
Query query = new Query();
query.setAggregation(null);
Assert.assertNull(query.getProjection());
Assert.assertNull(query.getFilters());
// If you had null for aggregation
Assert.assertNull(query.getAggregation());
query.configure(new BulletConfig());
Assert.assertNotNull(query.getAggregation());
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class WindowTest method testErrorsInInitialization.
@Test
public void testErrorsInInitialization() {
BulletConfig config = new BulletConfig();
Window window;
Optional<List<BulletError>> errors;
window = new Window();
window.configure(config);
errors = window.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_EMIT));
window = WindowUtils.makeWindow(Window.Unit.ALL, 10);
window.configure(config);
errors = window.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_EMIT));
window = WindowUtils.makeWindow(Window.Unit.TIME, null);
window.configure(config);
errors = window.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_EVERY));
window = WindowUtils.makeWindow(Window.Unit.RECORD, -1);
window.configure(config);
errors = window.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_EVERY));
window = WindowUtils.makeWindow(Window.Unit.RECORD, 0);
window.configure(config);
errors = window.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_EVERY));
window = WindowUtils.makeWindow(Window.Unit.RECORD, 2);
window.configure(config);
errors = window.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Window.NOT_ONE_RECORD_EMIT));
window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.ALL, null);
window.getInclude().put(Window.INCLUDE_FIRST_FIELD, 1000);
window.configure(config);
errors = window.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_FIRST));
window = WindowUtils.makeWindow(Window.Unit.RECORD, 1, Window.Unit.ALL, null);
window.getInclude().put(Window.INCLUDE_FIRST_FIELD, 10);
window.configure(config);
errors = window.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Window.NO_RECORD_ALL));
window = WindowUtils.makeWindow(Window.Unit.TIME, 1, Window.Unit.ALL, null);
window.getInclude().put(Window.INCLUDE_FIRST_FIELD, 10);
window.configure(config);
errors = window.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_FIRST));
window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.TIME, null);
window.configure(config);
errors = window.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_INCLUDE));
window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.TIME, 2000);
window.configure(config);
errors = window.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_INCLUDE));
window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.RECORD, 5);
window.configure(config);
errors = window.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_INCLUDE));
window = WindowUtils.makeWindow(Window.Unit.RECORD, 1, Window.Unit.RECORD, 5);
window.configure(config);
errors = window.initialize();
Assert.assertTrue(errors.isPresent());
Assert.assertEquals(errors.get(), singletonList(Window.IMPROPER_INCLUDE));
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class WindowTest method testProperInitialization.
@Test
public void testProperInitialization() {
BulletConfig config = new BulletConfig();
Window window;
Optional<List<BulletError>> errors;
window = WindowUtils.makeTumblingWindow(2000);
window.configure(config);
Assert.assertFalse(window.initialize().isPresent());
window = WindowUtils.makeWindow(Window.Unit.TIME, 2000);
window.configure(config);
Assert.assertFalse(window.initialize().isPresent());
window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.TIME, 1000);
window.configure(config);
errors = window.initialize();
Assert.assertFalse(errors.isPresent());
window = WindowUtils.makeReactiveWindow();
window.configure(config);
Assert.assertFalse(window.initialize().isPresent());
window = WindowUtils.makeWindow(Window.Unit.RECORD, 1, Window.Unit.RECORD, 1);
window.configure(config);
errors = window.initialize();
Assert.assertFalse(errors.isPresent());
window = WindowUtils.makeWindow(Window.Unit.TIME, 1000, Window.Unit.ALL, null);
window.configure(config);
errors = window.initialize();
Assert.assertFalse(errors.isPresent());
}
Aggregations