use of com.github.tfaga.lynx.beans.QueryFilter in project lynx by TFaga.
the class JPAUtilsCriteriaFilterTest method testQueryCriteriaFilterWithParamsAnd.
@Test
public void testQueryCriteriaFilterWithParamsAnd() {
QueryFilter qf = new QueryFilter();
qf.setField("lastname");
qf.setOperation(FilterOperation.EQ);
qf.setValue("Turner");
QueryParameters q = new QueryParameters();
q.getFilters().add(qf);
List<User> users = JPAUtils.queryEntities(em, User.class, q, (p, cb, r) -> cb.and(p, cb.equal(r.get("firstname"), "Antonio")));
Assert.assertNotNull(users);
Assert.assertEquals(1, users.size());
Assert.assertNotNull(users.get(0));
Assert.assertEquals("Antonio", users.get(0).getFirstname());
Assert.assertEquals("Turner", users.get(0).getLastname());
Long usersCount = JPAUtils.queryEntitiesCount(em, User.class, q, (p, cb, r) -> cb.and(p, cb.equal(r.get("firstname"), "Antonio")));
Assert.assertNotNull(usersCount);
Assert.assertEquals(1, usersCount.longValue());
}
use of com.github.tfaga.lynx.beans.QueryFilter in project lynx by TFaga.
the class JPAUtilsFiltersTest method testNotEqual.
@Test
public void testNotEqual() {
QueryFilter qf = new QueryFilter();
qf.setField("lastname");
qf.setOperation(FilterOperation.NEQ);
qf.setValue("Willis");
QueryParameters q = new QueryParameters();
q.getFilters().add(qf);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(97, users.size());
}
use of com.github.tfaga.lynx.beans.QueryFilter in project lynx by TFaga.
the class JPAUtilsFiltersTest method testSingleDateFilter.
@Test
public void testSingleDateFilter() {
Date d = Date.from(ZonedDateTime.parse("2014-11-26T11:15:08Z").toInstant());
QueryFilter qf = new QueryFilter();
qf.setField("createdAt");
qf.setOperation(FilterOperation.GT);
qf.setDateValue(d);
QueryParameters q = new QueryParameters();
q.getFilters().add(qf);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(39, users.size());
}
use of com.github.tfaga.lynx.beans.QueryFilter in project lynx by TFaga.
the class JPAUtilsFiltersTest method testLikeic.
@Test
public void testLikeic() {
QueryFilter qf = new QueryFilter();
qf.setField("firstname");
qf.setOperation(FilterOperation.LIKEIC);
qf.setValue("jA%");
QueryParameters q = new QueryParameters();
q.getFilters().add(qf);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(5, users.size());
}
use of com.github.tfaga.lynx.beans.QueryFilter in project lynx by TFaga.
the class JPAUtilsFiltersTest method testIsNotNullFilter.
@Test
public void testIsNotNullFilter() {
QueryFilter qf = new QueryFilter();
qf.setField("description");
qf.setOperation(FilterOperation.ISNOTNULL);
qf.setValue("");
QueryParameters q = new QueryParameters();
q.getFilters().add(qf);
List<Project> projects = JPAUtils.queryEntities(em, Project.class, q);
Assert.assertNotNull(projects);
Assert.assertEquals(99, projects.size());
}
Aggregations