@Test public void testGetElementsWithContentId() { final Node node1 = mock(Node.class); final Node node2 = mock(Node.class); final Node node3 = mock(Node.class); final DRGElement contentDefinition1 = mock(DRGElement.class); final DRGElement contentDefinition3 = mock(DRGElement.class); final String theId = "the id"; final String anotherId = "another id"; final List<Node> nodes = Arrays.asList(node1, node2, node3); when(dmnDiagramsSession.getAllNodes()).thenReturn(nodes); when(contentDefinition1.getContentDefinitionId()).thenReturn(theId); when(contentDefinition3.getContentDefinitionId()).thenReturn(anotherId); doReturn(contentDefinition1).when(synchronizer).getDRGElementFromContentDefinition(node1); doReturn(contentDefinition3).when(synchronizer).getDRGElementFromContentDefinition(node3); doReturn(true).when(synchronizer).definitionContainsDRGElement(node1); doReturn(false).when(synchronizer).definitionContainsDRGElement(node2); doReturn(true).when(synchronizer).definitionContainsDRGElement(node3); final List<Node> elements = synchronizer.getElementsWithContentId(theId); verify(synchronizer).definitionContainsDRGElement(node1); verify(synchronizer).definitionContainsDRGElement(node2); verify(synchronizer).definitionContainsDRGElement(node3); verify(synchronizer).getDRGElementFromContentDefinition(node1); verify(synchronizer, never()).getDRGElementFromContentDefinition(node2); verify(synchronizer).getDRGElementFromContentDefinition(node3); assertEquals(1, elements.size()); assertTrue(elements.contains(node1)); }
List<Node> getElementsWithContentId(final String contentDefinitionId) { final List<Node> allNodes = dmnDiagramsSession.getAllNodes(); return allNodes .stream() .filter(node -> definitionContainsDRGElement(node) && Objects.equals(getDRGElementFromContentDefinition(node).getContentDefinitionId(), contentDefinitionId)) .collect(Collectors.toList()); }
DMNElementsSynchronizer { List<Node> getElementsWithContentId(final String contentDefinitionId) { final List<Node> allNodes = dmnDiagramsSession.getAllNodes(); return allNodes .stream() .filter(node -> definitionContainsDRGElement(node) && Objects.equals(getDRGElementFromContentDefinition(node).getContentDefinitionId(), contentDefinitionId)) .collect(Collectors.toList()); } }
DMNElementsSynchronizer { List<Node> getElementsWithContentId(final String contentDefinitionId) { final List<Node> allNodes = dmnDiagramsSession.getAllNodes(); return allNodes .stream() .filter(node -> definitionContainsDRGElement(node) && Objects.equals(getDRGElementFromContentDefinition(node).getContentDefinitionId(), contentDefinitionId)) .collect(Collectors.toList()); } @Inject  DMNElementsSynchronizer(final DMNDiagramsSession dmnDiagramsSession,
                                   final Event<RefreshDecisionComponents> refreshDecisionComponentsEvent,
                                   final DMNGraphUtils graphUtils,
                                   final NodeTextSetter nodeTextSetter); }
DMNElementsSynchronizer { List<Node> getElementsWithContentId(final String contentDefinitionId) { final List<Node> allNodes = dmnDiagramsSession.getAllNodes(); return allNodes .stream() .filter(node -> definitionContainsDRGElement(node) && Objects.equals(getDRGElementFromContentDefinition(node).getContentDefinitionId(), contentDefinitionId)) .collect(Collectors.toList()); } @Inject  DMNElementsSynchronizer(final DMNDiagramsSession dmnDiagramsSession,
                                   final Event<RefreshDecisionComponents> refreshDecisionComponentsEvent,
                                   final DMNGraphUtils graphUtils,
                                   final NodeTextSetter nodeTextSetter); void onExpressionEditorChanged(final @Observes ExpressionEditorChanged event); void onPropertyChanged(final @Observes FormFieldChanged event); void synchronizeElementsFrom(final DRGElement drgElement); void synchronizeFromNode(final Optional<Node> node); }
DMNElementsSynchronizer { List<Node> getElementsWithContentId(final String contentDefinitionId) { final List<Node> allNodes = dmnDiagramsSession.getAllNodes(); return allNodes .stream() .filter(node -> definitionContainsDRGElement(node) && Objects.equals(getDRGElementFromContentDefinition(node).getContentDefinitionId(), contentDefinitionId)) .collect(Collectors.toList()); } @Inject  DMNElementsSynchronizer(final DMNDiagramsSession dmnDiagramsSession,
                                   final Event<RefreshDecisionComponents> refreshDecisionComponentsEvent,
                                   final DMNGraphUtils graphUtils,
                                   final NodeTextSetter nodeTextSetter); void onExpressionEditorChanged(final @Observes ExpressionEditorChanged event); void onPropertyChanged(final @Observes FormFieldChanged event); void synchronizeElementsFrom(final DRGElement drgElement); void synchronizeFromNode(final Optional<Node> node);  }