Search in sources :

Example 1 with PostfixPredicate

use of com.yahoo.elide.core.filter.predicates.PostfixPredicate 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));
}
Also used : InfixPredicate(com.yahoo.elide.core.filter.predicates.InfixPredicate) PostfixPredicate(com.yahoo.elide.core.filter.predicates.PostfixPredicate) PrefixPredicate(com.yahoo.elide.core.filter.predicates.PrefixPredicate) PostfixInsensitivePredicate(com.yahoo.elide.core.filter.predicates.PostfixInsensitivePredicate) PrefixInsensitivePredicate(com.yahoo.elide.core.filter.predicates.PrefixInsensitivePredicate) Author(example.Author) InfixInsensitivePredicate(com.yahoo.elide.core.filter.predicates.InfixInsensitivePredicate) Test(org.junit.jupiter.api.Test)

Aggregations

InfixInsensitivePredicate (com.yahoo.elide.core.filter.predicates.InfixInsensitivePredicate)1 InfixPredicate (com.yahoo.elide.core.filter.predicates.InfixPredicate)1 PostfixInsensitivePredicate (com.yahoo.elide.core.filter.predicates.PostfixInsensitivePredicate)1 PostfixPredicate (com.yahoo.elide.core.filter.predicates.PostfixPredicate)1 PrefixInsensitivePredicate (com.yahoo.elide.core.filter.predicates.PrefixInsensitivePredicate)1 PrefixPredicate (com.yahoo.elide.core.filter.predicates.PrefixPredicate)1 Author (example.Author)1 Test (org.junit.jupiter.api.Test)1