use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class TaskResourceRepositoryTest method checkGTDueDate.
@Test
public void checkGTDueDate() {
QuerySpec querySpec = new QuerySpec(ApproveTask.class);
querySpec.addFilter(new FilterSpec(Arrays.asList("dueDate"), FilterOperator.GT, OffsetDateTime.now().minusHours(1)));
Assert.assertEquals(1, taskRepository.findAll(querySpec).size());
querySpec = new QuerySpec(TaskResource.class);
querySpec.addFilter(new FilterSpec(Arrays.asList("dueDate"), FilterOperator.GT, OffsetDateTime.now().plusHours(1)));
Assert.assertEquals(0, taskRepository.findAll(querySpec).size());
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class TaskResourceRepositoryTest method updateTask.
@Test
public void updateTask() {
QuerySpec querySpec = new QuerySpec(TaskResource.class);
OffsetDateTime updatedDueDate = OffsetDateTime.now().plusHours(12);
ApproveTask resource = taskRepository.findOne(task.getId(), querySpec);
resource.setName("updatedName");
resource.setPriority(101);
resource.setDueDate(updatedDueDate);
ApproveTask updatedResource = taskRepository.save(resource);
Assert.assertEquals("updatedName", updatedResource.getName());
Assert.assertEquals(101, updatedResource.getPriority());
Assert.assertEquals(updatedDueDate.toInstant(), updatedResource.getDueDate().toInstant());
updatedResource = taskRepository.findOne(task.getId(), querySpec);
Assert.assertEquals("updatedName", updatedResource.getName());
Assert.assertEquals(101, updatedResource.getPriority());
Assert.assertEquals(updatedDueDate.toInstant(), updatedResource.getDueDate().toInstant());
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class TaskResourceRepositoryTest method checkLEDueDate.
@Test
public void checkLEDueDate() {
QuerySpec querySpec = new QuerySpec(ApproveTask.class);
querySpec.addFilter(new FilterSpec(Arrays.asList("dueDate"), FilterOperator.LT, OffsetDateTime.now().plusHours(1)));
Assert.assertEquals(1, taskRepository.findAll(querySpec).size());
querySpec = new QuerySpec(TaskResource.class);
querySpec.addFilter(new FilterSpec(Arrays.asList("dueDate"), FilterOperator.LT, OffsetDateTime.now().minusHours(1)));
Assert.assertEquals(0, taskRepository.findAll(querySpec).size());
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class TaskResourceRepositoryTest method checkOrderByPriorityDesc.
@Test
public void checkOrderByPriorityDesc() {
addTask("otherTask", 14);
QuerySpec querySpec = new QuerySpec(ApproveTask.class);
querySpec.addSort(new SortSpec(Arrays.asList("priority"), Direction.DESC));
ResourceList<ApproveTask> resources = taskRepository.findAll(querySpec);
Assert.assertEquals(2, resources.size());
Assert.assertEquals("otherTask", resources.get(0).getName());
Assert.assertEquals("testTask", resources.get(1).getName());
}
use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.
the class TaskResourceRepositoryTest method checkGTPriority.
@Test
public void checkGTPriority() {
QuerySpec querySpec = new QuerySpec(ApproveTask.class);
querySpec.addFilter(new FilterSpec(Arrays.asList("priority"), FilterOperator.GE, task.getPriority() - 1));
Assert.assertEquals(1, taskRepository.findAll(querySpec).size());
querySpec = new QuerySpec(TaskResource.class);
querySpec.addFilter(new FilterSpec(Arrays.asList("priority"), FilterOperator.GE, task.getPriority() + 1));
Assert.assertEquals(0, taskRepository.findAll(querySpec).size());
}
Aggregations