FileUtil { public List<File> listFiles(File file) { if (file != null && file.exists()) { return asList(file.listFiles()); } else { return new ArrayList<>(); } }  String copyFile(File sourceFile, File destFile); File getFileAtPath(String path); String getRandomFilename(); File getItemsetFile(String mediaFolderPath); List<File> listFiles(File file);  }
@Test public void whenTryToListFilesOnNullFile_shouldReturnEmptyArray() { assertThat(new FileUtil().listFiles(null), is(empty())); }
@Test public void whenTryToListFilesOnFileThatDoesNotExist_shouldReturnEmptyArray() { File file = mock(File.class); when(file.exists()).thenReturn(false); assertThat(new FileUtil().listFiles(file), is(empty())); }