org.camunda.bpm.model.bpmn.instance.Process Java Examples

The following examples show how to use org.camunda.bpm.model.bpmn.instance.Process. 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: ServiceTaskBpmnModelExecutionContextTest.java    From camunda-bpm-platform with Apache License 2.0 7 votes vote down vote up
public void testJavaDelegateModelExecutionContext() {
  deploy();

  runtimeService.startProcessInstanceByKey(PROCESS_ID);

  BpmnModelInstance modelInstance = ModelExecutionContextServiceTask.modelInstance;
  assertNotNull(modelInstance);

  Model model = modelInstance.getModel();
  Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(model.getType(Event.class));
  assertEquals(2, events.size());
  Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(model.getType(Task.class));
  assertEquals(1, tasks.size());

  Process process = (Process) modelInstance.getDefinitions().getRootElements().iterator().next();
  assertEquals(PROCESS_ID, process.getId());
  assertTrue(process.isExecutable());

  ServiceTask serviceTask = ModelExecutionContextServiceTask.serviceTask;
  assertNotNull(serviceTask);
  assertEquals(ModelExecutionContextServiceTask.class.getName(), serviceTask.getCamundaClass());
}
 
Example #2
Source File: Bpmn.java    From camunda-bpmn-model with Apache License 2.0 6 votes vote down vote up
public static ProcessBuilder createProcess() {
  BpmnModelInstance modelInstance = INSTANCE.doCreateEmptyModel();
  Definitions definitions = modelInstance.newInstance(Definitions.class);
  definitions.setTargetNamespace(BPMN20_NS);
  definitions.getDomElement().registerNamespace("camunda", CAMUNDA_NS);
  modelInstance.setDefinitions(definitions);
  Process process = modelInstance.newInstance(Process.class);
  definitions.addChildElement(process);

  BpmnDiagram bpmnDiagram = modelInstance.newInstance(BpmnDiagram.class);

  BpmnPlane bpmnPlane = modelInstance.newInstance(BpmnPlane.class);
  bpmnPlane.setBpmnElement(process);

  bpmnDiagram.addChildElement(bpmnPlane);
  definitions.addChildElement(bpmnDiagram);

  return process.builder();
}
 
Example #3
Source File: Bpmn.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static ProcessBuilder createProcess() {
  BpmnModelInstance modelInstance = INSTANCE.doCreateEmptyModel();
  Definitions definitions = modelInstance.newInstance(Definitions.class);
  definitions.setTargetNamespace(BPMN20_NS);
  definitions.getDomElement().registerNamespace("camunda", CAMUNDA_NS);
  modelInstance.setDefinitions(definitions);
  Process process = modelInstance.newInstance(Process.class);
  definitions.addChildElement(process);

  BpmnDiagram bpmnDiagram = modelInstance.newInstance(BpmnDiagram.class);

  BpmnPlane bpmnPlane = modelInstance.newInstance(BpmnPlane.class);
  bpmnPlane.setBpmnElement(process);

  bpmnDiagram.addChildElement(bpmnPlane);
  definitions.addChildElement(bpmnDiagram);

  return process.builder();
}
 
Example #4
Source File: ReferenceTest.java    From camunda-bpmn-model with Apache License 2.0 6 votes vote down vote up
@Before
public void createModel() {
  testBpmnModelInstance = Bpmn.createEmptyModel();
  Definitions definitions = testBpmnModelInstance.newInstance(Definitions.class);
  testBpmnModelInstance.setDefinitions(definitions);

  message = testBpmnModelInstance.newInstance(Message.class);
  message.setId("message-id");
  definitions.getRootElements().add(message);

  Process process = testBpmnModelInstance.newInstance(Process.class);
  process.setId("process-id");
  definitions.getRootElements().add(process);

  startEvent = testBpmnModelInstance.newInstance(StartEvent.class);
  startEvent.setId("start-event-id");
  process.getFlowElements().add(startEvent);

  messageEventDefinition = testBpmnModelInstance.newInstance(MessageEventDefinition.class);
  messageEventDefinition.setId("msg-def-id");
  messageEventDefinition.setMessage(message);
  startEvent.getEventDefinitions().add(messageEventDefinition);

  startEvent.getEventDefinitionRefs().add(messageEventDefinition);
}
 
Example #5
Source File: ProcessBuilderTest.java    From camunda-bpmn-model with Apache License 2.0 6 votes vote down vote up
@Test
public void testProcessCamundaExtensions() {
  modelInstance = Bpmn.createProcess(PROCESS_ID)
    .camundaJobPriority("${somePriority}")
    .camundaTaskPriority(TEST_PROCESS_TASK_PRIORITY)
    .camundaHistoryTimeToLive(TEST_HISTORY_TIME_TO_LIVE)
    .camundaStartableInTasklist(TEST_STARTABLE_IN_TASKLIST)
    .camundaVersionTag(TEST_VERSION_TAG)
    .startEvent()
    .endEvent()
    .done();

  Process process = modelInstance.getModelElementById(PROCESS_ID);
  assertThat(process.getCamundaJobPriority()).isEqualTo("${somePriority}");
  assertThat(process.getCamundaTaskPriority()).isEqualTo(TEST_PROCESS_TASK_PRIORITY);
  assertThat(process.getCamundaHistoryTimeToLive()).isEqualTo(TEST_HISTORY_TIME_TO_LIVE);
  assertThat(process.isCamundaStartableInTasklist()).isEqualTo(TEST_STARTABLE_IN_TASKLIST);
  assertThat(process.getCamundaVersionTag()).isEqualTo(TEST_VERSION_TAG);
}
 
Example #6
Source File: CreateModelTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void createProcessWithParallelGateway() {
  // create process
  Process process = createElement(definitions, "process-with-parallel-gateway", Process.class);

  // create elements
  StartEvent startEvent = createElement(process, "start", StartEvent.class);
  ParallelGateway fork = createElement(process, "fork", ParallelGateway.class);
  UserTask task1 = createElement(process, "task1", UserTask.class);
  ServiceTask task2 = createElement(process, "task2", ServiceTask.class);
  ParallelGateway join = createElement(process, "join", ParallelGateway.class);
  EndEvent endEvent = createElement(process, "end", EndEvent.class);

  // create flows
  createSequenceFlow(process, startEvent, fork);
  createSequenceFlow(process, fork, task1);
  createSequenceFlow(process, fork, task2);
  createSequenceFlow(process, task1, join);
  createSequenceFlow(process, task2, join);
  createSequenceFlow(process, join, endEvent);
}
 
Example #7
Source File: ProcessBuilderTest.java    From camunda-bpmn-model with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateEmptyProcess() {
  modelInstance = Bpmn.createProcess()
    .done();

  Definitions definitions = modelInstance.getDefinitions();
  assertThat(definitions).isNotNull();
  assertThat(definitions.getTargetNamespace()).isEqualTo(BPMN20_NS);

  Collection<ModelElementInstance> processes = modelInstance.getModelElementsByType(processType);
  assertThat(processes)
    .hasSize(1);

  Process process = (Process) processes.iterator().next();
  assertThat(process.getId()).isNotNull();
}
 
Example #8
Source File: ProcessTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
@BpmnModelResource
public void shouldImportProcess() {

  ModelElementInstance modelElementById = bpmnModelInstance.getModelElementById("exampleProcessId");
  assertThat(modelElementById).isNotNull();

  Collection<RootElement> rootElements = bpmnModelInstance.getDefinitions().getRootElements();
  assertThat(rootElements).hasSize(1);
  org.camunda.bpm.model.bpmn.instance.Process process = (Process) rootElements.iterator().next();

  assertThat(process.getId()).isEqualTo("exampleProcessId");
  assertThat(process.getName()).isNull();
  assertThat(process.getProcessType()).isEqualTo(ProcessType.None);
  assertThat(process.isExecutable()).isFalse();
  assertThat(process.isClosed()).isFalse();



}
 
Example #9
Source File: ProcessBuilderTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateEmptyProcess() {
  modelInstance = Bpmn.createProcess()
    .done();

  Definitions definitions = modelInstance.getDefinitions();
  assertThat(definitions).isNotNull();
  assertThat(definitions.getTargetNamespace()).isEqualTo(BPMN20_NS);

  Collection<ModelElementInstance> processes = modelInstance.getModelElementsByType(processType);
  assertThat(processes)
    .hasSize(1);

  Process process = (Process) processes.iterator().next();
  assertThat(process.getId()).isNotNull();
}
 
Example #10
Source File: ProcessBuilderTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testProcessCamundaExtensions() {
  modelInstance = Bpmn.createProcess(PROCESS_ID)
    .camundaJobPriority("${somePriority}")
    .camundaTaskPriority(TEST_PROCESS_TASK_PRIORITY)
    .camundaHistoryTimeToLive(TEST_HISTORY_TIME_TO_LIVE)
    .camundaStartableInTasklist(TEST_STARTABLE_IN_TASKLIST)
    .camundaVersionTag(TEST_VERSION_TAG)
    .startEvent()
    .endEvent()
    .done();

  Process process = modelInstance.getModelElementById(PROCESS_ID);
  assertThat(process.getCamundaJobPriority()).isEqualTo("${somePriority}");
  assertThat(process.getCamundaTaskPriority()).isEqualTo(TEST_PROCESS_TASK_PRIORITY);
  assertThat(process.getCamundaHistoryTimeToLive()).isEqualTo(TEST_HISTORY_TIME_TO_LIVE);
  assertThat(process.isCamundaStartableInTasklist()).isEqualTo(TEST_STARTABLE_IN_TASKLIST);
  assertThat(process.getCamundaVersionTag()).isEqualTo(TEST_VERSION_TAG);
}
 
Example #11
Source File: ProcessTest.java    From camunda-bpmn-model with Apache License 2.0 6 votes vote down vote up
@Test
@BpmnModelResource
public void shouldImportProcess() {

  ModelElementInstance modelElementById = bpmnModelInstance.getModelElementById("exampleProcessId");
  assertThat(modelElementById).isNotNull();

  Collection<RootElement> rootElements = bpmnModelInstance.getDefinitions().getRootElements();
  assertThat(rootElements).hasSize(1);
  org.camunda.bpm.model.bpmn.instance.Process process = (Process) rootElements.iterator().next();

  assertThat(process.getId()).isEqualTo("exampleProcessId");
  assertThat(process.getName()).isNull();
  assertThat(process.getProcessType()).isEqualTo(ProcessType.None);
  assertThat(process.isExecutable()).isFalse();
  assertThat(process.isClosed()).isFalse();



}
 
Example #12
Source File: ReferenceTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Before
public void createModel() {
  testBpmnModelInstance = Bpmn.createEmptyModel();
  Definitions definitions = testBpmnModelInstance.newInstance(Definitions.class);
  testBpmnModelInstance.setDefinitions(definitions);

  message = testBpmnModelInstance.newInstance(Message.class);
  message.setId("message-id");
  definitions.getRootElements().add(message);

  Process process = testBpmnModelInstance.newInstance(Process.class);
  process.setId("process-id");
  definitions.getRootElements().add(process);

  startEvent = testBpmnModelInstance.newInstance(StartEvent.class);
  startEvent.setId("start-event-id");
  process.getFlowElements().add(startEvent);

  messageEventDefinition = testBpmnModelInstance.newInstance(MessageEventDefinition.class);
  messageEventDefinition.setId("msg-def-id");
  messageEventDefinition.setMessage(message);
  startEvent.getEventDefinitions().add(messageEventDefinition);

  startEvent.getEventDefinitionRefs().add(messageEventDefinition);
}
 
Example #13
Source File: CreateModelTest.java    From camunda-bpmn-model with Apache License 2.0 6 votes vote down vote up
@Test
public void createProcessWithParallelGateway() {
  // create process
  Process process = createElement(definitions, "process-with-parallel-gateway", Process.class);

  // create elements
  StartEvent startEvent = createElement(process, "start", StartEvent.class);
  ParallelGateway fork = createElement(process, "fork", ParallelGateway.class);
  UserTask task1 = createElement(process, "task1", UserTask.class);
  ServiceTask task2 = createElement(process, "task2", ServiceTask.class);
  ParallelGateway join = createElement(process, "join", ParallelGateway.class);
  EndEvent endEvent = createElement(process, "end", EndEvent.class);

  // create flows
  createSequenceFlow(process, startEvent, fork);
  createSequenceFlow(process, fork, task1);
  createSequenceFlow(process, fork, task2);
  createSequenceFlow(process, task1, join);
  createSequenceFlow(process, task2, join);
  createSequenceFlow(process, join, endEvent);
}
 
Example #14
Source File: ProcessStartEventValidator.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void validate(Process process, ValidationResultCollector validationResultCollector) {
  Collection<StartEvent> startEvents = process.getChildElementsByType(StartEvent.class);
  int startEventCount = startEvents.size();

  if(startEventCount != 1) {
    validationResultCollector.addError(10, String.format("Process does not have exactly one start event. Got %d.", startEventCount));
  }
}
 
Example #15
Source File: ParticipantImpl.java    From camunda-bpmn-model with Apache License 2.0 5 votes vote down vote up
public static void registerType(ModelBuilder modelBuilder) {
  ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(Participant.class, BPMN_ELEMENT_PARTICIPANT)
    .namespaceUri(BPMN20_NS)
    .extendsType(BaseElement.class)
    .instanceProvider(new ModelTypeInstanceProvider<Participant>() {
      public Participant newInstance(ModelTypeInstanceContext instanceContext) {
        return new ParticipantImpl(instanceContext);
      }
    });

  nameAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_NAME)
    .build();

  processRefAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_PROCESS_REF)
    .qNameAttributeReference(Process.class)
    .build();

  SequenceBuilder sequenceBuilder = typeBuilder.sequence();

  interfaceRefCollection = sequenceBuilder.elementCollection(InterfaceRef.class)
    .qNameElementReferenceCollection(Interface.class)
    .build();

  endPointRefCollection = sequenceBuilder.elementCollection(EndPointRef.class)
    .qNameElementReferenceCollection(EndPoint.class)
    .build();

  participantMultiplicityChild = sequenceBuilder.element(ParticipantMultiplicity.class)
    .build();

  typeBuilder.build();
}
 
Example #16
Source File: CreateModelTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public SequenceFlow createSequenceFlow(Process process, FlowNode from, FlowNode to) {
  SequenceFlow sequenceFlow = createElement(process, from.getId() + "-" + to.getId(), SequenceFlow.class);
  process.addChildElement(sequenceFlow);
  sequenceFlow.setSource(from);
  from.getOutgoing().add(sequenceFlow);
  sequenceFlow.setTarget(to);
  to.getIncoming().add(sequenceFlow);
  return sequenceFlow;
}
 
Example #17
Source File: DefaultLoadGenerator.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws InterruptedException {

    final Properties properties = PerfTestProcessEngine.loadProperties();
    final ProcessEngine processEngine = PerfTestProcessEngine.getInstance();

    final LoadGeneratorConfiguration config = new LoadGeneratorConfiguration();
    config.setColor(Boolean.parseBoolean(properties.getProperty("loadGenerator.colorOutput", "false")));
    config.setNumberOfIterations(Integer.parseInt(properties.getProperty("loadGenerator.numberOfIterations", "10000")));

    final List<BpmnModelInstance> modelInstances = createProcesses(config.getNumberOfIterations());

    Runnable[] setupTasks = new Runnable[] {
        new DeployModelInstancesTask(processEngine, modelInstances)
    };
    config.setSetupTasks(setupTasks);

    ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
    processEngineConfiguration.setMetricsEnabled(true);
    processEngineConfiguration.getDbMetricsReporter().setReporterId(REPORTER_ID);
    final Runnable[] workerRunnables = new Runnable[2];
    Process process = modelInstances.get(0).getModelElementsByType(Process.class).iterator().next();
    String processDefKey = process.getId();
    workerRunnables[0] = new StartProcessInstanceTask(processEngine, processDefKey);
    workerRunnables[1] = new GenerateMetricsTask(processEngine);
    config.setWorkerTasks(workerRunnables);

    new LoadGenerator(config).execute();

    System.out.println(processEngine.getHistoryService().createHistoricProcessInstanceQuery().count()+ " Process Instances in DB");
    processEngineConfiguration.setMetricsEnabled(false);
  }
 
Example #18
Source File: CreateModelTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void createProcessWithOneTask() {
  // create process
  Process process = createElement(definitions, "process-with-one-task", Process.class);

  // create elements
  StartEvent startEvent = createElement(process, "start", StartEvent.class);
  UserTask task1 = createElement(process, "task1", UserTask.class);
  EndEvent endEvent = createElement(process, "end", EndEvent.class);

  // create flows
  createSequenceFlow(process, startEvent, task1);
  createSequenceFlow(process, task1, endEvent);
}
 
Example #19
Source File: StartProcessInstancesInDirectory.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private static List<String> extractProcessDefinitionKeys(List<String> deployableFileNames) {
  ArrayList<String> keys = new ArrayList<String>();
  for (String file : deployableFileNames) {
    if(file.endsWith(".bpmn") || file.endsWith(".bpmn20.xml")) {
      BpmnModelInstance modelInstance = Bpmn.readModelFromFile(new File(file));
      Collection<Process> processes = modelInstance.getModelElementsByType(Process.class);
      for (Process process : processes) {
        if(process.isExecutable()) {
          keys.add(process.getId());
        }
      }
    }
  }
  return keys;
}
 
Example #20
Source File: UserTaskBpmnModelExecutionContextTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
private void assertModelInstance() {
  BpmnModelInstance modelInstance = ModelExecutionContextTaskListener.modelInstance;
  assertNotNull(modelInstance);

  Collection<ModelElementInstance> events = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Event.class));
  assertEquals(2, events.size());

  Collection<ModelElementInstance> tasks = modelInstance.getModelElementsByType(modelInstance.getModel().getType(Task.class));
  assertEquals(1, tasks.size());

  Process process = (Process) modelInstance.getDefinitions().getRootElements().iterator().next();
  assertEquals(PROCESS_ID, process.getId());
  assertTrue(process.isExecutable());
}
 
Example #21
Source File: VersionedDeploymentHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected String parseProcessDefinitionKey(Resource resource) {
  BpmnModelInstance model = Bpmn
      .readModelFromStream(new ByteArrayInputStream(resource.getBytes()));

  Process process = model.getDefinitions().getChildElementsByType(Process.class)
      .iterator().next();

  return process.getId();
}
 
Example #22
Source File: VersionedDeploymentHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected Integer parseCamundaVersionTag(Resource resource) {
  BpmnModelInstance model = Bpmn
      .readModelFromStream(new ByteArrayInputStream(resource.getBytes()));

  Process process = model.getDefinitions().getChildElementsByType(Process.class)
      .iterator().next();

  return process.getCamundaVersionTag() != null ?
      Integer.valueOf(process.getCamundaVersionTag()) :
      0;
}
 
Example #23
Source File: GenerateIdTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldNotGenerateIdsOnRead() {
  BpmnModelInstance modelInstance = Bpmn.readModelFromStream(GenerateIdTest.class.getResourceAsStream("GenerateIdTest.bpmn"));
  Definitions definitions = modelInstance.getDefinitions();
  assertThat(definitions.getId()).isNull();

  Process process = modelInstance.getModelElementsByType(Process.class).iterator().next();
  assertThat(process.getId()).isNull();

  StartEvent startEvent = modelInstance.getModelElementsByType(StartEvent.class).iterator().next();
  assertThat(startEvent.getId()).isNull();

  UserTask userTask = modelInstance.getModelElementsByType(UserTask.class).iterator().next();
  assertThat(userTask.getId()).isNull();
}
 
Example #24
Source File: GenerateIdTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldGenerateIdsOnCreate() {
  BpmnModelInstance modelInstance = Bpmn.createEmptyModel();
  Definitions definitions = modelInstance.newInstance(Definitions.class);
  assertThat(definitions.getId()).isNotNull();

  Process process = modelInstance.newInstance(Process.class);
  assertThat(process.getId()).isNotNull();

  StartEvent startEvent = modelInstance.newInstance(StartEvent.class);
  assertThat(startEvent.getId()).isNotNull();

  UserTask userTask = modelInstance.newInstance(UserTask.class);
  assertThat(userTask.getId()).isNotNull();
}
 
Example #25
Source File: ProcessBuilderTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void getElementTypes() {
  Model model = Bpmn.createEmptyModel().getModel();
  taskType = model.getType(Task.class);
  gatewayType = model.getType(Gateway.class);
  eventType = model.getType(Event.class);
  processType = model.getType(Process.class);
}
 
Example #26
Source File: ModifiableBpmnModelInstance.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public ModifiableBpmnModelInstance addDocumentation(String content) {
  Collection<Process> processes = modelInstance.getModelElementsByType(Process.class);
  Documentation documentation = modelInstance.newInstance(Documentation.class);
  documentation.setTextContent(content);
  for (Process process : processes) {
    process.addChildElement(documentation);
  }
  return this;
}
 
Example #27
Source File: ProcessBuilderTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testBaseElementDocumentation() {
  modelInstance = Bpmn.createProcess("process")
          .documentation("processDocumentation")
          .startEvent("startEvent")
          .documentation("startEventDocumentation_1")
          .documentation("startEventDocumentation_2")
          .documentation("startEventDocumentation_3")
          .userTask("task")
          .documentation("taskDocumentation")
          .businessRuleTask("businessruletask")
          .subProcess("subprocess")
          .documentation("subProcessDocumentation")
          .embeddedSubProcess()
          .startEvent("subprocessStartEvent")
          .endEvent("subprocessEndEvent")
          .subProcessDone()
          .endEvent("endEvent")
          .documentation("endEventDocumentation")
          .done();

  assertThat(((Process) modelInstance.getModelElementById("process")).getDocumentations().iterator().next().getTextContent()).isEqualTo("processDocumentation");
  assertThat(((UserTask) modelInstance.getModelElementById("task")).getDocumentations().iterator().next().getTextContent()).isEqualTo("taskDocumentation");
  assertThat(((SubProcess) modelInstance.getModelElementById("subprocess")).getDocumentations().iterator().next().getTextContent()).isEqualTo("subProcessDocumentation");
  assertThat(((EndEvent) modelInstance.getModelElementById("endEvent")).getDocumentations().iterator().next().getTextContent()).isEqualTo("endEventDocumentation");

  final Documentation[] startEventDocumentations = ((StartEvent) modelInstance.getModelElementById("startEvent")).getDocumentations().toArray(new Documentation[]{});
  assertThat(startEventDocumentations.length).isEqualTo(3);
  for (int i = 1; i <=3; i++) {
    assertThat(startEventDocumentations[i - 1].getTextContent()).isEqualTo("startEventDocumentation_" + i);
  }
}
 
Example #28
Source File: ProcessBuilderTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testProcessStartableInTasklist() {
  modelInstance = Bpmn.createProcess(PROCESS_ID)
    .startEvent()
    .endEvent()
    .done();

  Process process = modelInstance.getModelElementById(PROCESS_ID);
  assertThat(process.isCamundaStartableInTasklist()).isEqualTo(true);
}
 
Example #29
Source File: CreateModelTest.java    From camunda-bpmn-model with Apache License 2.0 5 votes vote down vote up
@Test
public void createProcessWithOneTask() {
  // create process
  Process process = createElement(definitions, "process-with-one-task", Process.class);

  // create elements
  StartEvent startEvent = createElement(process, "start", StartEvent.class);
  UserTask task1 = createElement(process, "task1", UserTask.class);
  EndEvent endEvent = createElement(process, "end", EndEvent.class);

  // create flows
  createSequenceFlow(process, startEvent, task1);
  createSequenceFlow(process, task1, endEvent);
}
 
Example #30
Source File: ProcessStartEventValidator.java    From camunda-bpmn-model with Apache License 2.0 5 votes vote down vote up
@Override
public void validate(Process process, ValidationResultCollector validationResultCollector) {
  Collection<StartEvent> startEvents = process.getChildElementsByType(StartEvent.class);
  int startEventCount = startEvents.size();

  if(startEventCount != 1) {
    validationResultCollector.addError(10, String.format("Process does not have exactly one start event. Got %d.", startEventCount));
  }
}