use of com.yahoo.elide.core.filter.predicates.InfixPredicate in project elide by yahoo.
the class InMemoryFilterExecutorTest method prefixAndPostfixAndInfixPredicateTest.
@Test
public void prefixAndPostfixAndInfixPredicateTest() throws Exception {
author = new Author();
author.setId(1L);
author.setName("AuthorForTest");
// When prefix, infix, postfix are correctly matched
expression = new PrefixPredicate(authorNameElement, "Author");
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new InfixPredicate(authorNameElement, "For");
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new PostfixPredicate(authorNameElement, "Test");
fn = expression.accept(visitor);
assertTrue(fn.test(author));
// When prefix, infix, postfix are correctly matched if case-insensitive
expression = new PrefixPredicate(authorNameElement, "author");
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new InfixPredicate(authorNameElement, "for");
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new PostfixPredicate(authorNameElement, "test");
fn = expression.accept(visitor);
assertFalse(fn.test(author));
// When prefix, infix, postfix are correctly matched if case-insensitive
expression = new PrefixInsensitivePredicate(authorNameElement, "author");
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new InfixInsensitivePredicate(authorNameElement, "for");
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new PostfixInsensitivePredicate(authorNameElement, "test");
fn = expression.accept(visitor);
assertTrue(fn.test(author));
// When prefix, infix, postfix are not matched
expression = new PrefixPredicate(authorNameElement, "error");
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new InfixPredicate(authorNameElement, "error");
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new PostfixPredicate(authorNameElement, "error");
fn = expression.accept(visitor);
assertFalse(fn.test(author));
// When values is null
author.setName(null);
expression = new PrefixPredicate(authorNameElement, "Author");
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new InfixPredicate(authorNameElement, "For");
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new PostfixPredicate(authorNameElement, "Test");
fn = expression.accept(visitor);
assertFalse(fn.test(author));
}
use of com.yahoo.elide.core.filter.predicates.InfixPredicate in project elide by yahoo.
the class AbstractHQLQueryBuilderTest method testSettingQueryParams.
@Test
public void testSettingQueryParams() {
Path.PathElement idPath = new Path.PathElement(Book.class, Chapter.class, "id");
Query query = mock(Query.class);
FilterPredicate predicate = new InPredicate(idPath, ABC, DEF);
supplyFilterQueryParameters(query, Arrays.asList(predicate));
verify(query, times(2)).setParameter(anyString(), any());
query = mock(Query.class);
predicate = new InfixPredicate(idPath, ABC);
supplyFilterQueryParameters(query, Arrays.asList(predicate));
verify(query, times(1)).setParameter(anyString(), any());
}
Aggregations