### Question:
StorageManagerUtil { public static boolean isValidFilename(String fullname) { if (StringUtils.isBlank(fullname)) { return false; } if (fullname.endsWith(".")) { return false; } if (!isValidPath(fullname)) { return false; } String basename = FilenameUtils.getBaseName(fullname); String extension = FilenameUtils.getExtension(fullname); return isValidFilename(basename, extension); } private  StorageManagerUtil(); static boolean isValidFilename(String fullname); static boolean isValidFilename(String basename, String extension); static boolean isValidFilenameNoExtension(String basename); static boolean isValidDirName(String basename); static boolean isValidExtension(String extension);  }### Answer:
@Test public void isValidFilename_1() { Assert.assertFalse(StorageManagerUtil.isValidFilename(null)); Assert.assertFalse(StorageManagerUtil.isValidFilename(" ")); Assert.assertFalse(StorageManagerUtil.isValidFilename(".txt")); Assert.assertFalse(StorageManagerUtil.isValidFilename("filename.")); Assert.assertTrue(StorageManagerUtil.isValidFilename("filename.txt")); Assert.assertTrue(StorageManagerUtil.isValidFilename("file name.png")); Assert.assertTrue(StorageManagerUtil.isValidFilename("file_name.png")); Assert.assertTrue(StorageManagerUtil.isValidFilename("file_name (1).jpeg")); Assert.assertFalse(StorageManagerUtil.isValidFilename("file_?name (1).jpeg")); Assert.assertFalse(StorageManagerUtil.isValidFilename("file_../name")); Assert.assertFalse(StorageManagerUtil.isValidFilename("file_../name.jpg")); }
@Test public void isValidFilename_2() { Assert.assertFalse(StorageManagerUtil.isValidFilename(null, null)); Assert.assertFalse(StorageManagerUtil.isValidFilename(" ", null)); Assert.assertFalse(StorageManagerUtil.isValidFilename(null, " ")); Assert.assertFalse(StorageManagerUtil.isValidFilename(" ", "")); Assert.assertFalse(StorageManagerUtil.isValidFilename(null, ".txt")); Assert.assertTrue(StorageManagerUtil.isValidFilename("filename", "")); Assert.assertTrue(StorageManagerUtil.isValidFilename("filename", "txt")); Assert.assertTrue(StorageManagerUtil.isValidFilename("filename.txt", "txt")); Assert.assertTrue(StorageManagerUtil.isValidFilename("file name", "png")); Assert.assertTrue(StorageManagerUtil.isValidFilename("file_name", "png")); Assert.assertTrue(StorageManagerUtil.isValidFilename("file_name (1)", "jpeg")); Assert.assertTrue(StorageManagerUtil.isValidFilename("file_name (1).jpg", "jpeg")); Assert.assertFalse(StorageManagerUtil.isValidFilename("file_?name (1)", "jpeg")); Assert.assertFalse(StorageManagerUtil.isValidFilename("file_../name", "")); Assert.assertFalse(StorageManagerUtil.isValidFilename("file_../name", "jpg")); }