@Test public void testGetUniqueDMNShapes() { final DMNMarshallerStandalone marshaller = spy(getDMNMarshaller()); final org.kie.dmn.model.api.dmndi.DMNDiagram diagram = mock(org.kie.dmn.model.api.dmndi.DMNDiagram.class); final List<DiagramElement> elements = new ArrayList<>(); final DMNShape unique1 = mock(DMNShape.class); when(unique1.getId()).thenReturn("unique1"); final DMNShape unique2 = mock(DMNShape.class); when(unique2.getId()).thenReturn("unique2"); final DMNShape duplicate1 = mock(DMNShape.class); when(duplicate1.getId()).thenReturn("duplicate"); final DMNShape duplicate2 = mock(DMNShape.class); when(duplicate2.getId()).thenReturn("duplicate"); elements.add(unique1); elements.add(unique2); elements.add(duplicate1); elements.add(duplicate2); when(diagram.getDMNDiagramElement()).thenReturn(elements); final List<DMNShape> actual = marshaller.getUniqueDMNShapes(diagram); assertEquals(3, actual.size()); assertTrue(actual.contains(unique1)); assertTrue(actual.contains(unique2)); assertTrue(actual.contains(duplicate1) || actual.contains(duplicate2)); }
List<DMNShape> getUniqueDMNShapes(final org.kie.dmn.model.api.dmndi.DMNDiagram dmnDDDiagram) { return new ArrayList<>(dmnDDDiagram .getDMNDiagramElement() .stream() .filter(diagramElements -> diagramElements instanceof DMNShape) .map(d -> (DMNShape) d) .collect(toMap(DMNShape::getId, shape -> shape, (shape1, shape2) -> shape1)) .values()); }
DMNMarshallerStandalone implements DiagramMarshaller<Graph, Metadata, Diagram<Graph, Metadata>> { List<DMNShape> getUniqueDMNShapes(final org.kie.dmn.model.api.dmndi.DMNDiagram dmnDDDiagram) { return new ArrayList<>(dmnDDDiagram .getDMNDiagramElement() .stream() .filter(diagramElements -> diagramElements instanceof DMNShape) .map(d -> (DMNShape) d) .collect(toMap(DMNShape::getId, shape -> shape, (shape1, shape2) -> shape1)) .values()); } }
DMNMarshallerStandalone implements DiagramMarshaller<Graph, Metadata, Diagram<Graph, Metadata>> { List<DMNShape> getUniqueDMNShapes(final org.kie.dmn.model.api.dmndi.DMNDiagram dmnDDDiagram) { return new ArrayList<>(dmnDDDiagram .getDMNDiagramElement() .stream() .filter(diagramElements -> diagramElements instanceof DMNShape) .map(d -> (DMNShape) d) .collect(toMap(DMNShape::getId, shape -> shape, (shape1, shape2) -> shape1)) .values()); } 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<DMNShape> getUniqueDMNShapes(final org.kie.dmn.model.api.dmndi.DMNDiagram dmnDDDiagram) { return new ArrayList<>(dmnDDDiagram .getDMNDiagramElement() .stream() .filter(diagramElements -> diagramElements instanceof DMNShape) .map(d -> (DMNShape) d) .collect(toMap(DMNShape::getId, shape -> shape, (shape1, shape2) -> shape1)) .values()); } 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<DMNShape> getUniqueDMNShapes(final org.kie.dmn.model.api.dmndi.DMNDiagram dmnDDDiagram) { return new ArrayList<>(dmnDDDiagram .getDMNDiagramElement() .stream() .filter(diagramElements -> diagramElements instanceof DMNShape) .map(d -> (DMNShape) d) .collect(toMap(DMNShape::getId, shape -> shape, (shape1, shape2) -> shape1)) .values()); } 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; }