use of com.github.tfaga.lynx.beans.QueryFilter in project lynx by TFaga.
the class JPAUtilsFiltersTest method testNullField.
@Test
public void testNullField() {
QueryFilter qf = new QueryFilter();
qf.setOperation(FilterOperation.NEQ);
qf.setValue("test");
QueryParameters q = new QueryParameters();
q.getFilters().add(qf);
try {
JPAUtils.queryEntities(em, User.class, q);
Assert.fail("No exception was thrown");
} catch (NoSuchEntityFieldException e) {
Assert.assertEquals(null, e.getField());
}
}
use of com.github.tfaga.lynx.beans.QueryFilter in project lynx by TFaga.
the class JPAUtilsFiltersTest method testManyToOneRelation.
@Test
public void testManyToOneRelation() {
QueryFilter qf = new QueryFilter();
qf.setField("user.id");
qf.setOperation(FilterOperation.EQ);
qf.setValue("28");
QueryParameters q = new QueryParameters();
q.getFilters().add(qf);
List<Project> projects = JPAUtils.queryEntities(em, Project.class, q);
Assert.assertNotNull(projects);
Assert.assertEquals(5, projects.size());
qf = new QueryFilter();
qf.setField("user.firstname");
qf.setOperation(FilterOperation.INIC);
qf.getValues().add("sArAH");
qf.getValues().add("ricHArd");
qf.getValues().add("jACk");
q = new QueryParameters();
q.getFilters().add(qf);
projects = JPAUtils.queryEntities(em, Project.class, q);
Assert.assertNotNull(projects);
Assert.assertEquals(8, projects.size());
}
use of com.github.tfaga.lynx.beans.QueryFilter in project lynx by TFaga.
the class JPAUtilsFiltersTest method testInFilter.
@Test
public void testInFilter() {
QueryFilter qf = new QueryFilter();
qf.setField("firstname");
qf.setOperation(FilterOperation.IN);
qf.getValues().add("Bruce");
qf.getValues().add("Karen");
qf.getValues().add("Sandra");
qf.getValues().add("Laura");
QueryParameters q = new QueryParameters();
q.getFilters().add(qf);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(9, users.size());
}
use of com.github.tfaga.lynx.beans.QueryFilter in project lynx by TFaga.
the class JPAUtilsFiltersTest method testBooleanNinFilter.
@Test
public void testBooleanNinFilter() {
QueryFilter qf = new QueryFilter();
qf.setField("confirmed");
qf.setOperation(FilterOperation.NIN);
qf.getValues().add("FALSE");
qf.getValues().add("trUe");
QueryParameters q = new QueryParameters();
q.getFilters().add(qf);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(0, users.size());
}
use of com.github.tfaga.lynx.beans.QueryFilter in project lynx by TFaga.
the class JPAUtilsFiltersTest method testNullValue.
@Test
public void testNullValue() {
QueryFilter qf = new QueryFilter();
qf.setField("firstname");
qf.setOperation(FilterOperation.EQ);
QueryParameters q = new QueryParameters();
q.getFilters().add(qf);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(100, users.size());
}
Aggregations