Search in sources :

Example 16 with QueryParameters

use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.

the class JPAUtilsFiltersTest method testBooleanInFilter.

@Test
public void testBooleanInFilter() {
    QueryFilter qf = new QueryFilter();
    qf.setField("confirmed");
    qf.setOperation(FilterOperation.IN);
    qf.getValues().add("False");
    QueryParameters q = new QueryParameters();
    q.getFilters().add(qf);
    List<User> users = JPAUtils.queryEntities(em, User.class, q);
    Assert.assertNotNull(users);
    Assert.assertEquals(45, users.size());
}
Also used : QueryFilter(com.github.tfaga.lynx.beans.QueryFilter) User(com.github.tfaga.lynx.test.entities.User) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 17 with QueryParameters

use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.

the class JPAUtilsFiltersTest method testManyToOneRelationOnlyField.

@Test
public void testManyToOneRelationOnlyField() {
    QueryFilter qf = new QueryFilter();
    qf.setField("user");
    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(100, projects.size());
}
Also used : Project(com.github.tfaga.lynx.test.entities.Project) QueryFilter(com.github.tfaga.lynx.beans.QueryFilter) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 18 with QueryParameters

use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.

the class JPAUtilsFiltersTest method testEnumInFilter.

@Test
public void testEnumInFilter() {
    QueryFilter qf = new QueryFilter();
    qf.setField("status");
    qf.setOperation(FilterOperation.IN);
    qf.getValues().add("ACTIVE");
    QueryParameters q = new QueryParameters();
    q.getFilters().add(qf);
    List<Project> projects = JPAUtils.queryEntities(em, Project.class, q);
    Assert.assertNotNull(projects);
    Assert.assertEquals(50, projects.size());
}
Also used : Project(com.github.tfaga.lynx.test.entities.Project) QueryFilter(com.github.tfaga.lynx.beans.QueryFilter) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 19 with QueryParameters

use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.

the class JPAUtilsFiltersTest method testEnumNinFilter.

@Test
public void testEnumNinFilter() {
    QueryFilter qf = new QueryFilter();
    qf.setField("status");
    qf.setOperation(FilterOperation.NIN);
    qf.getValues().add("ACTIVE");
    qf.getValues().add("INACTIVE");
    QueryParameters q = new QueryParameters();
    q.getFilters().add(qf);
    List<Project> projects = JPAUtils.queryEntities(em, Project.class, q);
    Assert.assertNotNull(projects);
    Assert.assertEquals(0, projects.size());
}
Also used : Project(com.github.tfaga.lynx.test.entities.Project) QueryFilter(com.github.tfaga.lynx.beans.QueryFilter) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 20 with QueryParameters

use of com.github.tfaga.lynx.beans.QueryParameters in project lynx by TFaga.

the class JPAUtilsFiltersTest method testOneToManyRelationOnlyFieldInteger.

@Test
public void testOneToManyRelationOnlyFieldInteger() {
    QueryFilter qf = new QueryFilter();
    qf.setField("projects");
    qf.setOperation(FilterOperation.EQ);
    qf.setValue("28");
    QueryParameters q = new QueryParameters();
    q.getFilters().add(qf);
    List<User> users = JPAUtils.queryEntities(em, User.class, q);
    Assert.assertNotNull(users);
    Assert.assertEquals(60, users.size());
}
Also used : QueryFilter(com.github.tfaga.lynx.beans.QueryFilter) User(com.github.tfaga.lynx.test.entities.User) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Aggregations

QueryParameters (com.github.tfaga.lynx.beans.QueryParameters)158 Test (org.junit.Test)155 User (com.github.tfaga.lynx.test.entities.User)46 QueryFilter (com.github.tfaga.lynx.beans.QueryFilter)44 QueryStringDefaults (com.github.tfaga.lynx.utils.QueryStringDefaults)14 QueryOrder (com.github.tfaga.lynx.beans.QueryOrder)13 Project (com.github.tfaga.lynx.test.entities.Project)12 NoSuchEntityFieldException (com.github.tfaga.lynx.exceptions.NoSuchEntityFieldException)6 Date (java.util.Date)6 URI (java.net.URI)4 CriteriaField (com.github.tfaga.lynx.beans.CriteriaField)2 CriteriaWhereQuery (com.github.tfaga.lynx.beans.CriteriaWhereQuery)2 OrderDirection (com.github.tfaga.lynx.enums.OrderDirection)2 InvalidEntityFieldException (com.github.tfaga.lynx.exceptions.InvalidEntityFieldException)2 InvalidFieldValueException (com.github.tfaga.lynx.exceptions.InvalidFieldValueException)2 CriteriaFilter (com.github.tfaga.lynx.interfaces.CriteriaFilter)2 Field (java.lang.reflect.Field)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ZonedDateTime (java.time.ZonedDateTime)2 DateTimeParseException (java.time.format.DateTimeParseException)2