Search in sources :

Example 11 with NotAllowedException

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

the class CaseServiceStageTest method testTerminateWithNonActiveState.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneStageCaseWithManualActivation.cmmn" })
public void testTerminateWithNonActiveState() {
    // given:
    // a deployed case definition
    String caseDefinitionId = repositoryService.createCaseDefinitionQuery().singleResult().getId();
    caseService.withCaseDefinition(caseDefinitionId).create().getId();
    CaseExecution stageExecution = queryCaseExecutionByActivityId("PI_Stage_1");
    // when
    try {
        // when
        caseService.terminateCaseExecution(stageExecution.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 12 with NotAllowedException

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

the class CaseServiceCaseTaskTest method testTerminateNonActiveCaseTask.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneCaseTaskCaseWithManualActivation.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testTerminateNonActiveCaseTask() {
    // given
    createCaseInstance(DEFINITION_KEY);
    CaseExecution caseTaskExecution = queryCaseExecutionByActivityId(CASE_TASK_KEY);
    try {
        // when
        caseService.terminateCaseExecution(caseTaskExecution.getId());
        fail("It should not be possible to terminate a case 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 13 with NotAllowedException

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

the class RequiredRuleTest method testRequiredRuleEvaluatesToTrue.

@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/required/RequiredRuleTest.testVariableBasedRule.cmmn")
public void testRequiredRuleEvaluatesToTrue() {
    CaseInstance caseInstance = caseService.createCaseInstanceByKey("case", Collections.<String, Object>singletonMap("required", true));
    CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
    assertNotNull(taskExecution);
    assertTrue(taskExecution.isRequired());
    try {
        caseService.completeCaseExecution(caseInstance.getId());
        fail("completing the containing stage should not be allowed");
    } catch (NotAllowedException e) {
    // happy path
    }
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 14 with NotAllowedException

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

the class RequiredRuleTest method testDefaultRequiredRuleEvaluatesToTrue.

@Deployment(resources = "org/camunda/bpm/engine/test/cmmn/required/RequiredRuleTest.testDefaultVariableBasedRule.cmmn")
public void testDefaultRequiredRuleEvaluatesToTrue() {
    CaseInstance caseInstance = caseService.createCaseInstanceByKey("case", Collections.<String, Object>singletonMap("required", true));
    CaseExecution taskExecution = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult();
    assertNotNull(taskExecution);
    assertTrue(taskExecution.isRequired());
    try {
        caseService.completeCaseExecution(caseInstance.getId());
        fail("completing the containing stage should not be allowed");
    } catch (NotAllowedException e) {
    // happy path
    }
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) CaseExecution(org.camunda.bpm.engine.runtime.CaseExecution) NotAllowedException(org.camunda.bpm.engine.exception.NotAllowedException) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 15 with NotAllowedException

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

the class SentryEntryCriteriaTest method testCycle.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/sentry/SentryEntryCriteriaTest.testCycle.cmmn" })
public void testCycle() {
    // given
    createCaseInstance();
    CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
    String firstHumanTaskId = firstHumanTask.getId();
    assertTrue(firstHumanTask.isAvailable());
    CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
    String secondHumanTaskId = secondHumanTask.getId();
    assertTrue(secondHumanTask.isAvailable());
    CaseExecution thirdHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_3");
    String thirdHumanTaskId = thirdHumanTask.getId();
    assertTrue(thirdHumanTask.isAvailable());
    try {
        // (1) when
        manualStart(firstHumanTaskId);
        fail("It should not be possible to start the first human task manually.");
    } catch (NotAllowedException e) {
    }
    try {
        // (2) when
        manualStart(secondHumanTaskId);
        fail("It should not be possible to start the second human task manually.");
    } catch (NotAllowedException e) {
    }
    try {
        // (3) when
        manualStart(thirdHumanTaskId);
        fail("It should not be possible to third the second human task manually.");
    } catch (NotAllowedException e) {
    }
}
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