use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class DefaultQuerySpecDeserializerTestBase method customPaginationOnRoot.
@Test
public void customPaginationOnRoot() {
Map<String, Set<String>> params = new HashMap<>();
QuerySpec actualSpec = deserializer.deserialize(taskWithPagingBehaviorInformation, params);
Assert.assertEquals(1L, actualSpec.getOffset());
Assert.assertEquals(10L, actualSpec.getLimit().longValue());
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class DefaultQuerySpecDeserializerTestBase method testFindAll.
@Test
public void testFindAll() {
Map<String, Set<String>> params = new HashMap<>();
QuerySpec actualSpec = deserializer.deserialize(taskInformation, params);
QuerySpec expectedSpec = new QuerySpec(Task.class);
Assert.assertEquals(expectedSpec, actualSpec);
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class DefaultQuerySpecDeserializerTestBase method testUnknownPropertyNotAllowed.
@Test(expected = PropertyException.class)
public void testUnknownPropertyNotAllowed() {
QuerySpec expectedSpec = new QuerySpec(Task.class);
expectedSpec.addFilter(new FilterSpec(Arrays.asList("doesNotExists"), FilterOperator.EQ, "value"));
deserializer.setAllowUnknownAttributes(false);
Map<String, Set<String>> params = new HashMap<>();
add(params, "filter[tasks][doesNotExists]", "value");
deserializer.deserialize(taskInformation, params);
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class DefaultQuerySpecDeserializerTestBase method testPagingMaxLimitAllowed.
@Test
public void testPagingMaxLimitAllowed() {
QuerySpec expectedSpec = new QuerySpec(Task.class);
expectedSpec.setOffset(1L);
expectedSpec.setLimit(5L);
Map<String, Set<String>> params = new HashMap<>();
add(params, "page[offset]", "1");
add(params, "page[limit]", "5");
QuerySpec actualSpec = deserializer.deserialize(taskInformation, params);
Assert.assertEquals(expectedSpec, actualSpec);
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class DefaultQuerySpecDeserializerTestBase method testGenericCast.
@Test
public void testGenericCast() {
Map<String, Set<String>> params = new HashMap<>();
add(params, "filter[id]", "12");
add(params, "filter[name]", "test");
add(params, "filter[completed]", "true");
deserializer.setIgnoreParseExceptions(false);
QuerySpec querySpec = deserializer.deserialize(taskInformation, params);
Assert.assertEquals(Task.class, querySpec.getResourceClass());
Assert.assertEquals(Arrays.asList("id"), querySpec.getFilters().get(2).getAttributePath());
Long id = querySpec.getFilters().get(2).getValue();
Assert.assertEquals(Long.valueOf(12), id);
String name = querySpec.getFilters().get(0).getValue();
Assert.assertEquals("test", name);
Boolean completed = querySpec.getFilters().get(1).getValue();
Assert.assertEquals(Boolean.TRUE, completed);
Assert.assertNull(querySpec.getRelatedSpecs().get(Project.class));
}
Aggregations