@Test public void testWithIncludedModelsWhenNodeParentIsDefinitions() { final DMNMarshaller dmnMarshaller = spy(new DMNMarshaller()); final Node node = mock(Node.class); final Definition nodeDefinition = mock(Definition.class); final DRGElement drgElement = mock(DRGElement.class); final Definitions definitionsStunnerPojo = mock(Definitions.class); final Import import1 = mock(Import.class); final Import import2 = mock(Import.class); final List<Import> diagramImports = new ArrayList<>(asList(import1, import2)); final Definitions nodeDiagramDefinitions = mock(Definitions.class); final List<Import> nodeDiagramImports = new ArrayList<>(); when(node.getContent()).thenReturn(nodeDefinition); when(nodeDefinition.getDefinition()).thenReturn(drgElement); when(definitionsStunnerPojo.getImport()).thenReturn(diagramImports); when(drgElement.getParent()).thenReturn(nodeDiagramDefinitions); when(nodeDiagramDefinitions.getImport()).thenReturn(nodeDiagramImports); dmnMarshaller.withIncludedModels(node, definitionsStunnerPojo); assertEquals(2, nodeDiagramImports.size()); assertTrue(nodeDiagramImports.contains(import1)); assertTrue(nodeDiagramImports.contains(import2)); }
Node<?, ?> withIncludedModels(final Node<?, ?> node, final Definitions definitionsStunnerPojo) { final Object elementDefinition = getElementDefinition(node); final List<Import> diagramImports = definitionsStunnerPojo.getImport(); if (!(elementDefinition instanceof DRGElement) || diagramImports.isEmpty()) { return node; } final DRGElement drgElement = (DRGElement) elementDefinition; final Optional<Definitions> nodeDefinitions = getDefinitions(drgElement); if (!nodeDefinitions.isPresent()) { return node; } final List<Import> nodeImports = nodeDefinitions.get().getImport(); updateNodeImports(diagramImports, nodeImports); return node; }
DMNMarshaller { Node<?, ?> withIncludedModels(final Node<?, ?> node, final Definitions definitionsStunnerPojo) { final Object elementDefinition = getElementDefinition(node); final List<Import> diagramImports = definitionsStunnerPojo.getImport(); if (!(elementDefinition instanceof DRGElement) || diagramImports.isEmpty()) { return node; } final DRGElement drgElement = (DRGElement) elementDefinition; final Optional<Definitions> nodeDefinitions = getDefinitions(drgElement); if (!nodeDefinitions.isPresent()) { return node; } final List<Import> nodeImports = nodeDefinitions.get().getImport(); updateNodeImports(diagramImports, nodeImports); return node; } }
DMNMarshaller { Node<?, ?> withIncludedModels(final Node<?, ?> node, final Definitions definitionsStunnerPojo) { final Object elementDefinition = getElementDefinition(node); final List<Import> diagramImports = definitionsStunnerPojo.getImport(); if (!(elementDefinition instanceof DRGElement) || diagramImports.isEmpty()) { return node; } final DRGElement drgElement = (DRGElement) elementDefinition; final Optional<Definitions> nodeDefinitions = getDefinitions(drgElement); if (!nodeDefinitions.isPresent()) { return node; } final List<Import> nodeImports = nodeDefinitions.get().getImport(); updateNodeImports(diagramImports, nodeImports); return node; } protected  DMNMarshaller(); @Inject  DMNMarshaller(final FactoryManager factoryManager); }
DMNMarshaller { Node<?, ?> withIncludedModels(final Node<?, ?> node, final Definitions definitionsStunnerPojo) { final Object elementDefinition = getElementDefinition(node); final List<Import> diagramImports = definitionsStunnerPojo.getImport(); if (!(elementDefinition instanceof DRGElement) || diagramImports.isEmpty()) { return node; } final DRGElement drgElement = (DRGElement) elementDefinition; final Optional<Definitions> nodeDefinitions = getDefinitions(drgElement); if (!nodeDefinitions.isPresent()) { return node; } final List<Import> nodeImports = nodeDefinitions.get().getImport(); updateNodeImports(diagramImports, nodeImports); return node; } protected  DMNMarshaller(); @Inject  DMNMarshaller(final FactoryManager factoryManager); @PostConstruct void init(); JSITDefinitions marshall(); List<Node> getNodeStream(final Diagram diagram); @SuppressWarnings("unchecked") JSITDRGElement stunnerToDMN(final Node<?, ?> node,
                                       final Consumer<JSITComponentWidths> componentWidthsConsumer); }
DMNMarshaller { Node<?, ?> withIncludedModels(final Node<?, ?> node, final Definitions definitionsStunnerPojo) { final Object elementDefinition = getElementDefinition(node); final List<Import> diagramImports = definitionsStunnerPojo.getImport(); if (!(elementDefinition instanceof DRGElement) || diagramImports.isEmpty()) { return node; } final DRGElement drgElement = (DRGElement) elementDefinition; final Optional<Definitions> nodeDefinitions = getDefinitions(drgElement); if (!nodeDefinitions.isPresent()) { return node; } final List<Import> nodeImports = nodeDefinitions.get().getImport(); updateNodeImports(diagramImports, nodeImports); return node; } protected  DMNMarshaller(); @Inject  DMNMarshaller(final FactoryManager factoryManager); @PostConstruct void init(); JSITDefinitions marshall(); List<Node> getNodeStream(final Diagram diagram); @SuppressWarnings("unchecked") JSITDRGElement stunnerToDMN(final Node<?, ?> node,
                                       final Consumer<JSITComponentWidths> componentWidthsConsumer); static final String PREFIX; }