Search in sources :

Example 1 with IsEmptyPredicate

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));
}
Also used : IsEmptyPredicate(com.yahoo.elide.core.filter.predicates.IsEmptyPredicate) Book(example.Book) Author(example.Author) NotEmptyPredicate(com.yahoo.elide.core.filter.predicates.NotEmptyPredicate) Test(org.junit.jupiter.api.Test)

Aggregations

IsEmptyPredicate (com.yahoo.elide.core.filter.predicates.IsEmptyPredicate)1 NotEmptyPredicate (com.yahoo.elide.core.filter.predicates.NotEmptyPredicate)1 Author (example.Author)1 Book (example.Book)1 Test (org.junit.jupiter.api.Test)1