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);
}
}
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());
}
}
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");
}
}
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) {
}
}
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");
}
}
Aggregations