FilePathReader { public List<String> getShortFilePaths(final String path) { List<String> result = new ArrayList<>(); File folder = fileFactory.createFile(path); Collection<File> files = fileUtils.listFiles(folder); for (File file : files) { result.add(getSimpleName(path, file)); } return result; }  List<String> getFilePaths(final String path); List<String> getShortFilePaths(final String path);  }
@Test public void testGetShortFilePathsShouldReturnWithEmptyListWhenTargetFolderIsEmpty() { given(fileFactory.createFile(PATH)).willReturn(file); given(fileUtils.listFiles(file)).willReturn(new ArrayList<File>()); List<String> actual = underTest.getShortFilePaths(PATH); Assert.assertEquals(actual.size(), 0); }
@Test public void testGetShortFilePathsShouldReturnListWithOneElementWhenTargetFolderContainsOneFile() { given(fileFactory.createFile(PATH)).willReturn(file); List<File> fileList = new ArrayList<File>(); fileList.add(file); given(fileUtils.listFiles(file)).willReturn(fileList); given(file.toString()).willReturn(PATH + "\\" + SHORT_PATH); List<String> actual = underTest.getShortFilePaths(PATH); Assert.assertEquals(actual.get(0), SHORT_PATH); }