use of io.crnk.core.queryspec.SortSpec 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.SortSpec in project crnk-framework by crnk-project.
the class DefaultQuerySpecDeserializerTestBase method testFindAllOrderByAsc.
@Test
public void testFindAllOrderByAsc() {
QuerySpec expectedSpec = new QuerySpec(Task.class);
expectedSpec.addSort(new SortSpec(Arrays.asList("name"), Direction.ASC));
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.SortSpec in project crnk-framework by crnk-project.
the class DefaultQuerySpecDeserializerTestBase method testFollowNestedObjectWithinResource.
@Test
public void testFollowNestedObjectWithinResource() {
// follow ProjectData.data
QuerySpec expectedSpec = new QuerySpec(Project.class);
expectedSpec.addSort(new SortSpec(Arrays.asList("data", "data"), Direction.ASC));
Map<String, Set<String>> params = new HashMap<>();
add(params, "sort", "data.data");
QuerySpec actualSpec = deserializer.deserialize(taskInformation, params);
Assert.assertEquals(expectedSpec, actualSpec);
}
use of io.crnk.core.queryspec.SortSpec in project crnk-framework by crnk-project.
the class DefaultQuerySpecDeserializerTestBase method testOrderByMultipleAttributes.
@Test
public void testOrderByMultipleAttributes() {
QuerySpec expectedSpec = new QuerySpec(Task.class);
expectedSpec.addSort(new SortSpec(Arrays.asList("name"), Direction.ASC));
expectedSpec.addSort(new SortSpec(Arrays.asList("id"), Direction.ASC));
Map<String, Set<String>> params = new HashMap<>();
add(params, "sort[tasks]", "name,id");
QuerySpec actualSpec = deserializer.deserialize(taskInformation, params);
Assert.assertEquals(expectedSpec, actualSpec);
}
use of io.crnk.core.queryspec.SortSpec in project crnk-framework by crnk-project.
the class TaskResourceRepositoryTest method checkIsolation.
@Test
public void checkIsolation() {
addTask("otherTask1", 14);
addTask("otherTask2", 15);
addTask("otherTask3", 16);
QuerySpec querySpec = new QuerySpec(ApproveTask.class);
querySpec.addSort(new SortSpec(Arrays.asList("priority"), Direction.ASC));
querySpec.setOffset(1);
querySpec.setLimit(2L);
ResourceList<ApproveTask> resources = taskRepository.findAll(querySpec);
Assert.assertEquals(2, resources.size());
Assert.assertEquals("otherTask1", resources.get(0).getName());
Assert.assertEquals("otherTask2", resources.get(1).getName());
}
Aggregations