Search in sources :

Example 21 with NotAllowedException

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

the class CaseServiceCaseTaskTest method testReenableAnEnabledCaseTask.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCaseWithManualActivation.cmmn" })
public void testReenableAnEnabledCaseTask() {
    // given
    createCaseInstance(DEFINITION_KEY);
    String caseTaskId = queryCaseExecutionByActivityId(CASE_TASK_KEY).getId();
    CaseInstance subCaseInstance = queryCaseInstanceByKey(DEFINITION_KEY_2);
    assertNull(subCaseInstance);
    try {
        // when
        caseService.withCaseExecution(caseTaskId).reenable();
        fail("It should not be possible to re-enable an enabled case task.");
    } catch (NotAllowedException e) {
    }
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 22 with NotAllowedException

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

the class CaseServiceCaseInstanceTest method testTerminateNonActiveCaseInstance.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testTerminateNonActiveCaseInstance() {
    // given:
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    String caseInstanceId = caseService.withCaseDefinition(caseDefinitionId).create().getId();
    assertNotNull(queryCaseExecutionByActivityId("CasePlanModel_1"));
    CaseExecution taskExecution = queryCaseExecutionByActivityId("PI_HumanTask_1");
    assertTrue(taskExecution.isEnabled());
    caseService.completeCaseExecution(caseInstanceId);
    try {
        // when
        caseService.terminateCaseExecution(caseInstanceId);
        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)

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