### Question:
DMNIncludedNodesFilter { public List<DMNIncludedNode> getNodesFromImports(final Path path, final List<DMNIncludedModel> includedModels) { try { final Diagram<Graph, Metadata> diagram = diagramHelper.getDiagramByPath(path); final Optional<DMNIncludedModel> diagramImport = getDiagramImport(diagram, includedModels); return diagramImport .map(dmn -> diagramHelper .getNodes(diagram) .stream() .map(node -> factory.makeDMNIncludeModel(path, dmn, node)) .collect(Collectors.toList())) .orElse(new ArrayList<>()); } catch (final Exception e) { } return new ArrayList<>(); } @Inject  DMNIncludedNodesFilter(final DMNDiagramHelper diagramHelper,
                                  final DMNIncludedNodeFactory factory); List<DMNIncludedNode> getNodesFromImports(final Path path,
                                                     final List<DMNIncludedModel> includedModels);  }### Answer:
@Test public void testGetNodesFromImports() { final Path path = mock(Path.class); final DMNIncludedModel includedModel1 = mock(DMNIncludedModel.class); final DMNIncludedModel includedModel2 = mock(DMNIncludedModel.class); final DMNIncludedModel includedModel3 = mock(DMNIncludedModel.class); final List<DMNIncludedModel> imports = asList(includedModel1, includedModel2, includedModel3); final DMNIncludedNode dmnNode1 = mock(DMNIncludedNode.class); final DMNIncludedNode dmnNode2 = mock(DMNIncludedNode.class); final Decision node1 = new Decision(); final InputData node2 = new InputData(); final List<DRGElement> diagramNodes = asList(node1, node2); when(includedModel1.getNamespace()).thenReturn(": when(includedModel2.getNamespace()).thenReturn(": when(includedModel3.getNamespace()).thenReturn(": when(diagramHelper.getDiagramByPath(path)).thenReturn(diagram); when(diagramHelper.getNodes(diagram)).thenReturn(diagramNodes); when(diagramHelper.getNamespace(diagram)).thenReturn(": when(factory.makeDMNIncludeModel(path, includedModel1, node1)).thenReturn(dmnNode1); when(factory.makeDMNIncludeModel(path, includedModel1, node2)).thenReturn(dmnNode2); final List<DMNIncludedNode> actualNodes = filter.getNodesFromImports(path, imports); final List<DMNIncludedNode> expectedNodes = asList(dmnNode1, dmnNode2); assertEquals(expectedNodes, actualNodes); }
@Test public void testGetNodesFromImportsWhenPathDoesNotRepresentsAnImportedDiagram() { final Path path = mock(Path.class); final DMNIncludedModel includedModel1 = mock(DMNIncludedModel.class); final DMNIncludedModel includedModel2 = mock(DMNIncludedModel.class); final DMNIncludedModel includedModel3 = mock(DMNIncludedModel.class); final List<DMNIncludedModel> imports = asList(includedModel1, includedModel2, includedModel3); when(includedModel1.getNamespace()).thenReturn(": when(includedModel2.getNamespace()).thenReturn(": when(includedModel3.getNamespace()).thenReturn(": when(diagramHelper.getDiagramByPath(path)).thenReturn(diagram); when(diagramHelper.getNamespace(diagram)).thenReturn(": final List<DMNIncludedNode> actualNodes = filter.getNodesFromImports(path, imports); final List<DMNIncludedNode> expectedNodes = emptyList(); assertEquals(expectedNodes, actualNodes); }