use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testCancelNonExistingActivityInstance.
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testCancelNonExistingActivityInstance() {
// given
ProcessInstance instance = runtimeService.startProcessInstanceByKey("exclusiveGateway");
// when - then throw exception
try {
runtimeService.createProcessInstanceModification(instance.getId()).cancelActivityInstance("nonExistingActivityInstance").execute();
fail("should not succeed");
} catch (NotValidException e) {
assertTextPresent("Cannot perform instruction: Cancel activity instance 'nonExistingActivityInstance'; " + "Activity instance 'nonExistingActivityInstance' does not exist", e.getMessage());
}
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testCancelNonExistingTranisitionInstance.
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testCancelNonExistingTranisitionInstance() {
// given
ProcessInstance instance = runtimeService.startProcessInstanceByKey("exclusiveGateway");
// when - then throw exception
try {
runtimeService.createProcessInstanceModification(instance.getId()).cancelTransitionInstance("nonExistingActivityInstance").execute();
fail("should not succeed");
} catch (NotValidException e) {
assertTextPresent("Cannot perform instruction: Cancel transition instance 'nonExistingActivityInstance'; " + "Transition instance 'nonExistingActivityInstance' does not exist", e.getMessage());
}
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testStartTransitionWithInvalidAncestorInstanceId.
@Deployment(resources = DOUBLE_NESTED_SUB_PROCESS)
public void testStartTransitionWithInvalidAncestorInstanceId() {
// given two instances of the outer subprocess
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("doubleNestedSubprocess");
String processInstanceId = processInstance.getId();
try {
runtimeService.createProcessInstanceModification(processInstance.getId()).startTransition("flow5", "noValidActivityInstanceId").execute();
fail();
} catch (NotValidException e) {
// happy path
assertTextPresent("Cannot perform instruction: " + "Start transition 'flow5' with ancestor activity instance 'noValidActivityInstanceId'; " + "Ancestor activity instance 'noValidActivityInstanceId' does not exist", e.getMessage());
}
try {
runtimeService.createProcessInstanceModification(processInstance.getId()).startTransition("flow5", null).execute();
fail();
} catch (NotValidException e) {
// happy path
assertTextPresent("ancestorActivityInstanceId is null", e.getMessage());
}
ActivityInstance tree = runtimeService.getActivityInstance(processInstanceId);
String subProcessTaskId = getInstanceIdForActivity(tree, "subProcessTask");
try {
runtimeService.createProcessInstanceModification(processInstance.getId()).startTransition("flow5", subProcessTaskId).execute();
fail("should not succeed because subProcessTask is a child of subProcess");
} catch (NotValidException e) {
// happy path
assertTextPresent("Cannot perform instruction: " + "Start transition 'flow5' with ancestor activity instance '" + subProcessTaskId + "'; " + "Scope execution for '" + subProcessTaskId + "' cannot be found in parent hierarchy of flow element 'flow5'", e.getMessage());
}
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testStartAfterNonExistingActivity.
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testStartAfterNonExistingActivity() {
// given
ProcessInstance instance = runtimeService.startProcessInstanceByKey("exclusiveGateway");
try {
// when
runtimeService.createProcessInstanceModification(instance.getId()).startAfterActivity("someNonExistingActivity").execute();
fail("should not succeed");
} catch (NotValidException e) {
// then
assertTextPresentIgnoreCase("Cannot perform instruction: " + "Start after activity 'someNonExistingActivity'; " + "Activity 'someNonExistingActivity' does not exist: activity is null", e.getMessage());
}
}
use of org.camunda.bpm.engine.exception.NotValidException in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testStartAfterWithInvalidAncestorInstanceId.
@Deployment(resources = DOUBLE_NESTED_SUB_PROCESS)
public void testStartAfterWithInvalidAncestorInstanceId() {
// given two instances of the outer subprocess
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("doubleNestedSubprocess");
String processInstanceId = processInstance.getId();
try {
runtimeService.createProcessInstanceModification(processInstance.getId()).startAfterActivity("innerSubProcessStart", "noValidActivityInstanceId").execute();
fail();
} catch (NotValidException e) {
// happy path
assertTextPresent("Cannot perform instruction: " + "Start after activity 'innerSubProcessStart' with ancestor activity instance 'noValidActivityInstanceId'; " + "Ancestor activity instance 'noValidActivityInstanceId' does not exist", e.getMessage());
}
try {
runtimeService.createProcessInstanceModification(processInstance.getId()).startAfterActivity("innerSubProcessStart", null).execute();
fail();
} catch (NotValidException e) {
// happy path
assertTextPresent("ancestorActivityInstanceId is null", e.getMessage());
}
ActivityInstance tree = runtimeService.getActivityInstance(processInstanceId);
String subProcessTaskId = getInstanceIdForActivity(tree, "subProcessTask");
try {
runtimeService.createProcessInstanceModification(processInstance.getId()).startAfterActivity("innerSubProcessStart", subProcessTaskId).execute();
fail("should not succeed because subProcessTask is a child of subProcess");
} catch (NotValidException e) {
// happy path
assertTextPresent("Cannot perform instruction: " + "Start after activity 'innerSubProcessStart' with ancestor activity instance '" + subProcessTaskId + "'; " + "Scope execution for '" + subProcessTaskId + "' cannot be found in parent hierarchy of flow element 'flow5'", e.getMessage());
}
}
Aggregations