use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testSuspendAlreadySuspendedProcessInstance.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testSuspendAlreadySuspendedProcessInstance() {
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());
processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertTrue(processInstance.isSuspended());
} catch (ProcessEngineException e) {
fail("Should not fail");
}
try {
runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinition.getId());
processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertTrue(processInstance.isSuspended());
} catch (ProcessEngineException e) {
fail("Should not fail");
}
try {
runtimeService.suspendProcessInstanceByProcessDefinitionKey(processDefinition.getKey());
processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertTrue(processInstance.isSuspended());
} catch (ProcessEngineException e) {
fail("Should not fail");
}
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testSubmitTaskFormFailAfterProcessInstanceSuspendByProcessDefinitionId.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testSubmitTaskFormFailAfterProcessInstanceSuspendByProcessDefinitionId() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinition.getId());
try {
formService.submitTaskFormData(taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getId(), new HashMap<String, String>());
fail();
} catch (SuspendedEntityInteractionException e) {
// This is expected
}
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testProcessInstanceSignalFailAfterSuspendByProcessDefinitionKey.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testProcessInstanceSignalFailAfterSuspendByProcessDefinitionKey() {
// Suspend process instance
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
runtimeService.suspendProcessInstanceByProcessDefinitionKey(processDefinition.getKey());
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.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testMessageEventReceiveFailAfterSuspendByProcessDefinitionKey.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/ProcessInstanceSuspensionTest.testMessageEventReceiveFailAfterSuspend.bpmn20.xml" })
public void testMessageEventReceiveFailAfterSuspendByProcessDefinitionKey() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
runtimeService.startProcessInstanceById(processDefinition.getId());
runtimeService.suspendProcessInstanceByProcessDefinitionKey(processDefinition.getKey());
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.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testSuspendActivateProcessInstanceByProcessDefinitionKey.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testSuspendActivateProcessInstanceByProcessDefinitionKey() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
runtimeService.startProcessInstanceByKey(processDefinition.getKey());
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertFalse(processInstance.isSuspended());
// suspend
runtimeService.suspendProcessInstanceByProcessDefinitionKey(processDefinition.getKey());
processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertTrue(processInstance.isSuspended());
// activate
runtimeService.activateProcessInstanceByProcessDefinitionKey(processDefinition.getKey());
processInstance = runtimeService.createProcessInstanceQuery().singleResult();
assertFalse(processInstance.isSuspended());
}
Aggregations