Search in sources :

Example 36 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class ProcessInstanceSuspensionTest method testCannotSuspendSuspendedProcessInstance.

@Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testCannotSuspendSuspendedProcessInstance() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    runtimeService.startProcessInstanceByKey(processDefinition.getKey());
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
    assertFalse(processInstance.isSuspended());
    runtimeService.suspendProcessInstanceById(processInstance.getId());
    try {
        runtimeService.suspendProcessInstanceById(processInstance.getId());
        fail("Expected activiti exception");
    } catch (ActivitiException e) {
    // expected
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 37 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class ExecutionQueryTest method testQueryByActivityId.

public void testQueryByActivityId() {
    ExecutionQuery query = runtimeService.createExecutionQuery().activityId("receivePayment");
    assertEquals(4, query.list().size());
    assertEquals(4, query.count());
    try {
        assertNull(query.singleResult());
        fail();
    } catch (ActivitiException e) {
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ExecutionQuery(org.activiti.engine.runtime.ExecutionQuery)

Example 38 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class ProcessInstanceQueryTest method testQueryByProcessDefinitionKeys.

public void testQueryByProcessDefinitionKeys() {
    final Set<String> processDefinitionKeySet = new HashSet<String>(2);
    processDefinitionKeySet.add(PROCESS_DEFINITION_KEY);
    processDefinitionKeySet.add(PROCESS_DEFINITION_KEY_2);
    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processDefinitionKeys(processDefinitionKeySet);
    assertEquals(PROCESS_DEPLOY_COUNT, query.count());
    assertEquals(PROCESS_DEPLOY_COUNT, query.list().size());
    try {
        query.singleResult();
        fail();
    } catch (ActivitiException e) {
    // Exception is expected
    }
}
Also used : ProcessInstanceQuery(org.activiti.engine.runtime.ProcessInstanceQuery) ActivitiException(org.activiti.engine.ActivitiException) HashSet(java.util.HashSet)

Example 39 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class ProcessInstanceSuspensionTest method testCannotActivateActiveProcessInstance.

@Deployment(resources = { "org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testCannotActivateActiveProcessInstance() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    runtimeService.startProcessInstanceByKey(processDefinition.getKey());
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
    assertFalse(processInstance.isSuspended());
    try {
        //activate
        runtimeService.activateProcessInstanceById(processInstance.getId());
        fail("Expected activiti exception");
    } catch (ActivitiException e) {
    // expected
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 40 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class RepositoryServiceTest method testDeploymentWithDelayedProcessDefinitionActivation.

public void testDeploymentWithDelayedProcessDefinitionActivation() {
    Date startTime = new Date();
    processEngineConfiguration.getClock().setCurrentTime(startTime);
    Date inThreeDays = new Date(startTime.getTime() + (3 * 24 * 60 * 60 * 1000));
    // Deploy process, but activate after three days
    org.activiti.engine.repository.Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml").addClasspathResource("org/activiti/engine/test/api/twoTasksProcess.bpmn20.xml").activateProcessDefinitionsOn(inThreeDays).deploy();
    assertEquals(1, repositoryService.createDeploymentQuery().count());
    assertEquals(2, repositoryService.createProcessDefinitionQuery().count());
    assertEquals(2, repositoryService.createProcessDefinitionQuery().suspended().count());
    assertEquals(0, repositoryService.createProcessDefinitionQuery().active().count());
    // Shouldn't be able to start a process instance
    try {
        runtimeService.startProcessInstanceByKey("oneTaskProcess");
        fail();
    } catch (ActivitiException e) {
        assertTextPresentIgnoreCase("suspended", e.getMessage());
    }
    // Move time four days forward, the timer will fire and the process definitions will be active
    Date inFourDays = new Date(startTime.getTime() + (4 * 24 * 60 * 60 * 1000));
    processEngineConfiguration.getClock().setCurrentTime(inFourDays);
    waitForJobExecutorToProcessAllJobs(5000L, 50L);
    assertEquals(1, repositoryService.createDeploymentQuery().count());
    assertEquals(2, repositoryService.createProcessDefinitionQuery().count());
    assertEquals(0, repositoryService.createProcessDefinitionQuery().suspended().count());
    assertEquals(2, repositoryService.createProcessDefinitionQuery().active().count());
    // Should be able to start process instance
    runtimeService.startProcessInstanceByKey("oneTaskProcess");
    assertEquals(1, runtimeService.createProcessInstanceQuery().count());
    // Cleanup
    repositoryService.deleteDeployment(deployment.getId(), true);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) Date(java.util.Date)

Aggregations

ActivitiException (org.activiti.engine.ActivitiException)247 Deployment (org.activiti.engine.test.Deployment)38 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)36 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)35 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)31 IOException (java.io.IOException)28 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)23 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)21 ArrayList (java.util.ArrayList)20 TaskQuery (org.activiti.engine.task.TaskQuery)16 HashMap (java.util.HashMap)14 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)14 Task (org.activiti.engine.task.Task)14 ByteArrayOutputStream (java.io.ByteArrayOutputStream)13 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)12 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)10 ObjectOutputStream (java.io.ObjectOutputStream)10 Date (java.util.Date)10 RestVariable (org.activiti.rest.service.api.engine.variable.RestVariable)10 JobExecutor (org.activiti.engine.impl.jobexecutor.JobExecutor)9