Search in sources :

Example 31 with SuspendedEntityInteractionException

use of org.camunda.bpm.engine.SuspendedEntityInteractionException in project camunda-bpm-platform by camunda.

the class ProcessInstanceSuspensionTest method testTaskNonLifecycleOperationsSucceedAfterProcessInstanceSuspendByProcessDefinitionKey.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTaskNonLifecycleOperationsSucceedAfterProcessInstanceSuspendByProcessDefinitionKey() {
    // Start a new process instance with one task
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
    final Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    runtimeService.suspendProcessInstanceByProcessDefinitionKey(processDefinition.getKey());
    assertNotNull(task);
    try {
        taskService.setVariable(task.getId(), "someVar", "someValue");
    } catch (SuspendedEntityInteractionException e) {
        fail("should be allowed");
    }
    try {
        taskService.setVariableLocal(task.getId(), "someVar", "someValue");
    } catch (SuspendedEntityInteractionException e) {
        fail("should be allowed");
    }
    try {
        HashMap<String, String> variables = new HashMap<String, String>();
        variables.put("varOne", "one");
        variables.put("varTwo", "two");
        taskService.setVariables(task.getId(), variables);
    } catch (SuspendedEntityInteractionException e) {
        fail("should be allowed");
    }
    try {
        HashMap<String, String> variables = new HashMap<String, String>();
        variables.put("varOne", "one");
        variables.put("varTwo", "two");
        taskService.setVariablesLocal(task.getId(), variables);
    } catch (SuspendedEntityInteractionException e) {
        fail("should be allowed");
    }
    try {
        taskService.removeVariable(task.getId(), "someVar");
    } catch (SuspendedEntityInteractionException e) {
        fail("should be allowed");
    }
    try {
        taskService.removeVariableLocal(task.getId(), "someVar");
    } catch (SuspendedEntityInteractionException e) {
        fail("should be allowed");
    }
    try {
        taskService.removeVariables(task.getId(), Arrays.asList("one", "two"));
    } catch (SuspendedEntityInteractionException e) {
        fail("should be allowed");
    }
    try {
        taskService.removeVariablesLocal(task.getId(), Arrays.asList("one", "two"));
    } catch (SuspendedEntityInteractionException e) {
        fail("should be allowed");
    }
    if (processEngineConfiguration.getHistoryLevel().getId() > HistoryLevel.HISTORY_LEVEL_ACTIVITY.getId()) {
        try {
            taskService.createComment(task.getId(), processInstance.getId(), "test comment");
        } catch (SuspendedEntityInteractionException e) {
            fail("should be allowed");
        }
        try {
            taskService.createAttachment("text", task.getId(), processInstance.getId(), "tesTastName", "testDescription", "http://test.com");
        } catch (SuspendedEntityInteractionException e) {
            fail("should be allowed");
        }
    }
    try {
        taskService.setPriority(task.getId(), 99);
    } catch (SuspendedEntityInteractionException e) {
        fail("should be allowed");
    }
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Task(org.camunda.bpm.engine.task.Task) HashMap(java.util.HashMap) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 32 with SuspendedEntityInteractionException

use of org.camunda.bpm.engine.SuspendedEntityInteractionException in project camunda-bpm-platform by camunda.

the class ProcessInstanceSuspensionTest method testStartAfterActivityForSuspendProcessInstance.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testStartAfterActivityForSuspendProcessInstance() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    // start process instance
    runtimeService.startProcessInstanceById(processDefinition.getId());
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
    // Suspend process instance
    runtimeService.suspendProcessInstanceById(processInstance.getId());
    // try to start after activity for suspended processDefinition
    try {
        runtimeService.createProcessInstanceModification(processInstance.getId()).startAfterActivity("theTask").execute();
        fail("Exception is expected but not thrown");
    } catch (SuspendedEntityInteractionException e) {
        assertTextPresentIgnoreCase("is suspended", e.getMessage());
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 33 with SuspendedEntityInteractionException

use of org.camunda.bpm.engine.SuspendedEntityInteractionException in project camunda-bpm-platform by camunda.

the class ProcessInstanceSuspensionTest method testMessageEventReceiveFailAfterSuspendByProcessDefinitionId.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/ProcessInstanceSuspensionTest.testMessageEventReceiveFailAfterSuspend.bpmn20.xml" })
public void testMessageEventReceiveFailAfterSuspendByProcessDefinitionId() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    runtimeService.startProcessInstanceById(processDefinition.getId());
    runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinition.getId());
    EventSubscription subscription = runtimeService.createEventSubscriptionQuery().singleResult();
    try {
        runtimeService.messageEventReceived("someMessage", subscription.getExecutionId());
        fail();
    } catch (SuspendedEntityInteractionException e) {
        // This is expected
        assertTextPresent("is suspended", e.getMessage());
    }
    try {
        runtimeService.messageEventReceived("someMessage", subscription.getExecutionId(), new HashMap<String, Object>());
        fail();
    } catch (SuspendedEntityInteractionException e) {
        // This is expected
        assertTextPresent("is suspended", e.getMessage());
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 34 with SuspendedEntityInteractionException

use of org.camunda.bpm.engine.SuspendedEntityInteractionException in project camunda-bpm-platform by camunda.

the class ProcessInstanceSuspensionTest method testSubmitTaskFormFailAfterProcessInstanceSuspendByProcessDefinitionKey.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testSubmitTaskFormFailAfterProcessInstanceSuspendByProcessDefinitionKey() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
    runtimeService.suspendProcessInstanceByProcessDefinitionKey(processDefinition.getKey());
    try {
        formService.submitTaskFormData(taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getId(), new HashMap<String, String>());
        fail();
    } catch (SuspendedEntityInteractionException e) {
    // This is expected
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 35 with SuspendedEntityInteractionException

use of org.camunda.bpm.engine.SuspendedEntityInteractionException in project camunda-bpm-platform by camunda.

the class ProcessInstanceSuspensionTest method testProcessInstanceSignalFailAfterSuspend.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testProcessInstanceSignalFailAfterSuspend() {
    // Suspend process instance
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
    runtimeService.suspendProcessInstanceById(processInstance.getId());
    try {
        runtimeService.signal(processInstance.getId());
        fail();
    } catch (SuspendedEntityInteractionException e) {
        // This is expected
        assertTextPresent("is suspended", e.getMessage());
        assertTrue(e instanceof BadUserRequestException);
    }
    try {
        runtimeService.signal(processInstance.getId(), new HashMap<String, Object>());
        fail();
    } catch (SuspendedEntityInteractionException e) {
        // This is expected
        assertTextPresent("is suspended", e.getMessage());
        assertTrue(e instanceof BadUserRequestException);
    }
}
Also used : ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BadUserRequestException(org.camunda.bpm.engine.BadUserRequestException) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

SuspendedEntityInteractionException (org.camunda.bpm.engine.SuspendedEntityInteractionException)39 Deployment (org.camunda.bpm.engine.test.Deployment)34 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)30 Task (org.camunda.bpm.engine.task.Task)16 ExternalTask (org.camunda.bpm.engine.externaltask.ExternalTask)15 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)8 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)5 Test (org.junit.Test)5 Date (java.util.Date)3 HashMap (java.util.HashMap)3 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3 Job (org.camunda.bpm.engine.runtime.Job)3