Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-file-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-file-service
Commits
5a003e9c
Commit
5a003e9c
authored
3 years ago
by
Nicola Fulvio Calabria
Browse files
Options
Downloads
Patches
Plain Diff
Added tests to FileDAOTest
parent
05dcfd63
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/it/inaf/ia2/transfer/persistence/FileDAO.java
+1
-18
1 addition, 18 deletions
src/main/java/it/inaf/ia2/transfer/persistence/FileDAO.java
src/test/java/it/inaf/ia2/transfer/persistence/FileDAOTest.java
+26
-13
26 additions, 13 deletions
...st/java/it/inaf/ia2/transfer/persistence/FileDAOTest.java
with
27 additions
and
31 deletions
src/main/java/it/inaf/ia2/transfer/persistence/FileDAO.java
+
1
−
18
View file @
5a003e9c
...
...
@@ -75,22 +75,6 @@ public class FileDAO {
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
)
{
String
sql
=
"UPDATE node SET job_id = ? WHERE node_id = id_from_vos_path(?)"
;
...
...
@@ -216,8 +200,7 @@ public class FileDAO {
// TODO: same problem as get archive file infos
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"
+
"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"
...
...
This diff is collapsed.
Click to expand it.
src/test/java/it/inaf/ia2/transfer/persistence/FileDAOTest.java
+
26
−
13
View file @
5a003e9c
...
...
@@ -41,27 +41,27 @@ public class FileDAOTest {
dao
=
new
FileDAO
(
dataSource
);
ReflectionTestUtils
.
setField
(
dao
,
"uploadLocationId"
,
uploadLocationId
);
}
@Test
public
void
testGetBranchFileInfo
()
{
List
<
FileInfo
>
fi
=
dao
.
getBranchFileInfos
(
"/test100"
,
"pippo"
);
assertEquals
(
3
,
fi
.
size
());
List
<
FileInfo
>
fi2
=
dao
.
getBranchFileInfos
(
"/test100/test1001.txt"
,
"pippo"
);
assertEquals
(
1
,
fi2
.
size
());
List
<
FileInfo
>
fi
=
dao
.
getBranchFileInfos
(
"/test100"
,
"pippo"
);
assertEquals
(
3
,
fi
.
size
());
List
<
FileInfo
>
fi2
=
dao
.
getBranchFileInfos
(
"/test100/test1001.txt"
,
"pippo"
);
assertEquals
(
1
,
fi2
.
size
());
}
@Test
public
void
testSetBranchLocationId
()
{
dao
.
setBranchLocationId
(
"/test100"
,
"pippo"
,
3
);
List
<
FileInfo
>
fi
=
dao
.
getBranchFileInfos
(
"/test100"
,
"pippo"
);
assertEquals
(
3
,
fi
.
size
());
f
or
(
FileInfo
f
:
fi
)
{
f
i
.
forEach
(
f
->
{
assertEquals
(
3
,
f
.
getLocationId
());
}
}
);
}
@Test
public
void
testGetFileInfo
()
{
...
...
@@ -113,13 +113,26 @@ public class FileDAOTest {
FileInfo
fileInfo
=
dao
.
getFileInfo
(
"/public/file1"
).
get
();
assertNull
(
fileInfo
.
getJobId
());
dao
.
setBusy
(
fileInfo
.
get
NodeId
(),
"pippo1"
);
dao
.
setBusy
(
fileInfo
.
get
VirtualPath
(),
"pippo1"
);
assertEquals
(
"pippo1"
,
dao
.
getFileInfo
(
"/public/file1"
).
get
().
getJobId
());
dao
.
setBusy
(
fileInfo
.
get
NodeId
(),
null
);
dao
.
setBusy
(
fileInfo
.
get
VirtualPath
(),
null
);
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
public
void
testSetOsName
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment