### Question:
BpmnModelImporter { public Collection<FlowDefinition> fromBpmnXml(InputStream bpmnStream) { BpmnModelInstance modelInstance = Bpmn.readModelFromStream(bpmnStream); Collection<Process> processes = modelInstance.getModelElementsByType(Process.class); List<FlowDefinition> flowDefinitions = new ArrayList<FlowDefinition>(); for (Process process: processes) { flowDefinitions.add(new BpmnProcessFlowBuilder(process).getDefinition()); } return flowDefinitions; }  Collection<FlowDefinition> fromBpmnXml(InputStream bpmnStream);  }### Answer:
@Test public void shouldTransformBpmnModelToFlowDefinition() { BpmnModelImporter bpmnModelImporter = new BpmnModelImporter(); Collection<FlowDefinition> flowDefinition = bpmnModelImporter.fromBpmnXml(getClass().getClassLoader().getResourceAsStream("simple-process.bpmn")); FlowDefinition importedDefinition = flowDefinition.iterator().next(); FlowDefinitionAssert.assertThat(importedDefinition) .hasFlowNodesWithType(EventDefinition.class, 3) .hasFlowNodesWithType(TaskDefinition.class, 3) .hasFlowNodesWithType(ChoiceDefinition.class, 1) .hasFlowNodesWithType(JoinDefinition.class, 1) .hasEdgesCount(8); TaskDefinition task1 = (TaskDefinition) importedDefinition.getNode(id("Task_0zf0c5m")); assertThat(task1.isRetryAsync()).isTrue(); assertThat(task1.getTaskScript().isPresent()).isTrue(); assertThat(task1.getTaskScript().get().getLanguage()).isEqualTo("JavaScript"); assertThat(task1.getTaskScript().get().getText()).isEqualTo("execution.setProperty(\"foo\", \"bar\");"); TaskDefinition task2 = (TaskDefinition) importedDefinition.getNode(id("Task_09b543m")); assertThat(task2.getDelegateClass()).isEqualTo(Task.class); assertThat(task2.isAsync()).isTrue(); assertThat(task2.getConfiguration()) .containsEntry("param1", "value1") .containsEntry("param2", "value2"); ChoiceDefinition choice = (ChoiceDefinition) importedDefinition.getNode(id("ExclusiveGateway_0s7cjkk")); Expression expression = firstChoiceExpression(choice); assertThat(expression) .isInstanceOf(JuelExpression.class); assertThat(((JuelExpression) expression).getValue()).isEqualTo("x == 1"); System.out.println(new BpmnModelExporter().toBpmnXml(importedDefinition)); }