org.camunda.bpm.model.bpmn.Bpmn Java Examples

The following examples show how to use org.camunda.bpm.model.bpmn.Bpmn. 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: BoundedNumberOfMaxResultsTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldReturnResultInsideJavaDelegate() {
  // given
  BpmnModelInstance process = Bpmn.createExecutableProcess("process")
      .startEvent("startEvent")
      .serviceTask()
        .camundaClass(BoundedNumberOfMaxResultsDelegate.class)
      .endEvent()
      .done();

  testHelper.deploy(process);

  try {
    // when
    runtimeService.startProcessInstanceByKey("process");

    // then: should not fail
  } catch (BadUserRequestException e) {
    fail("Should not throw exception inside command!");
  }
}
 
Example #2
Source File: ProcessDataLoggingContextTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@WatchLogger(loggerNames = PVM_LOGGER, level = "DEBUG")
public void shouldLogMdcPropertiesForAsyncBeforeInTaskContext() {
  // given
  manageDeployment(Bpmn.createExecutableProcess(PROCESS)
      .startEvent("start")
      .userTask("waitState").camundaAsyncBefore()
      .endEvent("end")
      .done());
  // when
  ProcessInstance pi = runtimeService.startProcessInstanceByKey(PROCESS, B_KEY);
  testRule.waitForJobExecutorToProcessAllJobs();
  taskService.complete(taskService.createTaskQuery().singleResult().getId());
  // then
  assertActivityLogsPresent(pi, Arrays.asList("start", "waitState", "end"));
}
 
Example #3
Source File: TransientVariableTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * CAM-9932
 */
@Test
public void testKeepTransientIfUntypedValueIsAccessed() {
  // given
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("aProcess")
    .startEvent()
    .serviceTask()
      .camundaClass(ReadTypedTransientVariableDelegate.class)
    .userTask()
    .endEvent()
    .done();
  testRule.deploy(modelInstance);

  // when
  String processInstanceId = runtimeService.startProcessInstanceByKey("aProcess").getId();

  // then
  Object value = runtimeService.getVariable(processInstanceId, "var");
  assertThat(value).isNull();
}
 
Example #4
Source File: DiGeneratorForFlowNodesTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldGenerateShapeForBoundaryIntermediateEvent() {

  // given
  ProcessBuilder processBuilder = Bpmn.createExecutableProcess();

  // when
  instance = processBuilder
                .startEvent(START_EVENT_ID)
                .userTask(USER_TASK_ID)
                .endEvent(END_EVENT_ID)
                  .moveToActivity(USER_TASK_ID)
                    .boundaryEvent(BOUNDARY_ID)
                      .conditionalEventDefinition(CONDITION_ID)
                        .condition(TEST_CONDITION)
                      .conditionalEventDefinitionDone()
                    .endEvent()
               .done();

  // then
  Collection<BpmnShape> allShapes = instance.getModelElementsByType(BpmnShape.class);
  assertEquals(5, allShapes.size());

  assertEventShapeProperties(BOUNDARY_ID);
}
 
Example #5
Source File: BpmnDeploymentTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testDeployAndGetProcessDefinition() throws Exception {

    // given process model
    final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess("foo").startEvent().userTask().endEvent().done();

    // when process model is deployed
    DeploymentWithDefinitions deployment = repositoryService.createDeployment()
      .addModelInstance("foo.bpmn", modelInstance).deployWithResult();
    deploymentIds.add(deployment.getId());

    // then deployment contains deployed process definitions
    List<ProcessDefinition> deployedProcessDefinitions = deployment.getDeployedProcessDefinitions();
    assertEquals(1, deployedProcessDefinitions.size());
    assertNull(deployment.getDeployedCaseDefinitions());
    assertNull(deployment.getDeployedDecisionDefinitions());
    assertNull(deployment.getDeployedDecisionRequirementsDefinitions());

    // and persisted process definition is equal to deployed process definition
    ProcessDefinition persistedProcDef = repositoryService.createProcessDefinitionQuery()
                                                          .processDefinitionResourceName("foo.bpmn")
                                                          .singleResult();
    assertEquals(persistedProcDef.getId(), deployedProcessDefinitions.get(0).getId());
  }
 
Example #6
Source File: MultiTenancyCallActivityTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testStartProcessInstanceWithDeploymentBinding() {

    BpmnModelInstance callingProcess = Bpmn.createExecutableProcess("callingProcess")
      .startEvent()
      .callActivity()
        .calledElement("subProcess")
        .camundaCalledElementBinding("deployment")
      .endEvent()
      .done();

    deploymentForTenant(TENANT_ONE, callingProcess, SUB_PROCESS);
    deploymentForTenant(TENANT_TWO, callingProcess, SUB_PROCESS);

    runtimeService.createProcessInstanceByKey("callingProcess").processDefinitionTenantId(TENANT_ONE).execute();
    runtimeService.createProcessInstanceByKey("callingProcess").processDefinitionTenantId(TENANT_TWO).execute();

    ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().processDefinitionKey("subProcess");
    assertThat(query.tenantIdIn(TENANT_ONE).count(), is(1L));
    assertThat(query.tenantIdIn(TENANT_TWO).count(), is(1L));
  }
 
Example #7
Source File: ProcessApplicationDeploymentTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testOverwriteDeploymentSource() {
  // given
  String key = "process";
  BpmnModelInstance model = Bpmn.createExecutableProcess(key).done();
  DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery();

  // when
  testRule.deploy(repositoryService
      .createDeployment(processApplication.getReference())
      .name("first-deployment-with-a-source")
      .source("my-source")
      .addModelInstance("process.bpmn", model));

  // then
  assertEquals("my-source",
               deploymentQuery.deploymentName("first-deployment-with-a-source")
                   .singleResult()
                   .getSource());
}
 
Example #8
Source File: TenantIdProviderTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void providerCalledForStartedProcessInstanceByStartFormWithoutTenantId() {
  ContextLoggingTenantIdProvider tenantIdProvider = new ContextLoggingTenantIdProvider();
  TestTenantIdProvider.delegate = tenantIdProvider;

  // given a deployment without a tenant id
  testRule.deploy(Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().done(),
                                          "org/camunda/bpm/engine/test/api/form/util/request.form");

  // when a process instance is started with a start form
  String processDefinitionId = engineRule.getRepositoryService()
                                         .createProcessDefinitionQuery()
                                         .singleResult()
                                         .getId();

  Map<String, Object> properties = new HashMap<String, Object>();
  properties.put("employeeName", "demo");

  ProcessInstance procInstance = engineRule.getFormService().submitStartForm(processDefinitionId, properties);
  assertNotNull(procInstance);

  // then the tenant id provider is invoked
  assertThat(tenantIdProvider.parameters.size(), is(1));
}
 
Example #9
Source File: ModificationExecutionSyncTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testCancelWithFlag() {
  // given
  this.instance = Bpmn.createExecutableProcess("process1")
      .startEvent("start")
      .serviceTask("ser").camundaExpression("${true}")
      .userTask("user")
      .endEvent("end")
      .done();

  ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);

  List<String> processInstanceIds = helper.startInstances("process1", 1);

  // when
  runtimeService.createModification(processDefinition.getId())
    .startBeforeActivity("ser")
    .cancelAllForActivity("user", true)
    .processInstanceIds(processInstanceIds)
    .execute();

  // then
  ExecutionEntity execution = (ExecutionEntity) runtimeService.createExecutionQuery().singleResult();
  assertNotNull(execution);
  assertEquals("user", execution.getActivityId());
}
 
Example #10
Source File: GetHistoricVariableUpdatesForOptimizeTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void occurredAfterParameterWorks() {
   // given
  BpmnModelInstance simpleDefinition = Bpmn.createExecutableProcess("process")
    .startEvent()
    .endEvent()
    .done();
  testHelper.deploy(simpleDefinition);
  Map<String, Object> variables = new HashMap<>();
  variables.put("stringVar", "value1");
  Date now = new Date();
  ClockUtil.setCurrentTime(now);
  runtimeService.startProcessInstanceByKey("process", variables);
  Date nowPlus2Seconds = new Date(new Date().getTime() + 2000L);
  ClockUtil.setCurrentTime(nowPlus2Seconds);
  variables.put("stringVar", "value2");
  runtimeService.startProcessInstanceByKey("process", variables);

  // when
  List<HistoricVariableUpdate> variableUpdates =
    optimizeService.getHistoricVariableUpdates(now, null, 10);

  // then
  assertThat(variableUpdates.size()).isEqualTo(1);
  assertThat(variableUpdates.get(0).getValue().toString()).isEqualTo("value2");
}
 
Example #11
Source File: ModificationExecutionSyncTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testCancelWithoutFlag2() {
  // given
  this.instance = Bpmn.createExecutableProcess("process1")
      .startEvent("start")
      .serviceTask("ser").camundaExpression("${true}")
      .userTask("user")
      .endEvent("end")
      .done();

  ProcessDefinition processDefinition = testRule.deployAndGetDefinition(instance);

  List<String> processInstanceIds = helper.startInstances("process1", 1);

  // when
  runtimeService.createModification(processDefinition.getId())
    .startBeforeActivity("ser")
    .cancelAllForActivity("user", false)
    .processInstanceIds(processInstanceIds)
    .execute();

  // then
  assertEquals(0, runtimeService.createExecutionQuery().list().size());
}
 
Example #12
Source File: ExecutionListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected BpmnModelInstance createModelWithCatchInServiceTaskAndListener(String eventName) {
  return Bpmn.createExecutableProcess(PROCESS_KEY)
        .startEvent()
        .userTask("userTask1")
        .serviceTask("throw")
          .camundaExecutionListenerClass(eventName, ThrowBPMNErrorDelegate.class.getName())
          .camundaExpression("${true}")
        .boundaryEvent("errorEvent")
        .error(ERROR_CODE)
        .userTask("afterCatch")
        .endEvent("endEvent")
        .moveToActivity("throw")
        .userTask("afterService")
        .endEvent()
        .done();
}
 
Example #13
Source File: MultiTenancyExecutionPropagationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testPropagateTenantIdToFailedStartTimerIncident() {

    deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY)
        .startEvent()
          .timerWithDuration("PT1M")
         .serviceTask()
           .camundaExpression("${failing}")
         .endEvent()
         .done());

    executeAvailableJobs();

    Incident incident = runtimeService.createIncidentQuery().singleResult();
    assertThat(incident, is(notNullValue()));
    // inherit the tenant id from job
    assertThat(incident.getTenantId(), is(TENANT_ID));
  }
 
Example #14
Source File: MultiTenancySharedDefinitionPropagationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void propagateTenantIdToAsyncJob() {
  testRule.deploy(Bpmn.createExecutableProcess("process")
    .startEvent()
    .userTask()
      .camundaAsyncBefore()
    .endEvent()
  .done());

  engineRule.getRuntimeService().startProcessInstanceByKey("process");

  // the job is created when the asynchronous activity is reached
  Job job = engineRule.getManagementService().createJobQuery().singleResult();
  assertThat(job, is(notNullValue()));
  // inherit the tenant id from execution
  assertThat(job.getTenantId(), is(TENANT_ID));
}
 
Example #15
Source File: ProcessDataLoggingContextTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@WatchLogger(loggerNames = CONTEXT_LOGGER, level = "ERROR")
public void shouldLogFailureFromCompleteTaskListenerInTaskContext() {
  // given
  manageDeployment(Bpmn.createExecutableProcess(PROCESS)
      .startEvent("start")
      .userTask("failingTask")
        .camundaTaskListenerClass(TaskListener.EVENTNAME_COMPLETE, FailingTaskListener.class)
      .endEvent("end")
      .done());
  ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS, B_KEY);
  // when
  try {
    taskService.complete(taskService.createTaskQuery().singleResult().getId());
    fail("Exception expected");
  } catch (Exception e) {
    // expected exception in the task listener that is not caught
  }
  assertFailureLogPresent(instance, "failingTask");
}
 
Example #16
Source File: TriggerConditionalEventFromDelegationCodeTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testNonInterruptingSetVariableInEndListener() {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
    .startEvent()
    .userTask(TASK_BEFORE_CONDITION_ID)
    .name(TASK_BEFORE_CONDITION)
    .camundaExecutionListenerClass(ExecutionListener.EVENTNAME_END, specifier.getDelegateClass().getName())
    .userTask(TASK_WITH_CONDITION_ID)
    .name(TASK_WITH_CONDITION)
    .endEvent()
    .done();
  deployConditionalEventSubProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, specifier.getCondition(), false);

  // given
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
  TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());

  //when task is completed
  taskService.complete(taskQuery.singleResult().getId());

  //then end listener sets variable
  //non interrupting event is triggered
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(1 + specifier.getExpectedNonInterruptingCount(), tasksAfterVariableIsSet.size());
  assertEquals(specifier.getExpectedNonInterruptingCount(), taskQuery.taskName(TASK_AFTER_CONDITION).count());
}
 
Example #17
Source File: DiGeneratorForSequenceFlowsTest.java    From camunda-bpmn-model with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldGenerateEdgesWhenUsingMoveToActivity() {

  ProcessBuilder builder = Bpmn.createExecutableProcess();

  instance = builder
      .startEvent(START_EVENT_ID)
      .sequenceFlowId("s1")
      .exclusiveGateway()
      .sequenceFlowId("s2")
      .userTask(USER_TASK_ID)
      .sequenceFlowId("s3")
      .endEvent("e1")
      .moveToActivity(USER_TASK_ID)
      .sequenceFlowId("s4")
      .endEvent("e2")
      .done();

  Collection<BpmnEdge> allEdges = instance.getModelElementsByType(BpmnEdge.class);
  assertEquals(4, allEdges.size());

  assertBpmnEdgeExists("s1");
  assertBpmnEdgeExists("s2");
  assertBpmnEdgeExists("s3");
  assertBpmnEdgeExists("s4");
}
 
Example #18
Source File: TriggerConditionalEventFromDelegationCodeTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testNonInterruptingSetVariableInStartListener() {
  BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
    .startEvent()
    .userTask(TASK_BEFORE_CONDITION_ID)
    .name(TASK_BEFORE_CONDITION)
    .userTask(TASK_WITH_CONDITION_ID)
    .camundaExecutionListenerClass(ExecutionListener.EVENTNAME_START, specifier.getDelegateClass().getName())
    .name(TASK_WITH_CONDITION)
    .endEvent()
    .done();
  deployConditionalEventSubProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, specifier.getCondition(), false);

  // given
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
  TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());

  //when task is completed
  taskService.complete(taskQuery.singleResult().getId());

  //then start listener sets variable
  //non interrupting boundary event is triggered
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(1 + specifier.getExpectedNonInterruptingCount(), tasksAfterVariableIsSet.size());
  assertEquals(specifier.getExpectedNonInterruptingCount(), taskQuery.taskName(TASK_AFTER_CONDITION).count());
}
 
Example #19
Source File: GetRunningHistoricTaskInstancesForOptimizeTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void getRunningHistoricTaskInstances() {
   // given
  BpmnModelInstance simpleDefinition = Bpmn.createExecutableProcess("process")
    .startEvent("startEvent")
    .userTask("userTask")
      .name("task")
      .camundaAssignee(userId)
    .endEvent("endEvent")
    .done();
  testHelper.deploy(simpleDefinition);
  runtimeService.startProcessInstanceByKey("process");

  // when
  List<HistoricTaskInstance> runningHistoricTaskInstances =
    optimizeService.getRunningHistoricTaskInstances(null, null, 10);

  // then
  assertThat(runningHistoricTaskInstances.size(), is(1));
  assertThatTasksHaveAllImportantInformation(runningHistoricTaskInstances.get(0));
}
 
Example #20
Source File: MultiTenancyExecutionPropagationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testPropagateTenantIdToVariableInstanceOnStartProcessInstance() {

    deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY)
        .startEvent()
        .userTask()
        .endEvent()
      .done());

    VariableMap variables = Variables.putValue("var", "test");

    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    runtimeService.startProcessInstanceById(processDefinition.getId(), variables);

    VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult();
    assertThat(variableInstance, is(notNullValue()));
    // inherit the tenant id from process instance
    assertThat(variableInstance.getTenantId(), is(TENANT_ID));
  }
 
Example #21
Source File: CoordinatesGenerationTest.java    From camunda-bpmn-model with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldPlaceTwoBoundaryEventsForSubProcess() {
  ProcessBuilder builder = Bpmn.createExecutableProcess();

  instance = builder
      .startEvent(START_EVENT_ID)
      .subProcess(SUB_PROCESS_ID)
      .boundaryEvent("boundary1")
      .moveToActivity(SUB_PROCESS_ID)
      .boundaryEvent("boundary2")
      .moveToActivity(SUB_PROCESS_ID)
      .endEvent()
      .done();

  Bounds boundaryEvent1Bounds = findBpmnShape("boundary1").getBounds();
  assertShapeCoordinates(boundaryEvent1Bounds, 343, 200);

  Bounds boundaryEvent2Bounds = findBpmnShape("boundary2").getBounds();
  assertShapeCoordinates(boundaryEvent2Bounds, 379, 200);

}
 
Example #22
Source File: DiGeneratorForFlowNodesTest.java    From camunda-bpmn-model with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldGenerateShapeForThrowingIntermediateEvent() {

  // given
  ProcessBuilder processBuilder = Bpmn.createExecutableProcess();

  // when
  instance = processBuilder
                .startEvent(START_EVENT_ID)
                .intermediateThrowEvent("inter")
                .endEvent(END_EVENT_ID).done();

  // then
  Collection<BpmnShape> allShapes = instance.getModelElementsByType(BpmnShape.class);
  assertEquals(3, allShapes.size());

  assertEventShapeProperties("inter");
}
 
Example #23
Source File: DiGeneratorForFlowNodesTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldGenerateShapeForExclusiveGateway() {

  // given
  ProcessBuilder processBuilder = Bpmn.createExecutableProcess();

  // when
  instance = processBuilder
                .startEvent(START_EVENT_ID)
                .exclusiveGateway("or")
                .endEvent(END_EVENT_ID)
                .done();

  // then
  Collection<BpmnShape> allShapes = instance.getModelElementsByType(BpmnShape.class);
  assertEquals(3, allShapes.size());

  assertGatewayShapeProperties("or");
  BpmnShape bpmnShape = findBpmnShape("or");
  assertTrue(bpmnShape.isMarkerVisible());
}
 
Example #24
Source File: TaskListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testCompleteTaskInCreateEventTaskListenerWithIdentityLinks() {
  // given process with user task, identity links and task create listener
  BpmnModelInstance modelInstance =
      Bpmn.createExecutableProcess("startToEnd")
          .startEvent()
          .userTask()
          .camundaTaskListenerClass(TaskListener.EVENTNAME_CREATE, CompletingTaskListener.class.getName())
          .name("userTask")
          .camundaCandidateUsers(Arrays.asList(new String[]{"users1", "user2"}))
          .camundaCandidateGroups(Arrays.asList(new String[]{"group1", "group2"}))
          .endEvent().done();

  testRule.deploy(modelInstance);

  // when process is started and user task completed in task create listener
  runtimeService.startProcessInstanceByKey("startToEnd");

  // then task is successfully completed without an exception
  assertNull(taskService.createTaskQuery().singleResult());
}
 
Example #25
Source File: HistoricRootProcessInstanceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldResolveExternalTaskLog() {
  // given
  testRule.deploy(Bpmn.createExecutableProcess("calledProcess")
    .startEvent()
      .serviceTask().camundaExternalTask("anExternalTaskTopic")
    .endEvent().done());

  testRule.deploy(Bpmn.createExecutableProcess("callingProcess")
    .startEvent()
      .callActivity()
        .calledElement("calledProcess")
    .endEvent().done());

  // when
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callingProcess");

  HistoricExternalTaskLog ExternalTaskLog = historyService.createHistoricExternalTaskLogQuery().singleResult();

  // assume
  assertThat(ExternalTaskLog, notNullValue());

  // then
  assertThat(ExternalTaskLog.getRootProcessInstanceId(), is(processInstance.getRootProcessInstanceId()));
}
 
Example #26
Source File: DiGeneratorForFlowNodesTest.java    From camunda-bpmn-model with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldGenerateShapeForServiceTask() {

  // given
  ProcessBuilder processBuilder = Bpmn.createExecutableProcess();

  // when
  instance = processBuilder
                 .startEvent(START_EVENT_ID)
                 .serviceTask(SERVICE_TASK_ID)
                 .done();

  // then
  Collection<BpmnShape> allShapes = instance.getModelElementsByType(BpmnShape.class);
  assertEquals(2, allShapes.size());

  assertTaskShapeProperties(SERVICE_TASK_ID);
}
 
Example #27
Source File: MixedConditionalEventTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testSetVariableOnOutputMapping() {

  final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY)
    .startEvent()
    .userTask(TASK_WITH_CONDITION_ID)
    .camundaOutputParameter(VARIABLE_NAME, "1")
    .name(TASK_WITH_CONDITION)
    .endEvent()
    .done();

  deployMixedProcess(modelInstance, CONDITIONAL_EVENT_PROCESS_KEY, true);

  // given
  ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
  TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
  Task task = taskQuery.singleResult();

  //when task before is completed
  taskService.complete(task.getId());

  //then conditional boundary should not triggered but conditional start event
  tasksAfterVariableIsSet = taskQuery.list();
  assertEquals(TASK_AFTER_CONDITIONAL_START_EVENT, tasksAfterVariableIsSet.get(0).getName());
}
 
Example #28
Source File: DiGeneratorForFlowNodesTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldGenerateShapeForParallelGateway() {

  // given
  ProcessBuilder processBuilder = Bpmn.createExecutableProcess();

  // when
  instance = processBuilder
                .startEvent(START_EVENT_ID)
                .parallelGateway("and")
                .endEvent(END_EVENT_ID)
                .done();

  // then
  Collection<BpmnShape> allShapes = instance.getModelElementsByType(BpmnShape.class);
  assertEquals(3, allShapes.size());

  assertGatewayShapeProperties("and");
}
 
Example #29
Source File: MultiTenancyJobExecutorTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void setAuthenticatedTenantForTimerStartEvent() {
  testRule.deployForTenant(TENANT_ID, Bpmn.createExecutableProcess("process")
      .startEvent()
        .timerWithDuration("PT1M")
      .serviceTask()
        .camundaClass(AssertingJavaDelegate.class.getName())
      .userTask()
      .endEvent()
    .done());

  AssertingJavaDelegate.addAsserts(hasAuthenticatedTenantId(TENANT_ID));

  ClockUtil.setCurrentTime(tomorrow());
  testRule.waitForJobExecutorToProcessAllJobs();

  assertThat(engineRule.getTaskService().createTaskQuery().count(), is(1L));
}
 
Example #30
Source File: ProcessDataLoggingContextTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@WatchLogger(loggerNames = CONTEXT_LOGGER, level = "ERROR")
public void shouldLogFailureFromCreateTaskListenerInTaskContext() {
  // given
  manageDeployment(Bpmn.createExecutableProcess(PROCESS)
      .startEvent("start")
      .userTask("waitState")
      .userTask("failingTask")
        .camundaTaskListenerClass(TaskListener.EVENTNAME_CREATE, FailingTaskListener.class)
      .endEvent("end")
      .done());
  ProcessInstance instance = runtimeService.startProcessInstanceByKey(PROCESS, B_KEY);
  // when
  try {
    taskService.complete(taskService.createTaskQuery().singleResult().getId());
    fail("Exception expected");
  } catch (Exception e) {
    // expected exception in the task listener that is not caught
  }
  assertFailureLogPresent(instance, "failingTask");
}