Java Code Examples for org.camunda.bpm.engine.CaseService#createCaseInstanceByKey()

The following examples show how to use org.camunda.bpm.engine.CaseService#createCaseInstanceByKey() . 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: CaseInstanceFakeTest.java    From camunda-bpm-mockito with Apache License 2.0 6 votes vote down vote up
@Test
public void prepare_with_service_mock() {
  CaseService caseService = mock(CaseService.class);
  String uuid = UUID.randomUUID().toString();
  String businessKey = "12";

  AtomicReference<CaseInstanceFake> reference = CaseInstanceFake.prepareMock(caseService, uuid);

  assertThat(reference.get()).isNull();

  CaseInstance instance = caseService.createCaseInstanceByKey("case", businessKey, Variables.putValue("foo", "bar"));
  assertThat(reference.get()).isNotNull();
  assertThat(instance.getCaseInstanceId()).isEqualTo(uuid);

  assertThat(caseService.getVariable(uuid, "foo")).isEqualTo("bar");

  caseService.setVariable(uuid, "hello", 456);
  assertThat(caseService.getVariable(uuid, "hello")).isEqualTo(456);

  assertThat(caseService.createCaseInstanceQuery().singleResult()).isEqualTo(reference.get());
}
 
Example 2
Source File: SentryScenario.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@DescribesScenario("triggerStageEntryCriterion")
public static ScenarioSetup completeStage() {
  return new ScenarioSetup() {
    public void execute(ProcessEngine engine, String scenarioName) {
      CaseService caseService = engine.getCaseService();
      CaseInstance caseInstance = caseService.createCaseInstanceByKey("case", scenarioName);
      String caseInstanceId = caseInstance.getId();
      
      CaseExecutionQuery query = caseService.createCaseExecutionQuery().caseInstanceId(caseInstanceId);

      String firstHumanTaskId = query.activityId("PI_HumanTask_1").singleResult().getId();
      caseService.manuallyStartCaseExecution(firstHumanTaskId);
      caseService.completeCaseExecution(firstHumanTaskId);

      String secondHumanTaskId = query.activityId("PI_HumanTask_2").singleResult().getId();
      caseService.manuallyStartCaseExecution(secondHumanTaskId);
    }
  };
}
 
Example 3
Source File: SentryScenario.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@DescribesScenario("newSentryInstance")
public static ScenarioSetup newSentryInstance() {
  return new ScenarioSetup() {
    public void execute(ProcessEngine engine, String scenarioName) {
      CaseService caseService = engine.getCaseService();
      CaseInstance caseInstance = caseService.createCaseInstanceByKey("case", scenarioName);
      String caseInstanceId = caseInstance.getId();
      
      CaseExecutionQuery query = caseService.createCaseExecutionQuery().caseInstanceId(caseInstanceId);

      String firstHumanTaskId = query.activityId("PI_HumanTask_1").singleResult().getId();
      caseService.manuallyStartCaseExecution(firstHumanTaskId);
      caseService.completeCaseExecution(firstHumanTaskId);

      String secondHumanTaskId = query.activityId("PI_HumanTask_2").singleResult().getId();
      caseService.manuallyStartCaseExecution(secondHumanTaskId);
      caseService.completeCaseExecution(secondHumanTaskId);
    }
  };
}
 
Example 4
Source File: CaseTest.java    From camunda-bpm-reactor with Apache License 2.0 5 votes vote down vote up
@Test
public void assigneToMe() {
  CaseService caseService = processEngine().getCaseService();
  CaseInstance caseInstance = caseService.createCaseInstanceByKey("Case");

  Task task = taskService().createTaskQuery().caseInstanceId(caseInstance.getId()).singleResult();
  assertThat(task).isAssignedTo("me");

  CaseExecution caseExecution = caseService.createCaseExecutionQuery().activityId("_ab60407c-449e-4048-ba9c-01bb59f2f095").singleResult();
  caseService.completeCaseExecution(caseExecution.getId());
}
 
Example 5
Source File: SentryScenario.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@DescribesScenario("triggerTaskEntryCriterion")
public static ScenarioSetup triggerEntryCriterion() {
  return new ScenarioSetup() {
    public void execute(ProcessEngine engine, String scenarioName) {
      CaseService caseService = engine.getCaseService();
      caseService.createCaseInstanceByKey("case", scenarioName);
    }
  };
}
 
Example 6
Source File: SentryScenario.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@DescribesScenario("completeInstance")
public static ScenarioSetup completeInstance() {
  return new ScenarioSetup() {
    public void execute(ProcessEngine engine, String scenarioName) {
      CaseService caseService = engine.getCaseService();
      caseService.createCaseInstanceByKey("case", scenarioName);
    }
  };
}