use of com.yahoo.elide.core.filter.predicates.IsEmptyPredicate in project elide by yahoo.
the class InMemoryFilterExecutorTest method isemptyAndNotemptyPredicateTest.
@Test
public void isemptyAndNotemptyPredicateTest() throws Exception {
author = new Author();
author.setId(1L);
// When name is empty and books are empty
author.setBooks(new HashSet<>());
author.setAwards(new HashSet<>());
expression = new IsEmptyPredicate(authorAwardsElement);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new IsEmptyPredicate(authorBooksElement);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new NotEmptyPredicate(authorAwardsElement);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new NotEmptyPredicate(authorBooksElement);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
// When name and books are not empty
author.setAwards(Arrays.asList("Bookery prize"));
author.getBooks().add(new Book());
expression = new IsEmptyPredicate(authorAwardsElement);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new IsEmptyPredicate(authorBooksElement);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new NotEmptyPredicate(authorAwardsElement);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new NotEmptyPredicate(authorBooksElement);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
}
Aggregations