FilesResultMapper { @VisibleForTesting @Nullable String getFilenameFromPath(@Nullable String filePath) { String filename; if (!isEmpty(filePath) && filePath.contains(File.separator) && filePath.contains(".")) { filename = filePath.substring(filePath.lastIndexOf(File.separator) + 1); } else { filename = filePath; } return filename; } @Inject  FilesResultMapper(); @NonNull FilteredFilesResult transform(@Nullable ApiFilesResult apiFilesResult);  }
@Test public void getFilenameForPathShouldReturnNullIfNullPath() { String path = new FilesResultMapper().getFilenameFromPath(null); assertNull(path); }
@Test public void getFilenameForPathShouldRemoveFoldersIfAny() { String path = new FilesResultMapper().getFilenameFromPath("/123/123/123.jpg"); assertEquals("123.jpg", path); }
@Test public void getFilenameForPathShouldReturnSelfIfNoFolders() { String path = new FilesResultMapper().getFilenameFromPath("123.jpg"); assertEquals("123.jpg", path); }