use of com.yahoo.elide.core.filter.predicates.LEPredicate 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 com.yahoo.elide.core.filter.predicates.LEPredicate 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));
}
use of com.yahoo.elide.core.filter.predicates.LEPredicate in project elide by yahoo.
the class AsyncAPICleanerRunnable method deleteAsyncAPI.
/**
* This method deletes the historical queries based on threshold.
* @param type AsyncAPI Type Implementation.
*/
protected <T extends AsyncAPI> void deleteAsyncAPI(Class<T> type) {
try {
Date cleanupDate = dateUtil.calculateFilterDate(Calendar.DATE, queryCleanupDays);
PathElement createdOnPathElement = new PathElement(type, Long.class, "createdOn");
FilterExpression fltDeleteExp = new LEPredicate(createdOnPathElement, cleanupDate);
asyncAPIDao.deleteAsyncAPIAndResultByFilter(fltDeleteExp, type);
} catch (Exception e) {
log.error("Exception in scheduled cleanup: {}", e.toString());
}
}
use of com.yahoo.elide.core.filter.predicates.LEPredicate in project elide by yahoo.
the class AsyncAPICleanerRunnable method timeoutAsyncAPI.
/**
* This method updates the status of long running async query which
* were interrupted due to host crash/app shutdown to TIMEDOUT.
* @param type AsyncAPI Type Implementation.
*/
protected <T extends AsyncAPI> void timeoutAsyncAPI(Class<T> type) {
try {
Date filterDate = dateUtil.calculateFilterDate(Calendar.MINUTE, maxRunTimeMinutes);
PathElement createdOnPathElement = new PathElement(type, Long.class, "createdOn");
PathElement statusPathElement = new PathElement(type, String.class, "status");
FilterPredicate inPredicate = new InPredicate(statusPathElement, QueryStatus.PROCESSING, QueryStatus.QUEUED);
FilterPredicate lePredicate = new LEPredicate(createdOnPathElement, filterDate);
AndFilterExpression fltTimeoutExp = new AndFilterExpression(inPredicate, lePredicate);
asyncAPIDao.updateStatusAsyncAPIByFilter(fltTimeoutExp, QueryStatus.TIMEDOUT, type);
} catch (Exception e) {
log.error("Exception in scheduled cleanup: {}", e.toString());
}
}
Aggregations