Search in sources :

Example 1 with FilterClause

use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.

the class FilterOperationsTest method testFilterDefaults.

// ***************************************** Filter Clause *********************************************************
@Test(expectedExceptions = NullPointerException.class)
public void testFilterDefaults() {
    FilterClause clause = new FilterClause();
    clause.setValues(asList("foo", "bar"));
    // Without an operation, it is an error
    FilterOperations.perform(RecordBox.get().getRecord(), clause);
}
Also used : FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 2 with FilterClause

use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.

the class FilterOperationsTest method testEquals.

@Test
public void testEquals() {
    FilterClause clause = getFieldFilter(EQUALS, "foo", "bar");
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().getRecord(), clause));
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().add("field", "baz").getRecord(), clause));
    Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("field", "foo").getRecord(), clause));
    Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("field", "bar").getRecord(), clause));
}
Also used : FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 3 with FilterClause

use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.

the class FilterOperationsTest method testComparisonBooleanMap.

@Test
public void testComparisonBooleanMap() {
    FilterClause clause = getFieldFilter("filter_map.is_fake_event", EQUALS, "true");
    // "null" is not true
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().getRecord(), clause));
    RecordBox box = RecordBox.get();
    Assert.assertFalse(FilterOperations.perform(box.getRecord(), clause));
    box.addMap("filter_map", Pair.of("is_fake_event", true));
    Assert.assertTrue(FilterOperations.perform(box.getRecord(), clause));
    box.addMap("filter_map", Pair.of("is_fake_event", false));
    Assert.assertFalse(FilterOperations.perform(box.getRecord(), clause));
}
Also used : RecordBox(com.yahoo.bullet.result.RecordBox) FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 4 with FilterClause

use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.

the class FilterOperationsTest method testNotEquals.

@Test
public void testNotEquals() {
    FilterClause clause = getFieldFilter(NOT_EQUALS, "foo", "bar", "null");
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().getRecord(), clause));
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().add("field", "foo").getRecord(), clause));
    Assert.assertFalse(FilterOperations.perform(RecordBox.get().add("field", "bar").getRecord(), clause));
    Assert.assertTrue(FilterOperations.perform(RecordBox.get().add("field", "baz").getRecord(), clause));
}
Also used : FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Example 5 with FilterClause

use of com.yahoo.bullet.parsing.FilterClause in project bullet-core by yahoo.

the class FilterOperationsTest method testComparisonUncastable.

@Test
public void testComparisonUncastable() {
    FilterClause clause = getFieldFilter("unreal", EQUALS, "1.23", "4.56");
    RecordBox box = RecordBox.get().add("unreal", 123L);
    // Trying to cast
    Assert.assertFalse(FilterOperations.perform(box.getRecord(), clause));
}
Also used : RecordBox(com.yahoo.bullet.result.RecordBox) FilterClause(com.yahoo.bullet.parsing.FilterClause) Test(org.testng.annotations.Test)

Aggregations

FilterClause (com.yahoo.bullet.parsing.FilterClause)18 Test (org.testng.annotations.Test)17 RecordBox (com.yahoo.bullet.result.RecordBox)3 Utilities.extractTypedObject (com.yahoo.bullet.common.Utilities.extractTypedObject)1 Clause (com.yahoo.bullet.parsing.Clause)1 LogicalClause (com.yahoo.bullet.parsing.LogicalClause)1 TypedObject (com.yahoo.bullet.typesystem.TypedObject)1