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")));
}
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")));
}
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")));
}
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")));
}
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")));
}
Aggregations