Search in sources :

Example 21 with NotValidException

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());
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 22 with NotValidException

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());
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 23 with NotValidException

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());
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 24 with NotValidException

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());
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 25 with NotValidException

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());
    }
}
Also used : NotValidException(org.camunda.bpm.engine.exception.NotValidException) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

NotValidException (org.camunda.bpm.engine.exception.NotValidException)121 Test (org.junit.Test)28 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)24 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)24 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)18 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)17 Deployment (org.camunda.bpm.engine.test.Deployment)12 CaseDefinitionQuery (org.camunda.bpm.engine.repository.CaseDefinitionQuery)10 DecisionDefinitionQuery (org.camunda.bpm.engine.repository.DecisionDefinitionQuery)10 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)10 CaseService (org.camunda.bpm.engine.CaseService)9 NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)9 RestException (org.camunda.bpm.engine.rest.exception.RestException)8 CaseExecutionCommandBuilder (org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder)8 CaseInstanceQuery (org.camunda.bpm.engine.runtime.CaseInstanceQuery)8 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)6 HashMap (java.util.HashMap)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 InputStream (java.io.InputStream)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3