Search in sources :

Example 1 with QuerySpec

use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.

the class ProcessInstanceRepositoryTest method checkLEStartTime.

@Test
public void checkLEStartTime() {
    QuerySpec querySpec = new QuerySpec(ScheduleApprovalProcessInstance.class);
    querySpec.addFilter(new FilterSpec(Arrays.asList("startTime"), FilterOperator.LT, OffsetDateTime.now().plusHours(1)));
    Assert.assertEquals(1, processRepository.findAll(querySpec).size());
    querySpec = new QuerySpec(ScheduleApprovalProcessInstance.class);
    querySpec.addFilter(new FilterSpec(Arrays.asList("startTime"), FilterOperator.LT, OffsetDateTime.now().minusHours(1)));
    Assert.assertEquals(0, processRepository.findAll(querySpec).size());
}
Also used : ScheduleApprovalProcessInstance(io.crnk.activiti.example.model.ScheduleApprovalProcessInstance) QuerySpec(io.crnk.core.queryspec.QuerySpec) FilterSpec(io.crnk.core.queryspec.FilterSpec) Test(org.junit.Test)

Example 2 with QuerySpec

use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.

the class ProcessInstanceRepositoryTest method checkGTStartTime.

@Test
public void checkGTStartTime() {
    QuerySpec querySpec = new QuerySpec(ScheduleApprovalProcessInstance.class);
    querySpec.addFilter(new FilterSpec(Arrays.asList("startTime"), FilterOperator.GT, OffsetDateTime.now().minusHours(1)));
    Assert.assertEquals(1, processRepository.findAll(querySpec).size());
    querySpec = new QuerySpec(ScheduleApprovalProcessInstance.class);
    querySpec.addFilter(new FilterSpec(Arrays.asList("startTime"), FilterOperator.GT, OffsetDateTime.now().plusHours(1)));
    Assert.assertEquals(0, processRepository.findAll(querySpec).size());
}
Also used : ScheduleApprovalProcessInstance(io.crnk.activiti.example.model.ScheduleApprovalProcessInstance) QuerySpec(io.crnk.core.queryspec.QuerySpec) FilterSpec(io.crnk.core.queryspec.FilterSpec) Test(org.junit.Test)

Example 3 with QuerySpec

use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.

the class ProcessInstanceRepositoryTest method checkDelete.

@Test
public void checkDelete() {
    ScheduleApprovalProcessInstance processInstance = postProcess(null, null, null);
    processRepository.delete(processInstance.getId());
    try {
        processRepository.findOne(processInstance.getId(), new QuerySpec(ScheduleApprovalProcessInstance.class));
        Assert.fail();
    } catch (ResourceNotFoundException e) {
    // ok
    }
}
Also used : ScheduleApprovalProcessInstance(io.crnk.activiti.example.model.ScheduleApprovalProcessInstance) QuerySpec(io.crnk.core.queryspec.QuerySpec) ResourceNotFoundException(io.crnk.core.exception.ResourceNotFoundException) Test(org.junit.Test)

Example 4 with QuerySpec

use of io.crnk.core.queryspec.QuerySpec in project crnk-framework by crnk-project.

the class ProcessInstanceRepositoryTest method checkResourceMapping.

@Test
public void checkResourceMapping() {
    QuerySpec querySpec = new QuerySpec(ScheduleApprovalProcessInstance.class);
    ScheduleApprovalProcessInstance resource = processRepository.findOne(processInstance.getId(), querySpec);
    assertEqualsNotNull(processInstance.getId(), resource.getId());
    assertEqualsNotNull(processInstance.getName(), resource.getName());
    assertEqualsNotNull(processInstance.isEnded(), resource.isEnded());
    assertEqualsNotNull(processInstance.isSuspended(), resource.isSuspended());
    assertEqualsNotNull(processInstance.getBusinessKey(), resource.getBusinessKey());
    assertEqualsNotNull(processInstance.getProcessDefinitionKey(), resource.getProcessDefinitionKey());
    Map<String, Object> variables = processInstance.getProcessVariables();
    assertEqualsNotNull(variables.get("newValues.name"), resource.getNewValues().getName());
    assertEqualsNotNull(variables.get("resourceId"), resource.getResourceId());
    assertEqualsNotNull(variables.get("resourceType"), resource.getResourceType());
}
Also used : ScheduleApprovalProcessInstance(io.crnk.activiti.example.model.ScheduleApprovalProcessInstance) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 5 with QuerySpec

use of io.crnk.core.queryspec.QuerySpec 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)

Aggregations

QuerySpec (io.crnk.core.queryspec.QuerySpec)306 Test (org.junit.Test)233 FilterSpec (io.crnk.core.queryspec.FilterSpec)51 Document (io.crnk.core.engine.document.Document)45 Resource (io.crnk.core.engine.document.Resource)43 Set (java.util.Set)39 HashMap (java.util.HashMap)37 HashSet (java.util.HashSet)36 AbstractQuerySpecTest (io.crnk.core.queryspec.AbstractQuerySpecTest)34 QuerySpecAdapter (io.crnk.core.queryspec.internal.QuerySpecAdapter)32 AbstractJpaJerseyTest (io.crnk.jpa.AbstractJpaJerseyTest)32 Task (io.crnk.test.mock.models.Task)32 Project (io.crnk.core.mock.models.Project)28 Relationship (io.crnk.core.engine.document.Relationship)26 Task (io.crnk.core.mock.models.Task)26 TestEntity (io.crnk.jpa.model.TestEntity)26 ResourceIdentifier (io.crnk.core.engine.document.ResourceIdentifier)25 Serializable (java.io.Serializable)24 RelatedEntity (io.crnk.jpa.model.RelatedEntity)21 ResourceRegistryTest (io.crnk.core.resource.registry.ResourceRegistryTest)20