use of example.Author in project elide by yahoo.
the class InMemoryFilterExecutorTest method andExpressionTest.
@Test
public void andExpressionTest() throws Exception {
author = new Author();
author.setId(1L);
author.setName("AuthorForTest");
expression = new AndFilterExpression(new InPredicate(authorIdElement, 1L), new InPredicate(authorNameElement, "AuthorForTest"));
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new AndFilterExpression(new InPredicate(authorIdElement, 0L), new InPredicate(authorNameElement, "AuthorForTest"));
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new AndFilterExpression(new InPredicate(authorIdElement, 1L), new InPredicate(authorNameElement, "Fail"));
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new AndFilterExpression(new InPredicate(authorIdElement, 0L), new InPredicate(authorNameElement, "Fail"));
fn = expression.accept(visitor);
assertFalse(fn.test(author));
}
use of example.Author in project elide by yahoo.
the class InMemoryFilterExecutorTest method isnullAndNotnullPredicateTest.
@Test
public void isnullAndNotnullPredicateTest() throws Exception {
author = new Author();
author.setId(1L);
author.setName("AuthorForTest");
// When name is not null
expression = new IsNullPredicate(authorNameElement);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new NotNullPredicate(authorNameElement);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
// When name is null
author.setName(null);
expression = new IsNullPredicate(authorNameElement);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new NotNullPredicate(authorNameElement);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
}
use of example.Author 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));
}
use of example.Author in project elide by yahoo.
the class InMemoryFilterExecutorTest method negativeTests.
@Test
public void negativeTests() throws Exception {
author = new Author();
author.setId(10L);
PathElement pathElement = new PathElement(Author.class, Long.class, "id");
expression = new NotFilterExpression(new LTPredicate(pathElement, listEleven));
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new NotFilterExpression(new LEPredicate(pathElement, listTen));
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new NotFilterExpression(new GTPredicate(pathElement, listNine));
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new NotFilterExpression(new GEPredicate(pathElement, listTen));
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new NotFilterExpression(new LTPredicate(pathElement, listTen));
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new NotFilterExpression(new LEPredicate(pathElement, listNine));
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new NotFilterExpression(new GTPredicate(pathElement, listTen));
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new NotFilterExpression(new GEPredicate(pathElement, listEleven));
fn = expression.accept(visitor);
assertTrue(fn.test(author));
}
use of example.Author in project elide by yahoo.
the class InMemoryFilterExecutorTest method compareOpPredicateTests.
@Test
public void compareOpPredicateTests() throws Exception {
author = new Author();
author.setId(10L);
expression = new LTPredicate(authorIdElement, listEleven);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new LEPredicate(authorIdElement, listTen);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new GTPredicate(authorIdElement, listNine);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new GEPredicate(authorIdElement, listTen);
fn = expression.accept(visitor);
assertTrue(fn.test(author));
expression = new LTPredicate(authorIdElement, listTen);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new LEPredicate(authorIdElement, listNine);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new GTPredicate(authorIdElement, listTen);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new GEPredicate(authorIdElement, listEleven);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
// when val is null
author.setId(null);
expression = new LTPredicate(authorIdElement, listTen);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new LEPredicate(authorIdElement, listTen);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new GTPredicate(authorIdElement, listTen);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
expression = new GEPredicate(authorIdElement, listTen);
fn = expression.accept(visitor);
assertFalse(fn.test(author));
}
Aggregations