Search in sources :

Example 6 with NotAllowedException

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

the class CaseServiceHumanTaskTest method testTerminateNonActiveHumanTask.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testTerminateNonActiveHumanTask() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    caseService.withCaseDefinition(caseDefinitionId).create();
    CaseExecution taskExecution = queryCaseExecutionByActivityId("PI_HumanTask_1");
    try {
        // when
        caseService.terminateCaseExecution(taskExecution.getId());
        fail("It should not be possible to terminate a task.");
    } catch (NotAllowedException e) {
        boolean result = e.getMessage().contains("The case execution must be in state 'active' to terminate");
        assertTrue(result);
    }
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 7 with NotAllowedException

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

the class CaseServiceHumanTaskTest method testDisableADisabledHumanTask.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/twoTaskCase.cmmn" })
public void testDisableADisabledHumanTask() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    caseService.withCaseDefinition(caseDefinitionId).create();
    CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery();
    String caseExecutionId = caseExecutionQuery.activityId("PI_HumanTask_1").singleResult().getId();
    // the human task is disabled
    caseService.withCaseExecution(caseExecutionId).disable();
    try {
        // when
        caseService.withCaseExecution(caseExecutionId).disable();
        fail("It should not be possible to disable a already disabled human task.");
    } catch (NotAllowedException e) {
    }
}
Also used : NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 8 with NotAllowedException

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

the class CaseServiceProcessTaskTest method testReenableAnEnabledProcessTask.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCaseWithManualActivation.cmmn" })
public void testReenableAnEnabledProcessTask() {
    // given
    createCaseInstance(DEFINITION_KEY);
    String processTaskId = queryCaseExecutionByActivityId(PROCESS_TASK_KEY).getId();
    ProcessInstance processInstance = queryProcessInstance();
    assertNull(processInstance);
    try {
        // when
        caseService.withCaseExecution(processTaskId).reenable();
        fail("It should not be possible to re-enable an enabled process task.");
    } catch (NotAllowedException e) {
    }
}
Also used : NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 9 with NotAllowedException

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

the class CaseServiceProcessTaskTest method testTerminateNonActiveProcessTask.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTerminateNonActiveProcessTask() {
    // given
    createCaseInstance(DEFINITION_KEY);
    CaseExecution processTask = queryCaseExecutionByActivityId(PROCESS_TASK_KEY);
    assertTrue(processTask.isEnabled());
    try {
        // when
        caseService.terminateCaseExecution(processTask.getId());
        fail("It should not be possible to terminate a task.");
    } catch (NotAllowedException e) {
        boolean result = e.getMessage().contains("The case execution must be in state 'active' to terminate");
        assertTrue(result);
    }
}
Also used : CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 10 with NotAllowedException

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

the class CaseServiceStageTest method testDisableADisabledStage.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskAndOneStageWithManualActivationCase.cmmn" })
public void testDisableADisabledStage() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    // an active case instance
    caseService.withCaseDefinition(caseDefinitionId).create();
    CaseExecutionQuery caseExecutionQuery = caseService.createCaseExecutionQuery();
    String caseExecutionId = caseExecutionQuery.activityId("PI_Stage_1").singleResult().getId();
    // the human task is disabled
    caseService.withCaseExecution(caseExecutionId).disable();
    try {
        // when
        caseService.withCaseExecution(caseExecutionId).disable();
        fail("It should not be possible to disable a already disabled human task.");
    } catch (NotAllowedException e) {
    }
}
Also used : NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) CaseExecutionQuery(org.camunda.bpm.engine.runtime.CaseExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

NotAllowedException (org.camunda.bpm.engine.exception.NotAllowedException)22 Deployment (org.camunda.bpm.engine.test.Deployment)13 CaseService (org.camunda.bpm.engine.CaseService)9 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)9 NotFoundException (org.camunda.bpm.engine.exception.NotFoundException)9 NotValidException (org.camunda.bpm.engine.exception.NotValidException)9 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)9 CaseExecutionCommandBuilder (org.camunda.bpm.engine.runtime.CaseExecutionCommandBuilder)8 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)5 CaseExecutionQuery (org.camunda.bpm.engine.runtime.CaseExecutionQuery)2 URI (java.net.URI)1 CaseInstanceDto (org.camunda.bpm.engine.rest.dto.runtime.CaseInstanceDto)1 CreateCaseInstanceDto (org.camunda.bpm.engine.rest.dto.runtime.CreateCaseInstanceDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 RestException (org.camunda.bpm.engine.rest.exception.RestException)1 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)1 VariableMap (org.camunda.bpm.engine.variable.VariableMap)1