use of com.yahoo.bullet.typesystem.TypedObject in project bullet-core by yahoo.
the class FilterOperationsTest method testNulls.
@Test
public void testNulls() {
TypedObject object = new TypedObject(Type.NULL, null);
Assert.assertFalse(comparatorFor(EQUALS).compare(object, make(object, "foo")));
Assert.assertTrue(comparatorFor(EQUALS).compare(object, make(object, "null")));
Assert.assertTrue(comparatorFor(EQUALS).compare(object, make(object, "NULL")));
Assert.assertTrue(comparatorFor(EQUALS).compare(object, make(object, "Null")));
Assert.assertTrue(comparatorFor(NOT_EQUALS).compare(object, make(object, "foo")));
Assert.assertFalse(comparatorFor(NOT_EQUALS).compare(object, make(object, "null")));
Assert.assertFalse(comparatorFor(NOT_EQUALS).compare(object, make(object, "NULL")));
Assert.assertFalse(comparatorFor(NOT_EQUALS).compare(object, make(object, "Null")));
Assert.assertFalse(comparatorFor(GREATER_THAN).compare(object, make(object, "foo")));
Assert.assertFalse(comparatorFor(LESS_THAN).compare(object, make(object, "foo")));
Assert.assertFalse(comparatorFor(GREATER_EQUALS).compare(object, make(object, "foo")));
Assert.assertFalse(comparatorFor(LESS_EQUALS).compare(object, make(object, "foo")));
Assert.assertFalse(FilterOperations.REGEX_LIKE.compare(object, makePattern("foo")));
Assert.assertFalse(FilterOperations.REGEX_LIKE.compare(object, makePattern("null")));
Assert.assertFalse(FilterOperations.REGEX_LIKE.compare(object, makePattern("nu.*")));
}
use of com.yahoo.bullet.typesystem.TypedObject in project bullet-core by yahoo.
the class FilterOperationsTest method testComparatorUnsupportedType.
@Test
public void testComparatorUnsupportedType() {
TypedObject object = new TypedObject(Type.MAP, singletonMap("foo", "bar"));
// foo cannot be casted to map, so eq will return false (values will be empty)
Assert.assertFalse(comparatorFor(EQUALS).compare(object, make(object, "foo")));
// foo cannot be casted to map, so neq will return true (values will be empty)
Assert.assertTrue(comparatorFor(NOT_EQUALS).compare(object, make(object, "foo")));
Assert.assertFalse(comparatorFor(GREATER_THAN).compare(object, make(object, "foo")));
Assert.assertFalse(comparatorFor(GREATER_EQUALS).compare(object, make(object, "foo")));
Assert.assertFalse(comparatorFor(LESS_THAN).compare(object, make(object, "foo")));
Assert.assertFalse(comparatorFor(LESS_EQUALS).compare(object, make(object, "foo")));
Assert.assertFalse(FilterOperations.REGEX_LIKE.compare(object, makePattern("foo")));
}
use of com.yahoo.bullet.typesystem.TypedObject in project bullet-core by yahoo.
the class FilterOperationsTest method testComparatorUncastable.
@Test
public void testComparatorUncastable() {
TypedObject object = new TypedObject(Double.valueOf("1.234"));
Assert.assertFalse(comparatorFor(EQUALS).compare(object, make(object, "foo")));
}
use of com.yahoo.bullet.typesystem.TypedObject in project bullet-core by yahoo.
the class FilterOperationsTest method testMixedTypes.
@Test
public void testMixedTypes() {
TypedObject object = new TypedObject(2.34);
Assert.assertTrue(comparatorFor(EQUALS).compare(object, make(object, "foo", "2.34")));
Assert.assertFalse(comparatorFor(EQUALS).compare(object, make(object, "foo", "3.42")));
Assert.assertTrue(comparatorFor(NOT_EQUALS).compare(object, make(object, "baz", "bar")));
Assert.assertFalse(comparatorFor(NOT_EQUALS).compare(object, make(object, "baz", "2.34")));
Assert.assertTrue(comparatorFor(GREATER_THAN).compare(object, make(object, "baz", "2.1")));
Assert.assertFalse(comparatorFor(GREATER_THAN).compare(object, make(object, "baz", "2.34")));
Assert.assertFalse(comparatorFor(GREATER_THAN).compare(object, make(object, "baz", "2.4")));
Assert.assertFalse(comparatorFor(LESS_THAN).compare(object, make(object, "baz", "2.1")));
Assert.assertFalse(comparatorFor(LESS_THAN).compare(object, make(object, "baz", "2.34")));
Assert.assertTrue(comparatorFor(LESS_THAN).compare(object, make(object, "baz", "2.4")));
Assert.assertTrue(comparatorFor(GREATER_EQUALS).compare(object, make(object, "baz", "2.1")));
Assert.assertTrue(comparatorFor(GREATER_EQUALS).compare(object, make(object, "baz", "2.34")));
Assert.assertFalse(comparatorFor(GREATER_EQUALS).compare(object, make(object, "baz", "2.4")));
Assert.assertFalse(comparatorFor(LESS_EQUALS).compare(object, make(object, "baz", "2.1")));
Assert.assertTrue(comparatorFor(LESS_EQUALS).compare(object, make(object, "baz", "2.34")));
Assert.assertTrue(comparatorFor(LESS_EQUALS).compare(object, make(object, "baz", "2.4")));
}
use of com.yahoo.bullet.typesystem.TypedObject in project bullet-core by yahoo.
the class FilterOperationsTest method testInEquality.
@Test
public void testInEquality() {
TypedObject object = new TypedObject(1L);
Assert.assertFalse(comparatorFor(NOT_EQUALS).compare(object, make(object, "1", "2")));
Assert.assertTrue(comparatorFor(NOT_EQUALS).compare(object, make(object, "2", "3")));
// Will become a string
object = new TypedObject(singletonList("1"));
Assert.assertTrue(comparatorFor(NOT_EQUALS).compare(object, make(object, "1", "2")));
// Can't be casted to a list, so the inequality check will pass
object = new TypedObject(Type.LIST, singletonList("foo"));
Assert.assertTrue(comparatorFor(NOT_EQUALS).compare(object, make(object, "foo", "bar")));
}
Aggregations