use of com.github.tfaga.lynx.beans.QueryParameters 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());
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class JPAUtilsFiltersTest method testOneToManyRelationMultiple.
@Test
public void testOneToManyRelationMultiple() {
QueryFilter qf = new QueryFilter();
qf.setField("projects.name");
qf.setOperation(FilterOperation.EQ);
qf.setValue("Orange");
QueryParameters q = new QueryParameters();
q.getFilters().add(qf);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(3, users.size());
qf = new QueryFilter();
qf.setField("projects.name");
qf.setOperation(FilterOperation.IN);
qf.getValues().add("Maroon");
qf.getValues().add("Orange");
q = new QueryParameters();
q.getFilters().add(qf);
users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(9, users.size());
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class JPAUtilsFiltersTest method testNinFilter.
@Test
public void testNinFilter() {
QueryFilter qf = new QueryFilter();
qf.setField("firstname");
qf.setOperation(FilterOperation.NIN);
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(91, users.size());
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class JPAUtilsFiltersTest method testOneToManyRelation.
@Test
public void testOneToManyRelation() {
QueryFilter qf = new QueryFilter();
qf.setField("projects.id");
qf.setOperation(FilterOperation.EQ);
qf.setValue("10");
QueryParameters q = new QueryParameters();
q.getFilters().add(qf);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(1, users.size());
qf = new QueryFilter();
qf.setField("projects.name");
qf.setOperation(FilterOperation.NIN);
qf.getValues().add("Green");
qf.getValues().add("Violet");
q = new QueryParameters();
q.getFilters().add(qf);
users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(55, users.size());
}
use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.
the class JPAUtilsFiltersTest method testBooleanFilter.
@Test
public void testBooleanFilter() {
QueryFilter qf = new QueryFilter();
qf.setField("confirmed");
qf.setOperation(FilterOperation.EQ);
qf.setValue("true");
QueryParameters q = new QueryParameters();
q.getFilters().add(qf);
List<User> users = JPAUtils.queryEntities(em, User.class, q);
Assert.assertNotNull(users);
Assert.assertEquals(55, users.size());
}
Aggregations