Java Code Examples for org.camunda.bpm.engine.runtime.CaseExecution#getId()

The following examples show how to use org.camunda.bpm.engine.runtime.CaseExecution#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SentryExitCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryExitCriteriaTest.testExitCriteriaOnCasePlanModel.cmmn"})
public void testExitCriteriaOnCasePlanModel() {
  // given
  String caseInstanceId = createCaseInstance().getId();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();

  assertTrue(firstHumanTask.isActive());

  // when
  complete(firstHumanTaskId);

  // then
  CaseExecution caseInstance = queryCaseExecutionById(caseInstanceId);
  assertTrue(caseInstance.isTerminated());
}
 
Example 2
Source File: SentryVariableOnPartExitCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryVariableOnPartExitCriteriaTest.testExitTaskWithVariableOnPart.cmmn"})
public void testExitTaskWithVariableOnPartSatisfied() {
  // given
  createCaseInstance();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();
  assertTrue(firstHumanTask.isActive());

  CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
  String secondHumanTaskId = secondHumanTask.getId();
  assertTrue(secondHumanTask.isActive());

  // when
  caseService
    .withCaseExecution(firstHumanTaskId)
    .setVariable("variable_1", 100)
    .complete();

  // then
  firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
  assertNull(firstHumanTask);

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertNull(secondHumanTask);
}
 
Example 3
Source File: SentryEntryCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryEntryCriteriaTest.testSequenceAutoStartTask.cmmn"})
public void testSequenceAutoStartTask() {
  // given
  String caseInstanceId = createCaseInstance().getId();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();
  assertTrue(firstHumanTask.isActive());

  CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
  String secondHumanTaskId = secondHumanTask.getId();
  assertTrue(secondHumanTask.isAvailable());

  // (1) then
  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertTrue(secondHumanTask.isAvailable());

  assertNull(caseService.getVariable(caseInstanceId, "enable"));
  assertNull(caseService.getVariable(caseInstanceId, "start"));

  // (2) when
  complete(firstHumanTaskId);

  // (2) then
  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertTrue(secondHumanTask.isActive());

  assertNull(caseService.getVariable(caseInstanceId, "enable"));
  Object startVariable = caseService.getVariable(caseInstanceId, "start");
  assertNotNull(startVariable);
  assertTrue((Boolean) startVariable);
}
 
Example 4
Source File: DelegateVariableInstanceSpec.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static DelegateVariableInstanceSpec fromCaseExecution(CaseExecution caseExecution) {
  DelegateVariableInstanceSpec spec = new DelegateVariableInstanceSpec();
  spec.expectedCaseExecutionId = caseExecution.getId();
  spec.expectedCaseInstanceId = caseExecution.getCaseInstanceId();
  spec.expectedSourceExecution = caseExecution;
  return spec;
}
 
Example 5
Source File: SentryEntryCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * Please note that suspension and/or resuming is currently
 * not supported by the public API. Furthermore the given
 * test is not a very useful use case in that just a milestone
 * will be suspended.
 */
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryEntryCriteriaTest.testResume.cmmn"})
public void FAILING_testResume() {
  // given
  createCaseInstance();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();

  assertTrue(firstHumanTask.isEnabled());

  CaseExecution milestone = queryCaseExecutionByActivityId("PI_Milestone_1");
  String milestoneId = milestone.getId();

  assertTrue(milestone.isAvailable());

  suspend(milestoneId);

  // (1) when
  manualStart(firstHumanTaskId);
  complete(firstHumanTaskId);

  // (1) then
  firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
  assertNull(firstHumanTask);

  milestone = queryCaseExecutionById(milestoneId);
  assertTrue(((CaseExecutionEntity) milestone).isSuspended());

  // (2) when
  resume(milestoneId);

  // (2)
  milestone = queryCaseExecutionById(milestoneId);
  assertNull(milestone);

}
 
Example 6
Source File: SentryEntryCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryEntryCriteriaTest.testOrJoin.cmmn"})
public void testOrJoin() {
  // given
  String caseInstanceId = createCaseInstance().getId();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();
  assertTrue(firstHumanTask.isActive());

  CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
  String secondHumanTaskId = secondHumanTask.getId();
  assertTrue(secondHumanTask.isActive());

  CaseExecution thirdHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_3");
  String thirdHumanTaskId = thirdHumanTask.getId();
  assertTrue(thirdHumanTask.isAvailable());

  // (1) when
  complete(firstHumanTaskId);

  // (1) then
  thirdHumanTask = queryCaseExecutionById(thirdHumanTaskId);
  assertTrue(thirdHumanTask.isActive());

  Object startVariable = caseService.getVariable(caseInstanceId, "start");
  assertNotNull(startVariable);
  assertTrue((Boolean) startVariable);

  // (2) when
  complete(secondHumanTaskId);

  // (2) then
  thirdHumanTask = queryCaseExecutionById(thirdHumanTaskId);
  assertTrue(thirdHumanTask.isActive()); // is still active
}
 
Example 7
Source File: SentryEntryCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryEntryCriteriaTest.testOrFork.cmmn"})
public void testOrFork() {
  // given
  createCaseInstance();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();
  assertTrue(firstHumanTask.isActive());

  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());

  // when
  caseService
    .withCaseExecution(firstHumanTaskId)
    .setVariable("value", 80)
    .complete();

  // then
  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertTrue(secondHumanTask.isAvailable());

  thirdHumanTask = queryCaseExecutionById(thirdHumanTaskId);
  assertTrue(thirdHumanTask.isActive());

}
 
Example 8
Source File: SentryExitCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryExitCriteriaTest.testExitTaskWithIfPart.cmmn"})
public void testExitTaskWithIfPartSatisfied() {
  // given
  createCaseInstance();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();
  assertTrue(firstHumanTask.isActive());

  CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
  String secondHumanTaskId = secondHumanTask.getId();
  assertTrue(secondHumanTask.isActive());

  // when
  caseService
    .withCaseExecution(firstHumanTaskId)
    .setVariable("value", 100)
    .complete();

  // then
  firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
  assertNull(firstHumanTask);

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertNull(secondHumanTask);

}
 
Example 9
Source File: VariableListenerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources={
    "org/camunda/bpm/engine/test/cmmn/listener/VariableListenerTest.testVariableListenerWithProcessTask.cmmn",
    "org/camunda/bpm/engine/test/cmmn/listener/VariableListenerTest.testVariableListenerWithProcessTask.bpmn20.xml"
    })
public void testVariableListenerWithProcessTask() {
  CaseInstance caseInstance = caseService.createCaseInstanceByKey("case");

  CaseExecution processTask = caseService
      .createCaseExecutionQuery()
      .activityId("PI_ProcessTask_1")
      .singleResult();

  String processTaskId = processTask.getId();

  caseService
    .withCaseExecution(processTaskId)
    .manualStart();

  // then the listener is invoked
  assertEquals(1, LogVariableListener.getInvocations().size());

  DelegateVariableInstanceSpec
    .fromCaseExecution(caseInstance)
    .sourceExecution(processTask)
    .event(VariableListener.CREATE)
    .name("aVariable")
    .value("aValue")
    .matches(LogVariableListener.getInvocations().get(0));

  LogVariableListener.reset();
}
 
Example 10
Source File: SentryEntryCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryEntryCriteriaTest.testSequenceWithIfPart.cmmn"})
public void testSequenceWithIfPartNotSatisfied() {
  // given
  createCaseInstance();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();
  assertTrue(firstHumanTask.isActive());

  CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
  String secondHumanTaskId = secondHumanTask.getId();
  assertTrue(secondHumanTask.isAvailable());

  // when
  caseService
    .withCaseExecution(firstHumanTaskId)
    .setVariable("value", 99)
    .complete();

  // then
  firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
  assertNull(firstHumanTask);

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertTrue(secondHumanTask.isAvailable());

}
 
Example 11
Source File: SentryEntryCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryEntryCriteriaTest.testSequenceEnableStage.cmmn"})
public void testSequenceEnableStage() {
  // given
  String caseInstanceId = createCaseInstance().getId();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();
  assertTrue(firstHumanTask.isActive());

  CaseExecution stage = queryCaseExecutionByActivityId("PI_Stage_1");
  String stageId = stage.getId();
  assertTrue(stage.isAvailable());

  // (1) then
  stage = queryCaseExecutionById(stageId);
  assertTrue(stage.isAvailable());

  assertNull(caseService.getVariable(caseInstanceId, "enable"));

  // (2) when
  complete(firstHumanTaskId);

  // (2) then
  stage = queryCaseExecutionById(stageId);
  assertTrue(stage.isEnabled());

  Object enableVariable = caseService.getVariable(caseInstanceId, "enable");
  assertNotNull(enableVariable);
  assertTrue((Boolean) enableVariable);

}
 
Example 12
Source File: SentryExitCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryExitCriteriaTest.testOrJoin.cmmn"})
public void testOrJoin() {
  // given
  String caseInstanceId = createCaseInstance().getId();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();
  assertTrue(firstHumanTask.isActive());

  CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
  String secondHumanTaskId = secondHumanTask.getId();
  assertTrue(secondHumanTask.isActive());

  CaseExecution thirdHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_3");
  String thirdHumanTaskId = thirdHumanTask.getId();
  assertTrue(thirdHumanTask.isActive());

  // (1) when
  complete(firstHumanTaskId);

  // (1) then
  thirdHumanTask = queryCaseExecutionById(thirdHumanTaskId);
  assertNull(thirdHumanTask);

  Object exitVariable = caseService.getVariable(caseInstanceId, "exit");
  assertNotNull(exitVariable);
  assertTrue((Boolean) exitVariable);

  // (2) when
  complete(secondHumanTaskId);

  // (2) then
  thirdHumanTask = queryCaseExecutionById(thirdHumanTaskId);
  assertNull(thirdHumanTask);
}
 
Example 13
Source File: SentryExitCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryExitCriteriaTest.testExitActiveTask.cmmn"})
public void testExitActiveTask() {
  // given
  createCaseInstance();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();

  assertTrue(firstHumanTask.isEnabled());

  CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
  String secondHumanTaskId = secondHumanTask.getId();

  assertTrue(secondHumanTask.isEnabled());

  manualStart(secondHumanTaskId);

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertTrue(secondHumanTask.isActive());

  Task secondTask = taskService
      .createTaskQuery()
      .singleResult();
  assertNotNull(secondTask);

  // when
  manualStart(firstHumanTaskId);

  // then
  firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
  assertTrue(firstHumanTask.isActive());

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertNull(secondHumanTask);

  secondTask = taskService
      .createTaskQuery()
      .taskId(secondTask.getId())
      .singleResult();
  assertNull(secondTask);

}
 
Example 14
Source File: SentryExitCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryExitCriteriaTest.testExitStage.cmmn"})
public void testExitStage() {
  // given
  String caseInstanceId = createCaseInstance().getId();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();
  assertTrue(firstHumanTask.isActive());

  CaseExecution stage = queryCaseExecutionByActivityId("PI_Stage_1");
  String stageId = stage.getId();
  assertTrue(stage.isActive());

  stage = queryCaseExecutionById(stageId);
  assertTrue(stage.isActive());

  CaseExecution milestone = queryCaseExecutionByActivityId("PI_Milestone_1");
  String milestoneId = milestone.getId();
  assertTrue(milestone.isAvailable());

  CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
  String secondHumanTaskId = secondHumanTask.getId();
  assertTrue(secondHumanTask.isActive());

  // (2) then
  stage = queryCaseExecutionById(stageId);
  assertTrue(stage.isActive());

  assertNull(caseService.getVariable(caseInstanceId, "exit"));
  assertNull(caseService.getVariable(caseInstanceId, "parentTerminate"));

  // (2) when
  complete(firstHumanTaskId);

  // (2) then
  stage = queryCaseExecutionById(stageId);
  assertNull(stage);

  milestone = queryCaseExecutionById(milestoneId);
  assertNull(milestone);

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertNull(secondHumanTask);

  Object exitVariable = caseService.getVariable(caseInstanceId, "exit");
  assertNotNull(exitVariable);
  assertTrue((Boolean) exitVariable);

  Object parentTerminateVariable = caseService.getVariable(caseInstanceId, "parentTerminate");
  assertNotNull(parentTerminateVariable);
  assertTrue((Boolean) parentTerminateVariable);

}
 
Example 15
Source File: SentryEntryCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryEntryCriteriaTest.testSequenceAutoStartStage.cmmn"})
public void testSequenceAutoStartStage() {
  // given
  String caseInstanceId = createCaseInstance().getId();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();
  assertTrue(firstHumanTask.isActive());

  CaseExecution stage = queryCaseExecutionByActivityId("PI_Stage_1");
  String stageId = stage.getId();
  assertTrue(stage.isAvailable());

  // (1) then
  stage = queryCaseExecutionById(stageId);
  assertTrue(stage.isAvailable());

  assertNull(caseService.getVariable(caseInstanceId, "enable"));
  assertNull(caseService.getVariable(caseInstanceId, "start"));

  // (2) when
  complete(firstHumanTaskId);

  // (2) then
  stage = queryCaseExecutionById(stageId);
  assertTrue(stage.isActive());

  assertNull(caseService.getVariable(caseInstanceId, "enable"));
  Object startVariable = caseService.getVariable(caseInstanceId, "start");
  assertNotNull(startVariable);
  assertTrue((Boolean) startVariable);

  CaseExecutionQuery query = caseService
    .createCaseExecutionQuery()
    .enabled();

  assertEquals(2, query.count());

  for (CaseExecution child : query.list()) {
    assertEquals(stageId, child.getParentId());
  }

}
 
Example 16
Source File: SentryEntryCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryEntryCriteriaTest.testEnableOnParentSuspendInsideStage.cmmn"})
public void FAILING_testEnableOnParentSuspendInsideStage() {
  // given
  createCaseInstance();

  CaseExecution stage = queryCaseExecutionByActivityId("PI_Stage_1");
  String stageId = stage.getId();

  manualStart(stageId);

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();

  assertTrue(firstHumanTask.isEnabled());

  CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
  String secondHumanTaskId = secondHumanTask.getId();

  assertTrue(secondHumanTask.isAvailable());

  // (1) when
  suspend(stageId);

  // (1) then
  stage = queryCaseExecutionById(stageId);
  assertTrue(((CaseExecutionEntity)stage).isSuspended());

  firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
  assertTrue(((CaseExecutionEntity)firstHumanTask).isSuspended());

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertTrue(((CaseExecutionEntity)secondHumanTask).isSuspended());
  assertEquals(CaseExecutionState.ENABLED, ((CaseExecutionEntity)secondHumanTask).getPreviousState());

  // (2) when
  resume(stageId);

  // (2) then
  stage = queryCaseExecutionById(stageId);
  assertTrue(stage.isActive());

  firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
  assertTrue(firstHumanTask.isEnabled());

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertTrue(secondHumanTask.isEnabled());
}
 
Example 17
Source File: SentryEntryCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryEntryCriteriaTest.testEnableOnParentResumeInsideStage.cmmn"})
public void FAILING_testEnableOnParentResumeInsideStage() {
  // given
  createCaseInstance();

  CaseExecution stage = queryCaseExecutionByActivityId("PI_Stage_1");
  String stageId = stage.getId();

  manualStart(stageId);

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();

  assertTrue(firstHumanTask.isEnabled());

  CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
  String secondHumanTaskId = secondHumanTask.getId();

  assertTrue(secondHumanTask.isAvailable());

  // (1) when
  suspend(stageId);

  // (1) then
  stage = queryCaseExecutionById(stageId);
  assertTrue(((CaseExecutionEntity)stage).isSuspended());

  firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
  assertTrue(((CaseExecutionEntity)firstHumanTask).isSuspended());

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertTrue(((CaseExecutionEntity)secondHumanTask).isSuspended());
  assertEquals(CaseExecutionState.AVAILABLE, ((CaseExecutionEntity)secondHumanTask).getPreviousState());

  // (2) when
  resume(stageId);

  // (2) then
  stage = queryCaseExecutionById(stageId);
  assertTrue(stage.isActive());

  firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
  assertTrue(firstHumanTask.isEnabled());

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertTrue(secondHumanTask.isEnabled());
}
 
Example 18
Source File: SentryEntryCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryEntryCriteriaTest.testFireAlsoNotAffectedSentries.cmmn"})
public void testFireAlsoNotAffectedSentries() {
  // given
  String caseInstanceId = createCaseInstance().getId();

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();

  assertTrue(firstHumanTask.isActive());

  CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
  String secondHumanTaskId = secondHumanTask.getId();

  assertTrue(secondHumanTask.isAvailable());

  CaseExecution milestone = queryCaseExecutionByActivityId("PI_Milestone_1");
  String milestoneId = milestone.getId();

  assertTrue(milestone.isAvailable());

  caseService
    .withCaseExecution(caseInstanceId)
    .setVariable("value", 99)
    .execute();

  // (1) when
  complete(firstHumanTaskId);

  // (1) then
  firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
  assertNull(firstHumanTask);

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertTrue(secondHumanTask.isAvailable());

  // (2) when
  caseService
    .withCaseExecution(caseInstanceId)
    .setVariable("value", 101)
    .execute();

  // (2) then
  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertTrue(secondHumanTask.isActive());

  milestone = queryCaseExecutionById(milestoneId);
  // milestone occurs when the sentry was evaluated successfully after value is set to 101
  assertNull(milestone);
}
 
Example 19
Source File: SentryCombinedEntryAndExitCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 2 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryCombinedEntryAndExitCriteriaTest.testParentSuspendInsideStage.cmmn"})
public void FAILING_testParentSuspendInsideStage() {
  // given
  createCaseInstance();

  CaseExecution stage = queryCaseExecutionByActivityId("PI_Stage_1");
  String stageId = stage.getId();

  manualStart(stageId);

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();

  assertTrue(firstHumanTask.isEnabled());

  CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
  String secondHumanTaskId = secondHumanTask.getId();

  assertTrue(secondHumanTask.isEnabled());

  CaseExecution thirdHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_3");
  String thirdHumanTaskId = thirdHumanTask.getId();

  assertTrue(thirdHumanTask.isAvailable());

  // when
  suspend(stageId);

  // then
  stage = queryCaseExecutionById(stageId);
  assertTrue(((CaseExecutionEntity)stage).isSuspended());

  firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
  assertTrue(((CaseExecutionEntity)firstHumanTask).isSuspended());

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertNull(secondHumanTask);

  thirdHumanTask = queryCaseExecutionById(thirdHumanTaskId);
  assertTrue(((CaseExecutionEntity)thirdHumanTask).isSuspended());
  assertEquals(CaseExecutionState.ENABLED, ((CaseExecutionEntity) thirdHumanTask).getPreviousState());

}
 
Example 20
Source File: SentryCombinedEntryAndExitCriteriaTest.java    From camunda-bpm-platform with Apache License 2.0 2 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/sentry/SentryCombinedEntryAndExitCriteriaTest.testParentResumeInsideStage.cmmn"})
public void FAILING_testParentResumeInsideStage() {
  // given
  createCaseInstance();

  CaseExecution stage = queryCaseExecutionByActivityId("PI_Stage_1");
  String stageId = stage.getId();

  manualStart(stageId);

  CaseExecution firstHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_1");
  String firstHumanTaskId = firstHumanTask.getId();

  assertTrue(firstHumanTask.isEnabled());

  CaseExecution secondHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_2");
  String secondHumanTaskId = secondHumanTask.getId();

  assertTrue(secondHumanTask.isEnabled());

  CaseExecution thirdHumanTask = queryCaseExecutionByActivityId("PI_HumanTask_3");
  String thirdHumanTaskId = thirdHumanTask.getId();

  assertTrue(thirdHumanTask.isAvailable());

  // (1) when
  suspend(stageId);

  // (1) then
  stage = queryCaseExecutionById(stageId);
  assertTrue(((CaseExecutionEntity)stage).isSuspended());

  firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
  assertTrue(((CaseExecutionEntity)firstHumanTask).isSuspended());

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertTrue(((CaseExecutionEntity)secondHumanTask).isSuspended());

  thirdHumanTask = queryCaseExecutionById(thirdHumanTaskId);
  assertTrue(((CaseExecutionEntity)thirdHumanTask).isSuspended());

  // (2) when
  resume(stageId);

  // (2) then
  stage = queryCaseExecutionById(stageId);
  assertTrue(stage.isActive());

  firstHumanTask = queryCaseExecutionById(firstHumanTaskId);
  assertTrue(firstHumanTask.isEnabled());

  secondHumanTask = queryCaseExecutionById(secondHumanTaskId);
  assertNull(secondHumanTask);

  thirdHumanTask = queryCaseExecutionById(thirdHumanTaskId);
  assertTrue(thirdHumanTask.isEnabled());

}