use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class FilterClauseTest method testConfigureForPatterns.
@Test
public void testConfigureForPatterns() {
FilterClause filterClause = new FilterClause();
filterClause.setOperation(Clause.Operation.REGEX_LIKE);
filterClause.setValues(singletonList(".g.*"));
Assert.assertNull(filterClause.getPatterns());
filterClause.configure(new BulletConfig());
Assert.assertFalse(filterClause.initialize().isPresent());
List<Pattern> actual = filterClause.getPatterns();
Assert.assertNotNull(actual);
Assert.assertEquals(actual.size(), 1);
Assert.assertEquals(actual.get(0).pattern(), ".g.*");
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class FilterClauseTest method testConfigureForBadPatterns.
@Test
public void testConfigureForBadPatterns() {
FilterClause filterClause = new FilterClause();
filterClause.setOperation(Clause.Operation.REGEX_LIKE);
filterClause.setValues(singletonList("*TEST*"));
Assert.assertNull(filterClause.getPatterns());
filterClause.configure(new BulletConfig());
Assert.assertFalse(filterClause.initialize().isPresent());
Assert.assertNotNull(filterClause.getPatterns());
Assert.assertTrue(filterClause.getPatterns().isEmpty());
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class FilterUtils method makeClause.
public static Clause makeClause(String field, List<String> values, Clause.Operation operation) {
FilterClause clause = new FilterClause();
clause.setField(field);
clause.setValues(values == null ? Collections.singletonList(Type.NULL_EXPRESSION) : values);
clause.setOperation(operation);
clause.configure(new BulletConfig());
clause.initialize();
return clause;
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class QueryTest method testDefaults.
@Test
public void testDefaults() {
Query query = new Query();
BulletConfig config = new BulletConfig();
query.configure(config);
Assert.assertNull(query.getProjection());
Assert.assertNull(query.getFilters());
Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_DURATION);
Assert.assertEquals(query.getAggregation().getType(), Aggregation.Type.RAW);
Assert.assertEquals((Object) query.getAggregation().getSize(), BulletConfig.DEFAULT_AGGREGATION_SIZE);
}
use of com.yahoo.bullet.common.BulletConfig in project bullet-core by yahoo.
the class QueryTest method testDuration.
@Test
public void testDuration() {
BulletConfig config = new BulletConfig();
Query query = new Query();
query.configure(config);
Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_DURATION);
query.setDuration(-1000L);
query.configure(config);
Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_DURATION);
query.setDuration(0L);
query.configure(config);
Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_DURATION);
query.setDuration(1L);
query.configure(config);
Assert.assertEquals(query.getDuration(), (Long) 1L);
query.setDuration(BulletConfig.DEFAULT_QUERY_DURATION);
query.configure(config);
Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_DURATION);
query.setDuration(BulletConfig.DEFAULT_QUERY_MAX_DURATION);
query.configure(config);
Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_MAX_DURATION);
// Overflow
query.setDuration(BulletConfig.DEFAULT_QUERY_MAX_DURATION * 2);
query.configure(config);
Assert.assertEquals((Object) query.getDuration(), BulletConfig.DEFAULT_QUERY_MAX_DURATION);
}
Aggregations