@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(); }
@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(); }
/** * Returns the name of the user task after the start event. * * @param modelInstance the BPMN model instance * @return the name attribute value of the user task */ protected String getUserTaskName(BpmnModelInstance modelInstance) { StartEvent startEvent = getStartEvent(modelInstance); UserTask userTask = (UserTask) startEvent.getSucceedingNodes().singleResult(); return stripLineBreaks(userTask.getName()); }
/** * Gets the succeeding exclusive gateway of the current task. * * @param taskId the ID of the current task * @param modelInstance the BPMN model instance * @return the succeeding exclusive gateway element */ private ExclusiveGateway getExclusiveGateway(String taskId, BpmnModelInstance modelInstance) { UserTask userTask = (UserTask) modelInstance.getModelElementById(taskId); return (ExclusiveGateway) userTask.getSucceedingNodes().singleResult(); }