Search in sources :

Example 71 with QueryParameters

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

the class JPAUtilsPagingTest method testEmptyQuery.

@Test
public void testEmptyQuery() {
    List<User> users = JPAUtils.queryEntities(em, User.class, new QueryParameters());
    Assert.assertNotNull(users);
    Assert.assertEquals(100, users.size());
}
Also used : User(com.github.tfaga.lynx.test.entities.User) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 72 with QueryParameters

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

the class JPAUtilsPagingTest method testLimit.

@Test
public void testLimit() {
    QueryParameters q = new QueryParameters();
    q.setLimit(10);
    List<User> users = JPAUtils.queryEntities(em, User.class, q);
    Assert.assertNotNull(users);
    Assert.assertEquals(10, users.size());
    Assert.assertNotNull(users.get(0).getId());
    Assert.assertEquals(1, users.get(0).getId().intValue());
    Assert.assertNotNull(users.get(9).getId());
    Assert.assertEquals(10, users.get(9).getId().intValue());
}
Also used : User(com.github.tfaga.lynx.test.entities.User) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 73 with QueryParameters

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

the class JPAUtilsPagingTest method testOffset.

@Test
public void testOffset() {
    QueryParameters q = new QueryParameters();
    q.setOffset(30);
    List<User> users = JPAUtils.queryEntities(em, User.class, q);
    Assert.assertNotNull(users);
    Assert.assertEquals(70, users.size());
    Assert.assertNotNull(users.get(0).getId());
    Assert.assertEquals(31, users.get(0).getId().intValue());
    Assert.assertNotNull(users.get(69).getId());
    Assert.assertEquals(100, users.get(69).getId().intValue());
}
Also used : User(com.github.tfaga.lynx.test.entities.User) QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 74 with QueryParameters

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

the class QueryStringBuilderFieldsTest method testEmptyFieldWithoutDelimiter.

@Test
public void testEmptyFieldWithoutDelimiter() {
    QueryParameters query = QueryParameters.query("fields").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getFields());
    Assert.assertEquals(0, query.getFields().size());
}
Also used : QueryParameters(com.github.tfaga.lynx.beans.QueryParameters) Test(org.junit.Test)

Example 75 with QueryParameters

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

the class QueryStringBuilderFieldsTest method testSingleField.

@Test
public void testSingleField() {
    QueryParameters query = QueryParameters.query("fields=username").build();
    Assert.assertNotNull(query);
    Assert.assertNotNull(query.getFields());
    Assert.assertEquals(1, query.getFields().size());
    Assert.assertEquals("username", query.getFields().get(0));
}
Also used : 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