Skip to content
Snippets Groups Projects
Commit 5a003e9c authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Added tests to FileDAOTest

parent 05dcfd63
No related branches found
No related tags found
No related merge requests found
...@@ -75,22 +75,6 @@ public class FileDAO { ...@@ -75,22 +75,6 @@ public class FileDAO {
return Arrays.asList((String[]) array.getArray()); return Arrays.asList((String[]) array.getArray());
} }
public void setBusy(int nodeId, String jobId) {
String sql = "UPDATE node SET job_id = ? WHERE node_id = ?";
jdbcTemplate.update(conn -> {
PreparedStatement ps = conn.prepareStatement(sql);
if (jobId == null) {
ps.setNull(1, Types.VARCHAR);
} else {
ps.setString(1, jobId);
}
ps.setInt(2, nodeId);
return ps;
});
}
public int setBusy(String vosPath, String jobId) { public int setBusy(String vosPath, String jobId) {
String sql = "UPDATE node SET job_id = ? WHERE node_id = id_from_vos_path(?)"; String sql = "UPDATE node SET job_id = ? WHERE node_id = id_from_vos_path(?)";
...@@ -217,7 +201,6 @@ public class FileDAO { ...@@ -217,7 +201,6 @@ public class FileDAO {
// TODO: same problem as get archive file infos // TODO: same problem as get archive file infos
public List<FileInfo> getBranchFileInfos(String rootVosPath, String jobId) { public List<FileInfo> getBranchFileInfos(String rootVosPath, String jobId) {
// TODO: validate rootVosPath as a vos_path
String sql = "SELECT n.node_id, n.is_public, n.group_read, n.group_write, n.creator_id, n.async_trans,\n" String sql = "SELECT n.node_id, n.is_public, n.group_read, n.group_write, n.creator_id, n.async_trans,\n"
+ "n.content_type, n.content_encoding, n.content_length, n.content_md5,\n" + "n.content_type, n.content_encoding, n.content_length, n.content_md5,\n"
+ "n.accept_views, n.provide_views, l.location_type, n.path <> n.relative_path AS virtual_parent,\n" + "n.accept_views, n.provide_views, l.location_type, n.path <> n.relative_path AS virtual_parent,\n"
......
...@@ -56,9 +56,9 @@ public class FileDAOTest { ...@@ -56,9 +56,9 @@ public class FileDAOTest {
List<FileInfo> fi = dao.getBranchFileInfos("/test100", "pippo"); List<FileInfo> fi = dao.getBranchFileInfos("/test100", "pippo");
assertEquals(3, fi.size()); assertEquals(3, fi.size());
for(FileInfo f : fi) { fi.forEach(f -> {
assertEquals(3, f.getLocationId()); assertEquals(3, f.getLocationId());
} });
} }
...@@ -113,13 +113,26 @@ public class FileDAOTest { ...@@ -113,13 +113,26 @@ public class FileDAOTest {
FileInfo fileInfo = dao.getFileInfo("/public/file1").get(); FileInfo fileInfo = dao.getFileInfo("/public/file1").get();
assertNull(fileInfo.getJobId()); assertNull(fileInfo.getJobId());
dao.setBusy(fileInfo.getNodeId(), "pippo1"); dao.setBusy(fileInfo.getVirtualPath(), "pippo1");
assertEquals("pippo1", dao.getFileInfo("/public/file1").get().getJobId()); assertEquals("pippo1", dao.getFileInfo("/public/file1").get().getJobId());
dao.setBusy(fileInfo.getNodeId(), null); dao.setBusy(fileInfo.getVirtualPath(), null);
assertNull(dao.getFileInfo("/public/file1").get().getJobId()); assertNull(dao.getFileInfo("/public/file1").get().getJobId());
} }
@Test
public void testReleaseNodesByJobId() {
List<FileInfo> fi = dao.getBranchFileInfos("/test100", "pippo");
assertEquals(3, fi.size());
dao.releaseBusyNodesByJobId("pippo");
fi = dao.getBranchFileInfos("/test100", "pippo");
assertEquals(0, fi.size());
}
@Test @Test
public void testSetOsName() { public void testSetOsName() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment