use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class DefaultQuerySpecDeserializerTestBase method testUnknownPropertyAllowed.
@Test
public void testUnknownPropertyAllowed() {
QuerySpec expectedSpec = new QuerySpec(Task.class);
expectedSpec.addFilter(new FilterSpec(Arrays.asList("doesNotExists"), FilterOperator.EQ, "value"));
deserializer.setAllowUnknownAttributes(true);
Map<String, Set<String>> params = new HashMap<>();
add(params, "filter[tasks][doesNotExists]", "value");
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 testHyphenIsAllowedInResourceName.
@Test
public void testHyphenIsAllowedInResourceName() {
QuerySpec expectedSpec = new QuerySpec(Task.class);
expectedSpec.addSort(new SortSpec(Arrays.asList("id"), Direction.ASC));
Map<String, Set<String>> params = new HashMap<>();
add(params, "sort[task-with-lookup]", "id");
ResourceInformation taskWithLookUpInformation = resourceRegistry.getEntryForClass(TaskWithLookup.class).getResourceInformation();
QuerySpec actualSpec = deserializer.deserialize(taskWithLookUpInformation, params);
Assert.assertEquals(expectedSpec, actualSpec);
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class DefaultQuerySpecDeserializerTestBase method testFindAllOrderByDesc.
@Test
public void testFindAllOrderByDesc() {
QuerySpec expectedSpec = new QuerySpec(Task.class);
expectedSpec.addSort(new SortSpec(Arrays.asList("name"), Direction.DESC));
Map<String, Set<String>> params = new HashMap<>();
add(params, "sort[tasks]", "-name");
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 testFilterGreaterOnRoot.
@Test
public void testFilterGreaterOnRoot() {
QuerySpec expectedSpec = new QuerySpec(Task.class);
expectedSpec.addFilter(new FilterSpec(Arrays.asList("id"), FilterOperator.LE, 1L));
Map<String, Set<String>> params = new HashMap<>();
add(params, "filter[id][LE]", "1");
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 testFilterWithComputedAttribute.
@Test
public void testFilterWithComputedAttribute() {
// if computeAttribte is not found, module order is wrong
// tests setup with information builder must be hardened
QuerySpec expectedSpec = new QuerySpec(Task.class);
expectedSpec.addFilter(new FilterSpec(Arrays.asList("computedAttribute"), FilterOperator.EQ, 13));
Map<String, Set<String>> params = new HashMap<>();
add(params, "filter[tasks][computedAttribute]", "13");
QuerySpec actualSpec = deserializer.deserialize(taskInformation, params);
Assert.assertEquals(expectedSpec, actualSpec);
}
Aggregations