@Test public void shouldTraverseTheTreeNode() { TreeNode toFind = FileManagerCreators.createValidTreeNode("asdf"); List<SimpleNode> expected = Arrays.asList(new SimpleNode("2"), new SimpleNode("3"), new SimpleNode("4"), new SimpleNode("1"), new SimpleNode("0"), new SimpleNode("asdf"), new SimpleNode("5")); List<TreeNode> arrayOfNodes = FileManagerCreators.createNestedHierarchyOfNodes(toFind); List<SimpleNode> simpleNodes = new ArrayList<>(); sut.transformToSimpleList(arrayOfNodes, simpleNodes); assertThat(simpleNodes).isEqualTo(expected); }
public void transformToSimpleList(List<TreeNode> treeNodes, List<SimpleNode> simple) { for (TreeNode node : treeNodes) { String id = node.getId(); SimpleNode.Type type = getTypeOfNode(node); String label = node.getLabel(); String data = node.getData(); String parentId = node.getParentId(); SimpleNode simpleNode = new SimpleNode(id, type, label, data, parentId); simple.add(simpleNode); if (node.getChildren() != null && node.getChildren() != null) { transformToSimpleList(node.getChildren(), simple); } } }
FileManager { public void transformToSimpleList(List<TreeNode> treeNodes, List<SimpleNode> simple) { for (TreeNode node : treeNodes) { String id = node.getId(); SimpleNode.Type type = getTypeOfNode(node); String label = node.getLabel(); String data = node.getData(); String parentId = node.getParentId(); SimpleNode simpleNode = new SimpleNode(id, type, label, data, parentId); simple.add(simpleNode); if (node.getChildren() != null && node.getChildren() != null) { transformToSimpleList(node.getChildren(), simple); } } } }
FileManager { public void transformToSimpleList(List<TreeNode> treeNodes, List<SimpleNode> simple) { for (TreeNode node : treeNodes) { String id = node.getId(); SimpleNode.Type type = getTypeOfNode(node); String label = node.getLabel(); String data = node.getData(); String parentId = node.getParentId(); SimpleNode simpleNode = new SimpleNode(id, type, label, data, parentId); simple.add(simpleNode); if (node.getChildren() != null && node.getChildren() != null) { transformToSimpleList(node.getChildren(), simple); } } }  }
FileManager { public void transformToSimpleList(List<TreeNode> treeNodes, List<SimpleNode> simple) { for (TreeNode node : treeNodes) { String id = node.getId(); SimpleNode.Type type = getTypeOfNode(node); String label = node.getLabel(); String data = node.getData(); String parentId = node.getParentId(); SimpleNode simpleNode = new SimpleNode(id, type, label, data, parentId); simple.add(simpleNode); if (node.getChildren() != null && node.getChildren() != null) { transformToSimpleList(node.getChildren(), simple); } } }  Path createTempDir(); Path calculatePathForNode(SimpleNode node, List<SimpleNode> simpleNodes); SimpleNode findSimpleNode(SimpleNode toFind, List<SimpleNode> simpleNodes); void createFiles(Path tempDir, List<SimpleNode> simpleNodes); void transformToSimpleList(List<TreeNode> treeNodes, List<SimpleNode> simple); @Async void deleteFolderRecursively(Path path); void printAllFilesInFolder(Path tempDir); String removeExtension(String path); }
FileManager { public void transformToSimpleList(List<TreeNode> treeNodes, List<SimpleNode> simple) { for (TreeNode node : treeNodes) { String id = node.getId(); SimpleNode.Type type = getTypeOfNode(node); String label = node.getLabel(); String data = node.getData(); String parentId = node.getParentId(); SimpleNode simpleNode = new SimpleNode(id, type, label, data, parentId); simple.add(simpleNode); if (node.getChildren() != null && node.getChildren() != null) { transformToSimpleList(node.getChildren(), simple); } } }  Path createTempDir(); Path calculatePathForNode(SimpleNode node, List<SimpleNode> simpleNodes); SimpleNode findSimpleNode(SimpleNode toFind, List<SimpleNode> simpleNodes); void createFiles(Path tempDir, List<SimpleNode> simpleNodes); void transformToSimpleList(List<TreeNode> treeNodes, List<SimpleNode> simple); @Async void deleteFolderRecursively(Path path); void printAllFilesInFolder(Path tempDir); String removeExtension(String path);  }