use of com.yahoo.elide.core.filter.predicates.InInsensitivePredicate in project elide by yahoo.
the class InMemoryFilterExecutorTest method inAndNotInPredicateTest.
@Test
public void inAndNotInPredicateTest() throws Exception {
author = new Author();
author.setId(1L);
author.setName("AuthorForTest");
// Test exact match
expression = new InPredicate(authorIdElement, 1L);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new NotInPredicate(authorIdElement, 1L);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
// Test exact match insensitive
expression = new InInsensitivePredicate(authorNameElement, author.getName().toUpperCase(Locale.ENGLISH));
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new NotInInsensitivePredicate(authorNameElement, author.getName().toUpperCase(Locale.ENGLISH));
fn = expression.accept(visitor);
assertFalse(fn.test(author));
// Test contains works
expression = new InPredicate(authorIdElement, 1, 2);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new NotInPredicate(authorIdElement, 1, 2);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
// Test type
expression = new InPredicate(authorIdElement, "1");
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new NotInPredicate(authorIdElement, "1");
fn = expression.accept(visitor);
assertFalse(fn.test(author));
// Test not in
expression = new InPredicate(authorIdElement, 3L);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new NotInPredicate(authorIdElement, 3L);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
// Test empty
expression = new InPredicate(authorIdElement, Collections.emptyList());
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new NotInPredicate(authorIdElement, Collections.emptyList());
fn = expression.accept(visitor);
assertTrue(fn.test(author));
// Test TRUE/FALSE
expression = new TruePredicate(authorIdElement);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new FalsePredicate(authorIdElement);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
// Test null
author.setId(null);
expression = new InPredicate(authorIdElement, 1);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new NotInPredicate(authorIdElement, 1);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
}
Aggregations