### Question:
SoapFolderService extends AbstractService implements FolderService { @Override public void rename(String sid, long folderId, String name) throws Exception { User user = validateSession(sid); FolderDAO folderDao = (FolderDAO) Context.get().getBean(FolderDAO.class); if (!folderDao.isPermissionEnabled(Permission.RENAME, folderId, user.getId())) { throw new Exception("user does't have rename permission"); } long rootId = folderDao.findRoot(user.getTenantId()).getId(); if (folderId == rootId) throw new Exception("cannot rename the root folder"); if (folderId == rootId) throw new Exception("cannot rename the Default workspace"); Folder folder = folderDao.findById(folderId); if (folder == null) throw new Exception(String.format("cannot find folder %s", folderId)); folderDao.initialize(folder); List<Folder> folders = folderDao.findByNameAndParentId(name, folder.getParentId()); if (folders.size() > 0 && folders.get(0).getId() != folder.getId()) { throw new Exception(String.format("duplicate folder name %s", name)); } else { FolderHistory transaction = new FolderHistory(); transaction.setUser(user); transaction.setEvent(FolderEvent.RENAMED.toString()); transaction.setSessionId(sid); transaction.setFilenameOld(folder.getName()); transaction.setPathOld(folderDao.computePathExtended(folderId)); folder.setName(name); folderDao.store(folder, transaction); } }  @Override WSFolder create(String sid, WSFolder folder); @Override WSFolder createAlias(String sid, long parentId, long foldRef); @Override long createFolder(String sid, long parentId, String name); @Override void delete(String sid, long folderId); @Override WSFolder getFolder(String sid, long folderId); @Override WSFolder findByPath(String sid, String path); @Override boolean isReadable(String sid, long folderId); @Override WSFolder[] listChildren(String sid, long folderId); @Override void move(String sid, long folderId, long parentId); @Override void copy(String sid, long folderId, long targetId, int foldersOnly, int inheritSecurity); @Override void rename(String sid, long folderId, String name); @Override WSFolder getRootFolder(String sid); @Override WSFolder getDefaultWorkspace(String sid); @Override boolean isWritable(String sid, long folderId); @Override boolean isGranted(String sid, long folderId, int permission); @Override WSFolder[] getPath(String sid, long folderId); @Override void grantUser(String sid, long folderId, long userId, int permissions, boolean recursive); @Override void grantGroup(String sid, long folderId, long groupId, int permissions, boolean recursive); @Override WSRight[] getGrantedUsers(String sid, long folderId); @Override WSRight[] getGrantedGroups(String sid, long folderId); @Override void update(String sid, WSFolder folder); @Override WSFolder createPath(String sid, long parentId, String path); @Override WSFolder[] listWorkspaces(String sid);  }### Answer:
@Test public void testRename() throws Exception { Folder folder = folderDao.findById(103); Assert.assertNotNull(folder); Assert.assertEquals("menu.admin", folder.getName()); folderDao.initialize(folder); folderServiceImpl.rename("", 103, "paperino"); folder = folderDao.findById(103); Assert.assertEquals("paperino", folder.getName()); Assert.assertEquals(101, folder.getParentId()); Assert.assertEquals(3, folder.getType()); }