Search in sources :

Example 11 with SuspendedEntityInteractionException

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

the class ProcessInstanceSuspensionTest method testProcessInstanceSignalFailAfterSuspendByProcessDefinitionId.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testProcessInstanceSignalFailAfterSuspendByProcessDefinitionId() {
    // Suspend process instance
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
    runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinition.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)

Example 12 with SuspendedEntityInteractionException

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

the class ProcessInstanceSuspensionTest method testMessageEventReceiveFailAfterSuspend.

@Deployment
public void testMessageEventReceiveFailAfterSuspend() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
    runtimeService.suspendProcessInstanceById(processInstance.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 13 with SuspendedEntityInteractionException

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

the class ProcessInstanceSuspensionTest method testTaskNonLifecycleOperationsSucceedAfterProcessInstanceSuspendByProcessDefinitionId.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTaskNonLifecycleOperationsSucceedAfterProcessInstanceSuspendByProcessDefinitionId() {
    // 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.suspendProcessInstanceByProcessDefinitionId(processInstance.getProcessDefinitionId());
    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 14 with SuspendedEntityInteractionException

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

the class ProcessInstanceSuspensionTest method testSubTaskCreationFailAfterProcessInstanceSuspend.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testSubTaskCreationFailAfterProcessInstanceSuspend() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
    final Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    runtimeService.suspendProcessInstanceById(processInstance.getId());
    Task subTask = taskService.newTask("someTaskId");
    subTask.setParentTaskId(task.getId());
    try {
        taskService.saveTask(subTask);
        fail("Creating sub tasks for suspended task should not be possible");
    } catch (SuspendedEntityInteractionException e) {
    }
}
Also used : ExternalTask(org.camunda.bpm.engine.externaltask.ExternalTask) Task(org.camunda.bpm.engine.task.Task) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) SuspendedEntityInteractionException(org.camunda.bpm.engine.SuspendedEntityInteractionException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 15 with SuspendedEntityInteractionException

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

the class ProcessInstanceSuspensionTest method testTaskNonLifecycleOperationsSucceedAfterProcessInstanceSuspend.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTaskNonLifecycleOperationsSucceedAfterProcessInstanceSuspend() {
    // 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.suspendProcessInstanceById(processInstance.getId());
    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)

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