HttpFile { public static String getOriginalFilename(String filename) { Preconditions.checkNotNull(filename, "File name is required"); int pos = filename.lastIndexOf("/"); if (pos == -1) { pos = filename.lastIndexOf("\\"); } if (pos != -1) { return filename.substring(pos + 1); } else { return filename; } }  static void writeFileInResponseForVisualization(HttpServletRequest request, HttpServletResponse response, Path filePath); static void writeFileInResponseForDownload(HttpServletResponse response, Path filePath); static void writeFileInResponse(HttpServletRequest request, HttpServletResponse response, Path filePath); static String getOriginalFilename(String filename);  }
@Test(expected = NullPointerException.class) public void should_throw_NullPointerException_when_filename_is_null(){ HttpFile.getOriginalFilename(null); }
@Test public void should_find_filename_in_full_linux_path(){ assertThat(HttpFile.getOriginalFilename("/tmp/test/myfile.js")).isEqualTo("myfile.js"); }
@Test public void should_find_filename_in_full_windows_path(){ assertThat(HttpFile.getOriginalFilename("C:\\Users\\frontend\\myfile.js")).isEqualTo("myfile.js"); }
@Test public void should_find_filename_when_no_full_path(){ assertThat(HttpFile.getOriginalFilename("myfile.js")).isEqualTo("myfile.js"); }