Search in sources :

Example 6 with TypedObject

use of com.yahoo.bullet.typesystem.TypedObject in project bullet-core by yahoo.

the class FilterOperationsTest method testLessNumeric.

@Test
public void testLessNumeric() {
    TypedObject object = new TypedObject(1L);
    Assert.assertTrue(comparatorFor(LESS_THAN).compare(object, make(object, "-10", "2")));
    Assert.assertFalse(comparatorFor(LESS_THAN).compare(object, make(object, "-1", "0")));
    Assert.assertTrue(comparatorFor(LESS_EQUALS).compare(object, make(object, "0", "1")));
    Assert.assertFalse(comparatorFor(LESS_EQUALS).compare(object, make(object, "-2", "-3")));
    // Will become a string
    object = new TypedObject(singletonList("1"));
    Assert.assertFalse(comparatorFor(LESS_THAN).compare(object, make(object, "1", "2")));
    Assert.assertFalse(comparatorFor(LESS_EQUALS).compare(object, make(object, "1", "2")));
    // Can't be casted to a list, so the less check will fail
    object = new TypedObject(Type.LIST, singletonList("1"));
    Assert.assertFalse(comparatorFor(LESS_THAN).compare(object, make(object, "1", "2")));
    Assert.assertFalse(comparatorFor(LESS_EQUALS).compare(object, make(object, "1", "2")));
}
Also used : TypedObject(com.yahoo.bullet.typesystem.TypedObject) Test(org.testng.annotations.Test)

Example 7 with TypedObject

use of com.yahoo.bullet.typesystem.TypedObject in project bullet-core by yahoo.

the class FilterOperationsTest method testGreaterNumeric.

@Test
public void testGreaterNumeric() {
    TypedObject object = new TypedObject(1L);
    Assert.assertTrue(comparatorFor(GREATER_THAN).compare(object, make(object, "0", "2")));
    Assert.assertFalse(comparatorFor(GREATER_THAN).compare(object, make(object, "1", "2")));
    Assert.assertTrue(comparatorFor(GREATER_EQUALS).compare(object, make(object, "0", "3")));
    Assert.assertFalse(comparatorFor(GREATER_EQUALS).compare(object, make(object, "2", "3")));
    // Will become UNKNOWN
    object = new TypedObject(singletonList("1"));
    Assert.assertFalse(comparatorFor(GREATER_THAN).compare(object, make(object, "1", "2")));
    Assert.assertFalse(comparatorFor(GREATER_EQUALS).compare(object, make(object, "1", "2")));
    // Will become UNKNOWN
    object = new TypedObject(Type.LIST, singletonList("1"));
    Assert.assertFalse(comparatorFor(GREATER_THAN).compare(object, make(object, "1", "2")));
    Assert.assertFalse(comparatorFor(GREATER_EQUALS).compare(object, make(object, "1", "2")));
}
Also used : TypedObject(com.yahoo.bullet.typesystem.TypedObject) Test(org.testng.annotations.Test)

Example 8 with TypedObject

use of com.yahoo.bullet.typesystem.TypedObject in project bullet-core by yahoo.

the class FilterOperationsTest method testLessString.

@Test
public void testLessString() {
    TypedObject object = new TypedObject("foo");
    Assert.assertFalse(comparatorFor(LESS_THAN).compare(object, make(object, "bravo", "2")));
    Assert.assertTrue(comparatorFor(LESS_THAN).compare(object, make(object, "zulu", "xray")));
    Assert.assertTrue(comparatorFor(LESS_EQUALS).compare(object, make(object, "oscar", "foo")));
    Assert.assertFalse(comparatorFor(LESS_EQUALS).compare(object, make(object, "echo", "fi")));
}
Also used : TypedObject(com.yahoo.bullet.typesystem.TypedObject) Test(org.testng.annotations.Test)

Example 9 with TypedObject

use of com.yahoo.bullet.typesystem.TypedObject in project bullet-core by yahoo.

the class FilterOperationsTest method testGreaterString.

@Test
public void testGreaterString() {
    TypedObject object = new TypedObject("foo");
    Assert.assertTrue(comparatorFor(GREATER_THAN).compare(object, make(object, "bravo", "2")));
    Assert.assertFalse(comparatorFor(GREATER_THAN).compare(object, make(object, "zulu", "xray")));
    Assert.assertTrue(comparatorFor(GREATER_EQUALS).compare(object, make(object, "alpha", "foo")));
    Assert.assertFalse(comparatorFor(GREATER_EQUALS).compare(object, make(object, "golf", "november")));
}
Also used : TypedObject(com.yahoo.bullet.typesystem.TypedObject) Test(org.testng.annotations.Test)

Example 10 with TypedObject

use of com.yahoo.bullet.typesystem.TypedObject in project bullet-core by yahoo.

the class FilterOperationsTest method testOnDoubles.

@Test
public void testOnDoubles() {
    TypedObject object = new TypedObject(Double.valueOf("1.234"));
    Assert.assertTrue(comparatorFor(EQUALS).compare(object, make(object, "1.234", "4.343", "foo")));
    Assert.assertFalse(comparatorFor(EQUALS).compare(object, make(object, "4.343")));
}
Also used : TypedObject(com.yahoo.bullet.typesystem.TypedObject) Test(org.testng.annotations.Test)

Aggregations

TypedObject (com.yahoo.bullet.typesystem.TypedObject)13 Test (org.testng.annotations.Test)11 Utilities.extractTypedObject (com.yahoo.bullet.common.Utilities.extractTypedObject)1 Clause (com.yahoo.bullet.parsing.Clause)1 FilterClause (com.yahoo.bullet.parsing.FilterClause)1 LogicalClause (com.yahoo.bullet.parsing.LogicalClause)1