Skip to content

Commit

Permalink
More unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
car031 committed Jun 6, 2023
1 parent eb868cf commit f0755ab
Show file tree
Hide file tree
Showing 10 changed files with 801 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,10 @@ public Document copy(Document doc, String targetPath, String username) {
* @param doc1 first document
* @param doc2 second document
* @param type type of link(optional)
*
* @return the created link
*/
public void link(Document doc1, Document doc2, String type) {
public DocumentLink link(Document doc1, Document doc2, String type) {
DocumentLinkDAO linkDao = (DocumentLinkDAO) Context.get().getBean(DocumentLinkDAO.class);
DocumentLink link = linkDao.findByDocIdsAndType(doc1.getId(), doc2.getId(), "default");
if (link == null) {
Expand All @@ -318,6 +320,7 @@ public void link(Document doc1, Document doc2, String type) {
log.error(e.getMessage(), e);
}
}
return link;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public String getPath(Long folderId) throws PersistenceException {
FolderDAO folderDao = (FolderDAO) Context.get().getBean(FolderDAO.class);
return folderDao.computePathExtended(folderId);
}

/**
* Finds the folder by it's path
*
Expand Down Expand Up @@ -116,6 +116,23 @@ public Folder findByPath(String path, Long tenantId) {
}
}

/**
* Finds the folder by it's identifier
*
* @param id the unique identifier
*
* @return the found folder
*/
public Folder findById(long id) {
FolderDAO folderDao = (FolderDAO) Context.get().getBean(FolderDAO.class);
try {
return folderDao.findById(id);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
return null;
}
}

/**
* Saves / updates a folder into the database
*
Expand Down Expand Up @@ -188,7 +205,7 @@ public void delete(long folderId, String username) throws PersistenceException {
public void move(Folder folder, String targetPath, String username) throws PersistenceException {
User user = new SecurityTool().getUser(username);

Folder target = createPath(null, targetPath, username);
Folder target = createPath(folder, targetPath, username);

FolderHistory transaction = new FolderHistory();
transaction.setFolder(folder);
Expand Down Expand Up @@ -225,7 +242,7 @@ public Folder copy(Folder source, String targetPath, boolean foldersOnly, String
throws PersistenceException {
User user = new SecurityTool().getUser(username);

Folder target = createPath(null, targetPath, username);
Folder target = createPath(source, targetPath, username);

FolderHistory transaction = new FolderHistory();
transaction.setFolder(source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,10 @@ public Session remove(Object sid) {
public void renew(String sid) {
if (isOpen(sid)) {
Session session = get(sid);
if (session.getStatus() == Session.STATUS_OPEN) {
if (session.isTimedOut()) {
session.setExpired();
} else {
session.setLastRenew(new Date());
}
if (session.isTimedOut()) {
session.setExpired();
} else {
session.setLastRenew(new Date());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ private void prepareStore() throws IOException {

// Store the file of document 1
FileUtil.copyResource("/Digital_Day.pdf", new File(storePath+"/1/doc/1.0"));
FileUtil.copyResource("/Digital_Day.pdf", new File(storePath+"/1/doc/1.0-conversion.pdf"));

// Store the file of document 3
FileUtil.copyResource("/small.pdf", new File(storePath+"/3/doc/1.3"));
Expand Down
Loading

0 comments on commit f0755ab

Please sign in to comment.