@Test public void testGetImportedDrgElementsByShape() { final DMNMarshallerStandalone marshaller = spy(getDMNMarshaller()); final List<org.kie.dmn.model.api.DRGElement> importedDRGElements = mock(List.class); final Map<Import, org.kie.dmn.model.api.Definitions> importDefinitions = mock(Map.class); final org.kie.dmn.model.api.DRGElement ref1 = mock(org.kie.dmn.model.api.DRGElement.class); final org.kie.dmn.model.api.DRGElement ref2 = mock(org.kie.dmn.model.api.DRGElement.class); final org.kie.dmn.model.api.DRGElement ref3 = mock(org.kie.dmn.model.api.DRGElement.class); final List<DMNShape> dmnShapes = new ArrayList<>(); final DMNShape shape1 = mock(DMNShape.class); final DMNShape shape2 = mock(DMNShape.class); final DMNShape shape3 = mock(DMNShape.class); dmnShapes.add(shape1); dmnShapes.add(shape2); dmnShapes.add(shape3); doReturn("REF1").when(marshaller).getDmnElementRef(shape1); doReturn("REF2").when(marshaller).getDmnElementRef(shape2); doReturn("REF3").when(marshaller).getDmnElementRef(shape3); when(dmnMarshallerImportsHelper.getImportedDRGElements(importDefinitions)).thenReturn(importedDRGElements); doReturn(Optional.of(ref1)).when(marshaller).getReference(importedDRGElements, "REF1"); doReturn(Optional.of(ref2)).when(marshaller).getReference(importedDRGElements, "REF2"); doReturn(Optional.of(ref3)).when(marshaller).getReference(importedDRGElements, "REF3"); final List<DRGElement> actual = marshaller.getImportedDrgElementsByShape(dmnShapes, importDefinitions); assertEquals(ref1, actual.get(0)); assertEquals(ref2, actual.get(1)); assertEquals(ref3, actual.get(2)); }
List<org.kie.dmn.model.api.DRGElement> getImportedDrgElementsByShape(final List<DMNShape> dmnShapes, final Map<Import, org.kie.dmn.model.api.Definitions> importDefinitions) { final List<org.kie.dmn.model.api.DRGElement> importedDRGElements = dmnMarshallerImportsHelper.getImportedDRGElements(importDefinitions); return dmnShapes .stream() .map(shape -> { final String dmnElementRef = getDmnElementRef(shape); final Optional<org.kie.dmn.model.api.DRGElement> ref = getReference(importedDRGElements, dmnElementRef); return ref.orElse(null); }) .filter(Objects::nonNull) .collect(Collectors.toList()); }
DMNMarshallerStandalone implements DiagramMarshaller<Graph, Metadata, Diagram<Graph, Metadata>> { List<org.kie.dmn.model.api.DRGElement> getImportedDrgElementsByShape(final List<DMNShape> dmnShapes, final Map<Import, org.kie.dmn.model.api.Definitions> importDefinitions) { final List<org.kie.dmn.model.api.DRGElement> importedDRGElements = dmnMarshallerImportsHelper.getImportedDRGElements(importDefinitions); return dmnShapes .stream() .map(shape -> { final String dmnElementRef = getDmnElementRef(shape); final Optional<org.kie.dmn.model.api.DRGElement> ref = getReference(importedDRGElements, dmnElementRef); return ref.orElse(null); }) .filter(Objects::nonNull) .collect(Collectors.toList()); } }
DMNMarshallerStandalone implements DiagramMarshaller<Graph, Metadata, Diagram<Graph, Metadata>> { List<org.kie.dmn.model.api.DRGElement> getImportedDrgElementsByShape(final List<DMNShape> dmnShapes, final Map<Import, org.kie.dmn.model.api.Definitions> importDefinitions) { final List<org.kie.dmn.model.api.DRGElement> importedDRGElements = dmnMarshallerImportsHelper.getImportedDRGElements(importDefinitions); return dmnShapes .stream() .map(shape -> { final String dmnElementRef = getDmnElementRef(shape); final Optional<org.kie.dmn.model.api.DRGElement> ref = getReference(importedDRGElements, dmnElementRef); return ref.orElse(null); }) .filter(Objects::nonNull) .collect(Collectors.toList()); } protected  DMNMarshallerStandalone(); @Inject  DMNMarshallerStandalone(final XMLEncoderDiagramMetadataMarshaller diagramMetadataMarshaller,
                                   final FactoryManager factoryManager,
                                   final DMNMarshallerImportsHelperStandalone dmnMarshallerImportsHelper,
                                   final DMNMarshaller marshaller); }
DMNMarshallerStandalone implements DiagramMarshaller<Graph, Metadata, Diagram<Graph, Metadata>> { List<org.kie.dmn.model.api.DRGElement> getImportedDrgElementsByShape(final List<DMNShape> dmnShapes, final Map<Import, org.kie.dmn.model.api.Definitions> importDefinitions) { final List<org.kie.dmn.model.api.DRGElement> importedDRGElements = dmnMarshallerImportsHelper.getImportedDRGElements(importDefinitions); return dmnShapes .stream() .map(shape -> { final String dmnElementRef = getDmnElementRef(shape); final Optional<org.kie.dmn.model.api.DRGElement> ref = getReference(importedDRGElements, dmnElementRef); return ref.orElse(null); }) .filter(Objects::nonNull) .collect(Collectors.toList()); } protected  DMNMarshallerStandalone(); @Inject  DMNMarshallerStandalone(final XMLEncoderDiagramMetadataMarshaller diagramMetadataMarshaller,
                                   final FactoryManager factoryManager,
                                   final DMNMarshallerImportsHelperStandalone dmnMarshallerImportsHelper,
                                   final DMNMarshaller marshaller); @Override @SuppressWarnings("unchecked") Graph unmarshall(final Metadata metadata,
                            final InputStream input); static Node<?, ?> findDMNDiagramRoot(final Graph<?, Node<View, ?>> graph); @SuppressWarnings({"rawtypes", "unchecked"}) static void connectRootWithChild(final Node dmnDiagramRoot,
                                            final Node child); @SuppressWarnings({"rawtypes", "unchecked"}) static void connectEdge(final Edge edge,
                                   final Node source,
                                   final Node target); @Override @SuppressWarnings("unchecked") String marshall(final Diagram<Graph, Metadata> diagram); @Override DiagramMetadataMarshaller<Metadata> getMetadataMarshaller(); }
DMNMarshallerStandalone implements DiagramMarshaller<Graph, Metadata, Diagram<Graph, Metadata>> { List<org.kie.dmn.model.api.DRGElement> getImportedDrgElementsByShape(final List<DMNShape> dmnShapes, final Map<Import, org.kie.dmn.model.api.Definitions> importDefinitions) { final List<org.kie.dmn.model.api.DRGElement> importedDRGElements = dmnMarshallerImportsHelper.getImportedDRGElements(importDefinitions); return dmnShapes .stream() .map(shape -> { final String dmnElementRef = getDmnElementRef(shape); final Optional<org.kie.dmn.model.api.DRGElement> ref = getReference(importedDRGElements, dmnElementRef); return ref.orElse(null); }) .filter(Objects::nonNull) .collect(Collectors.toList()); } protected  DMNMarshallerStandalone(); @Inject  DMNMarshallerStandalone(final XMLEncoderDiagramMetadataMarshaller diagramMetadataMarshaller,
                                   final FactoryManager factoryManager,
                                   final DMNMarshallerImportsHelperStandalone dmnMarshallerImportsHelper,
                                   final DMNMarshaller marshaller); @Override @SuppressWarnings("unchecked") Graph unmarshall(final Metadata metadata,
                            final InputStream input); static Node<?, ?> findDMNDiagramRoot(final Graph<?, Node<View, ?>> graph); @SuppressWarnings({"rawtypes", "unchecked"}) static void connectRootWithChild(final Node dmnDiagramRoot,
                                            final Node child); @SuppressWarnings({"rawtypes", "unchecked"}) static void connectEdge(final Edge edge,
                                   final Node source,
                                   final Node target); @Override @SuppressWarnings("unchecked") String marshall(final Diagram<Graph, Metadata> diagram); @Override DiagramMetadataMarshaller<Metadata> getMetadataMarshaller(); static final String INFO_REQ_ID; static final String KNOWLEDGE_REQ_ID; static final String AUTH_REQ_ID; static final String ASSOCIATION_ID; }