@Test public void shouldCalculatePath() { SimpleNode toFind = FileManagerCreators.createValidSimpleNode("asdf", "myfile.java", "0"); List<SimpleNode> arrayOfNodes = FileManagerCreators.createSimpleListOfNodes(toFind); Path path = sut.calculatePathForNode(toFind, arrayOfNodes); assertThat(path.toString()).isEqualTo("src/main/java/com/company/project/myfile.java"); }
public Path calculatePathForNode(SimpleNode node, List<SimpleNode> simpleNodes) { List<SimpleNode> parents = findParentsForNode(node, simpleNodes); String path = ""; for (SimpleNode p : parents) { String label = p.getLabel(); label = label.replaceAll("\\.", "\\/"); if (p.getType() == FOLDER) { label = label + "/"; } path += label; } String label = (node.getType() == FOLDER) ? node.getLabel().replaceAll("\\.", "\\/") : node.getLabel(); return Paths.get(path, label); }
FileManager { public Path calculatePathForNode(SimpleNode node, List<SimpleNode> simpleNodes) { List<SimpleNode> parents = findParentsForNode(node, simpleNodes); String path = ""; for (SimpleNode p : parents) { String label = p.getLabel(); label = label.replaceAll("\\.", "\\/"); if (p.getType() == FOLDER) { label = label + "/"; } path += label; } String label = (node.getType() == FOLDER) ? node.getLabel().replaceAll("\\.", "\\/") : node.getLabel(); return Paths.get(path, label); } }
FileManager { public Path calculatePathForNode(SimpleNode node, List<SimpleNode> simpleNodes) { List<SimpleNode> parents = findParentsForNode(node, simpleNodes); String path = ""; for (SimpleNode p : parents) { String label = p.getLabel(); label = label.replaceAll("\\.", "\\/"); if (p.getType() == FOLDER) { label = label + "/"; } path += label; } String label = (node.getType() == FOLDER) ? node.getLabel().replaceAll("\\.", "\\/") : node.getLabel(); return Paths.get(path, label); }  }
FileManager { public Path calculatePathForNode(SimpleNode node, List<SimpleNode> simpleNodes) { List<SimpleNode> parents = findParentsForNode(node, simpleNodes); String path = ""; for (SimpleNode p : parents) { String label = p.getLabel(); label = label.replaceAll("\\.", "\\/"); if (p.getType() == FOLDER) { label = label + "/"; } path += label; } String label = (node.getType() == FOLDER) ? node.getLabel().replaceAll("\\.", "\\/") : node.getLabel(); return Paths.get(path, label); }  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 Path calculatePathForNode(SimpleNode node, List<SimpleNode> simpleNodes) { List<SimpleNode> parents = findParentsForNode(node, simpleNodes); String path = ""; for (SimpleNode p : parents) { String label = p.getLabel(); label = label.replaceAll("\\.", "\\/"); if (p.getType() == FOLDER) { label = label + "/"; } path += label; } String label = (node.getType() == FOLDER) ? node.getLabel().replaceAll("\\.", "\\/") : node.getLabel(); return Paths.get(path, label); }  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);  }