@Test public void test_changeDocumentAccess() throws UnstorableObjectException { boolean isChangeSuccess = filesManagerToTest.changeDocumentAccess(doc, DocumentAccess.PUBLIC); Mockito.verify(documentService).saveDocument(doc); Assert.assertEquals(isChangeSuccess, true); Assert.assertEquals(doc.getAccess(), DocumentAccess.PUBLIC); Mockito.verify(fileService).getFileById(IMG_ID); Assert.assertEquals(imgFile.getAccess(), DocumentAccess.PUBLIC); Mockito.verify(fileService).getFileById(TXT_ID); Assert.assertEquals(txtFile.getAccess(), DocumentAccess.PUBLIC); Mockito.verify(fileService).getFileById(OCR_ID); Assert.assertEquals(ocrFile.getAccess(), DocumentAccess.PUBLIC); }
@Override public boolean changeDocumentAccess(IDocument doc, DocumentAccess docAccess) throws UnstorableObjectException { doc.setAccess(docAccess); documentService.saveDocument(doc); boolean isChangeSuccess = true; for (IPage page : doc.getPages()) { IFile imgFile = fileService.getFileById(page.getImageFileId()); if (imgFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(imgFile, docAccess); } IFile txtFile = fileService.getFileById(page.getTextFileId()); if (txtFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(txtFile, docAccess); } IFile ocrFile = fileService.getFileById(page.getOcrFileId()); if (ocrFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(ocrFile, docAccess); } } return isChangeSuccess; }
FilesManager implements IFilesManager { @Override public boolean changeDocumentAccess(IDocument doc, DocumentAccess docAccess) throws UnstorableObjectException { doc.setAccess(docAccess); documentService.saveDocument(doc); boolean isChangeSuccess = true; for (IPage page : doc.getPages()) { IFile imgFile = fileService.getFileById(page.getImageFileId()); if (imgFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(imgFile, docAccess); } IFile txtFile = fileService.getFileById(page.getTextFileId()); if (txtFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(txtFile, docAccess); } IFile ocrFile = fileService.getFileById(page.getOcrFileId()); if (ocrFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(ocrFile, docAccess); } } return isChangeSuccess; } }
FilesManager implements IFilesManager { @Override public boolean changeDocumentAccess(IDocument doc, DocumentAccess docAccess) throws UnstorableObjectException { doc.setAccess(docAccess); documentService.saveDocument(doc); boolean isChangeSuccess = true; for (IPage page : doc.getPages()) { IFile imgFile = fileService.getFileById(page.getImageFileId()); if (imgFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(imgFile, docAccess); } IFile txtFile = fileService.getFileById(page.getTextFileId()); if (txtFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(txtFile, docAccess); } IFile ocrFile = fileService.getFileById(page.getOcrFileId()); if (ocrFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(ocrFile, docAccess); } } return isChangeSuccess; }  }
FilesManager implements IFilesManager { @Override public boolean changeDocumentAccess(IDocument doc, DocumentAccess docAccess) throws UnstorableObjectException { doc.setAccess(docAccess); documentService.saveDocument(doc); boolean isChangeSuccess = true; for (IPage page : doc.getPages()) { IFile imgFile = fileService.getFileById(page.getImageFileId()); if (imgFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(imgFile, docAccess); } IFile txtFile = fileService.getFileById(page.getTextFileId()); if (txtFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(txtFile, docAccess); } IFile ocrFile = fileService.getFileById(page.getOcrFileId()); if (ocrFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(ocrFile, docAccess); } } return isChangeSuccess; }  @Override List<StorageStatus> addFiles(Map<IFile, byte[]> files,
            User user, DocumentType docType, DocumentAccess access, String uploadProgressId); @Override List<IDocument> getDocumentsByUploadId(String uploadId); @Override byte[] getFileContent(IFile file); Map<String, Map<String, String>> getUploadedFilenames(String username); @Override String getFileUrl(IFile file); @Override List<IFile> getFilesOfDocument(IDocument doc); @Override List<IFile> getTextFilesOfDocument(IDocument doc); @Override boolean changeDocumentAccess(IDocument doc, DocumentAccess docAccess); }
FilesManager implements IFilesManager { @Override public boolean changeDocumentAccess(IDocument doc, DocumentAccess docAccess) throws UnstorableObjectException { doc.setAccess(docAccess); documentService.saveDocument(doc); boolean isChangeSuccess = true; for (IPage page : doc.getPages()) { IFile imgFile = fileService.getFileById(page.getImageFileId()); if (imgFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(imgFile, docAccess); } IFile txtFile = fileService.getFileById(page.getTextFileId()); if (txtFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(txtFile, docAccess); } IFile ocrFile = fileService.getFileById(page.getOcrFileId()); if (ocrFile != null) { isChangeSuccess = isChangeSuccess && changeFileAccess(ocrFile, docAccess); } } return isChangeSuccess; }  @Override List<StorageStatus> addFiles(Map<IFile, byte[]> files,
            User user, DocumentType docType, DocumentAccess access, String uploadProgressId); @Override List<IDocument> getDocumentsByUploadId(String uploadId); @Override byte[] getFileContent(IFile file); Map<String, Map<String, String>> getUploadedFilenames(String username); @Override String getFileUrl(IFile file); @Override List<IFile> getFilesOfDocument(IDocument doc); @Override List<IFile> getTextFilesOfDocument(IDocument doc); @Override boolean changeDocumentAccess(IDocument doc, DocumentAccess docAccess);  }