@Test public void renameFolderNotExistsTest() { String oldName = "x/y/z"; String newName = "a"; Folder oldFolder = folderView.renameFolder(oldName, newName); assertNull(oldFolder); }
public Folder renameFolder(String oldFolderId, String newFolderId) { String normOldFolderId = Folder.normalizeFolderId(oldFolderId); String normNewFolderId = Folder.normalizeFolderId(newFolderId); if (!hasFolder(normOldFolderId)) return null; if (oldFolderId.equals(Folder.ROOT_FOLDER_ID)) return null; if (normOldFolderId.equals(normNewFolderId)) return getFolder(normOldFolderId); logger.info("Rename {} to {}", normOldFolderId, normNewFolderId); Folder oldFolder = getFolder(normOldFolderId); removeFolder(oldFolderId); oldFolder.rename(normNewFolderId); return oldFolder; }
FolderView implements NoteNameListener, FolderListener { public Folder renameFolder(String oldFolderId, String newFolderId) { String normOldFolderId = Folder.normalizeFolderId(oldFolderId); String normNewFolderId = Folder.normalizeFolderId(newFolderId); if (!hasFolder(normOldFolderId)) return null; if (oldFolderId.equals(Folder.ROOT_FOLDER_ID)) return null; if (normOldFolderId.equals(normNewFolderId)) return getFolder(normOldFolderId); logger.info("Rename {} to {}", normOldFolderId, normNewFolderId); Folder oldFolder = getFolder(normOldFolderId); removeFolder(oldFolderId); oldFolder.rename(normNewFolderId); return oldFolder; } }
FolderView implements NoteNameListener, FolderListener { public Folder renameFolder(String oldFolderId, String newFolderId) { String normOldFolderId = Folder.normalizeFolderId(oldFolderId); String normNewFolderId = Folder.normalizeFolderId(newFolderId); if (!hasFolder(normOldFolderId)) return null; if (oldFolderId.equals(Folder.ROOT_FOLDER_ID)) return null; if (normOldFolderId.equals(normNewFolderId)) return getFolder(normOldFolderId); logger.info("Rename {} to {}", normOldFolderId, normNewFolderId); Folder oldFolder = getFolder(normOldFolderId); removeFolder(oldFolderId); oldFolder.rename(normNewFolderId); return oldFolder; }  }
FolderView implements NoteNameListener, FolderListener { public Folder renameFolder(String oldFolderId, String newFolderId) { String normOldFolderId = Folder.normalizeFolderId(oldFolderId); String normNewFolderId = Folder.normalizeFolderId(newFolderId); if (!hasFolder(normOldFolderId)) return null; if (oldFolderId.equals(Folder.ROOT_FOLDER_ID)) return null; if (normOldFolderId.equals(normNewFolderId)) return getFolder(normOldFolderId); logger.info("Rename {} to {}", normOldFolderId, normNewFolderId); Folder oldFolder = getFolder(normOldFolderId); removeFolder(oldFolderId); oldFolder.rename(normNewFolderId); return oldFolder; }  Folder getFolder(String folderId); Folder renameFolder(String oldFolderId, String newFolderId); Folder getFolderOf(Note note); void putNote(Note note); void removeNote(Note note); void clear(); boolean hasFolder(String folderId); boolean hasNote(Note note); int countFolders(); int countNotes(); @Override void onNoteNameChanged(Note note, String oldName); @Override void onFolderRenamed(Folder folder, String oldFolderId); }
FolderView implements NoteNameListener, FolderListener { public Folder renameFolder(String oldFolderId, String newFolderId) { String normOldFolderId = Folder.normalizeFolderId(oldFolderId); String normNewFolderId = Folder.normalizeFolderId(newFolderId); if (!hasFolder(normOldFolderId)) return null; if (oldFolderId.equals(Folder.ROOT_FOLDER_ID)) return null; if (normOldFolderId.equals(normNewFolderId)) return getFolder(normOldFolderId); logger.info("Rename {} to {}", normOldFolderId, normNewFolderId); Folder oldFolder = getFolder(normOldFolderId); removeFolder(oldFolderId); oldFolder.rename(normNewFolderId); return oldFolder; }  Folder getFolder(String folderId); Folder renameFolder(String oldFolderId, String newFolderId); Folder getFolderOf(Note note); void putNote(Note note); void removeNote(Note note); void clear(); boolean hasFolder(String folderId); boolean hasNote(Note note); int countFolders(); int countNotes(); @Override void onNoteNameChanged(Note note, String oldName); @Override void onFolderRenamed(Folder folder, String oldFolderId);  }