Search in sources :

Example 1 with ApproveTask

use of io.crnk.activiti.example.model.ApproveTask in project crnk-framework by crnk-project.

the class ActivitiTestBase method setup.

@Before
public void setup() {
    processEngine = ProcessEngines.getDefaultProcessEngine();
    processEngine.getRepositoryService().createDeployment().addClasspathResource("approval.bpmn20.xml").deploy();
    boot = new CrnkBoot();
    boot.addModule(new TestModule());
    boot.addModule(createActivitiModule());
    boot.boot();
    taskRepository = (TaskResourceRepository<ApproveTask>) boot.getResourceRegistry().getEntry(ApproveTask.class).getResourceRepository().getResourceRepository();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) TestModule(io.crnk.test.mock.TestModule) ApproveTask(io.crnk.activiti.example.model.ApproveTask) Before(org.junit.Before)

Example 2 with ApproveTask

use of io.crnk.activiti.example.model.ApproveTask in project crnk-framework by crnk-project.

the class TaskResourceRepositoryTest method deleteTask.

@Test
public void deleteTask() {
    QuerySpec querySpec = new QuerySpec(ApproveTask.class);
    ApproveTask resource = taskRepository.findOne(task.getId(), querySpec);
    taskRepository.delete(resource.getId());
    try {
        taskRepository.findOne(task.getId(), querySpec);
        Assert.fail();
    } catch (ResourceNotFoundException e) {
    // ok
    }
}
Also used : QuerySpec(io.crnk.core.queryspec.QuerySpec) ResourceNotFoundException(io.crnk.core.exception.ResourceNotFoundException) ApproveTask(io.crnk.activiti.example.model.ApproveTask) Test(org.junit.Test)

Example 3 with ApproveTask

use of io.crnk.activiti.example.model.ApproveTask in project crnk-framework by crnk-project.

the class TaskResourceRepositoryTest method checkFilterEnforcementOnCreate.

@Test(expected = BadRequestException.class)
public void checkFilterEnforcementOnCreate() {
    ApproveTask resource = new ApproveTask();
    resource.setName("testTask");
    // must be set => due to chosen setup
    resource.setDescription("invalid");
    taskRepository.create(resource);
}
Also used : ApproveTask(io.crnk.activiti.example.model.ApproveTask) Test(org.junit.Test)

Example 4 with ApproveTask

use of io.crnk.activiti.example.model.ApproveTask 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());
}
Also used : OffsetDateTime(java.time.OffsetDateTime) QuerySpec(io.crnk.core.queryspec.QuerySpec) ApproveTask(io.crnk.activiti.example.model.ApproveTask) Test(org.junit.Test)

Example 5 with ApproveTask

use of io.crnk.activiti.example.model.ApproveTask 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());
}
Also used : QuerySpec(io.crnk.core.queryspec.QuerySpec) ApproveTask(io.crnk.activiti.example.model.ApproveTask) SortSpec(io.crnk.core.queryspec.SortSpec) Test(org.junit.Test)

Aggregations

ApproveTask (io.crnk.activiti.example.model.ApproveTask)16 Test (org.junit.Test)13 QuerySpec (io.crnk.core.queryspec.QuerySpec)11 SortSpec (io.crnk.core.queryspec.SortSpec)4 ScheduleApprovalProcessInstance (io.crnk.activiti.example.model.ScheduleApprovalProcessInstance)2 ResourceNotFoundException (io.crnk.core.exception.ResourceNotFoundException)2 CrnkBoot (io.crnk.core.boot.CrnkBoot)1 FilterSpec (io.crnk.core.queryspec.FilterSpec)1 TestModule (io.crnk.test.mock.TestModule)1 Schedule (io.crnk.test.mock.models.Schedule)1 OffsetDateTime (java.time.OffsetDateTime)1 JerseyTest (org.glassfish.jersey.test.JerseyTest)1 Before (org.junit.Before)1