### Question:
DocumentManagerImpl implements DocumentManager { @Override public boolean unprotect(String sid, long docId, String password) { Session session = SessionManager.get().get(sid); if (!session.isOpen()) return false; if (session.getUnprotectedDocs().containsKey(docId)) return session.getUnprotectedDocs().get(docId).equals(password); Document doc = documentDAO.findDocument(docId); if (!doc.isPasswordProtected()) return true; boolean granted = doc.isGranted(password); if (granted) session.getUnprotectedDocs().put(docId, password); return granted; }  void setListenerManager(DocumentListenerManager listenerManager); void setDocumentDAO(DocumentDAO documentDAO); void setTemplateDAO(TemplateDAO templateDAO); void setIndexer(SearchEngine indexer); @Override void replaceFile(long docId, String fileVersion, InputStream content, DocumentHistory transaction); @Override void replaceFile(long docId, String fileVersion, File newFile, DocumentHistory transaction); @Override void checkin(long docId, File file, String filename, boolean release, AbstractDocument docVO,
			DocumentHistory transaction); @Override void checkin(long docId, InputStream content, String filename, boolean release, AbstractDocument docVO,
			DocumentHistory transaction); @Override void checkout(long docId, DocumentHistory transaction); @Override void lock(long docId, int status, DocumentHistory transaction); @Override void deleteFromIndex(Document doc); @Override String parseDocument(Document doc, String fileVersion); @Override long reindex(long docId, String content); @Override void update(Document doc, Document docVO, DocumentHistory transaction); @Override void moveToFolder(Document doc, Folder folder, DocumentHistory transaction); @Override Document create(InputStream content, Document docVO, DocumentHistory transaction); @Override Document create(File file, Document docVO, DocumentHistory transaction); Document copyToFolder(Document doc, Folder folder, DocumentHistory transaction); @Override void unlock(long docId, DocumentHistory transaction); @Override void makeImmutable(long docId, DocumentHistory transaction); @Override void rename(long docId, String newName, DocumentHistory transaction); @Override Document replaceAlias(long aliasId, DocumentHistory transaction); @Override Document createAlias(Document doc, Folder folder, String aliasType, DocumentHistory transaction); void setVersionDAO(VersionDAO versionDAO); void setStorer(Storer storer); void setConfig(ContextProperties config); @Override void changeIndexingStatus(Document doc, int status); void setUserDAO(UserDAO userDAO); void setFolderDAO(FolderDAO folderDAO); @Override Version deleteVersion(long versionId, DocumentHistory transaction); void setDocumentNoteDAO(DocumentNoteDAO documentNoteDAO); @Override long archiveFolder(long folderId, DocumentHistory transaction); @Override void archiveDocuments(long[] docIds, DocumentHistory transaction); @Override Ticket createDownloadTicket(long docId, String suffix, Integer expireHours, Date expireDate,
			Integer maxDownloads, String urlPrefix, DocumentHistory transaction); void setTicketDAO(TicketDAO ticketDAO); @Override boolean unprotect(String sid, long docId, String password); @Override void promoteVersion(long docId, String version, DocumentHistory transaction);  }### Answer:
@Test public void testUnprotect() throws Exception { Document doc = docDao.findById(3L); Assert.assertNull(doc.getPassword()); DocumentHistory history = new DocumentHistory(); history.setUserId(1L); history.setUsername("admin"); docDao.setPassword(3L, "test", history); Session session = SessionManager.get().newSession("admin", "admin", null); Assert.assertTrue(documentManager.unprotect(session.getSid(), 3L, "test")); Assert.assertFalse(documentManager.unprotect(session.getSid(), 3L, "test2")); Assert.assertTrue(documentManager.unprotect(session.getSid(), 3L, "test")); }