Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-rest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
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
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-rest
Commits
b10011cc
Commit
b10011cc
authored
4 years ago
by
Sonia Zorba
Browse files
Options
Downloads
Patches
Plain Diff
Added test case for task #3892
parent
eee6557b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
+7
-1
7 additions, 1 deletion
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
src/test/java/it/inaf/oats/vospace/persistence/NodeDAOTest.java
+60
-11
60 additions, 11 deletions
...st/java/it/inaf/oats/vospace/persistence/NodeDAOTest.java
with
67 additions
and
12 deletions
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
+
7
−
1
View file @
b10011cc
...
@@ -119,8 +119,14 @@ public class NodeDAO {
...
@@ -119,8 +119,14 @@ public class NodeDAO {
return
Optional
.
of
(
node
);
return
Optional
.
of
(
node
);
}
}
public
Node
setNode
(
Node
newNode
)
{
public
Node
setNode
(
Node
newNode
)
{
return
setNode
(
newNode
,
false
);
}
/**
* If recursive flag is true the update is applied to children too.
*/
public
Node
setNode
(
Node
newNode
,
boolean
recursive
)
{
String
vosPath
=
NodeUtils
.
getVosPath
(
newNode
);
String
vosPath
=
NodeUtils
.
getVosPath
(
newNode
);
...
...
This diff is collapsed.
Click to expand it.
src/test/java/it/inaf/oats/vospace/persistence/NodeDAOTest.java
+
60
−
11
View file @
b10011cc
...
@@ -3,7 +3,10 @@ package it.inaf.oats.vospace.persistence;
...
@@ -3,7 +3,10 @@ package it.inaf.oats.vospace.persistence;
import
it.inaf.oats.vospace.datamodel.NodeProperties
;
import
it.inaf.oats.vospace.datamodel.NodeProperties
;
import
it.inaf.oats.vospace.exception.InternalFaultException
;
import
it.inaf.oats.vospace.exception.InternalFaultException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
net.ivoa.xml.vospace.v2.ContainerNode
;
import
net.ivoa.xml.vospace.v2.ContainerNode
;
import
net.ivoa.xml.vospace.v2.DataNode
;
import
net.ivoa.xml.vospace.v2.DataNode
;
...
@@ -58,7 +61,7 @@ public class NodeDAOTest {
...
@@ -58,7 +61,7 @@ public class NodeDAOTest {
assertEquals
(
"true"
,
NodeProperties
.
getNodePropertyAsListByURI
(
root
,
NodeProperties
.
PUBLIC_READ_URI
).
get
(
0
));
assertEquals
(
"true"
,
NodeProperties
.
getNodePropertyAsListByURI
(
root
,
NodeProperties
.
PUBLIC_READ_URI
).
get
(
0
));
assertEquals
(
"group1 group2"
,
get
Property
(
root
.
getNodes
().
get
(
0
),
"ivo://ivoa.net/vospace/core#groupread"
));
assertEquals
(
"group1 group2"
,
NodeProperties
.
getNode
Property
ByURI
(
root
.
getNodes
().
get
(
0
),
NodeProperties
.
GROUP_READ_URI
));
}
}
@Test
@Test
...
@@ -114,9 +117,7 @@ public class NodeDAOTest {
...
@@ -114,9 +117,7 @@ public class NodeDAOTest {
@Test
@Test
public
void
testSetNode
()
{
public
void
testSetNode
()
{
Property
publicReadProperty
=
new
Property
();
Property
publicReadProperty
=
getProperty
(
NodeProperties
.
PUBLIC_READ_URI
,
String
.
valueOf
(
false
));
publicReadProperty
.
setUri
(
NodeProperties
.
PUBLIC_READ_URI
);
publicReadProperty
.
setValue
(
String
.
valueOf
(
false
));
Node
node
=
new
DataNode
();
Node
node
=
new
DataNode
();
node
.
setUri
(
"vos://example.com!vospace/mydata3"
);
node
.
setUri
(
"vos://example.com!vospace/mydata3"
);
...
@@ -136,13 +137,61 @@ public class NodeDAOTest {
...
@@ -136,13 +137,61 @@ public class NodeDAOTest {
assertEquals
(
"true"
,
NodeProperties
.
getNodePropertyByURI
(
node
,
NodeProperties
.
PUBLIC_READ_URI
));
assertEquals
(
"true"
,
NodeProperties
.
getNodePropertyByURI
(
node
,
NodeProperties
.
PUBLIC_READ_URI
));
}
}
private
String
getProperty
(
Node
node
,
String
uri
)
{
//@Test
for
(
Property
property
:
node
.
getProperties
())
{
public
void
testSetNodeRecursiveGroup
()
{
if
(
uri
.
equals
(
property
.
getUri
()))
{
return
property
.
getValue
();
Property
parentGroupRead
=
getProperty
(
NodeProperties
.
GROUP_READ_URI
,
"group1 group2"
);
Property
parentGroupWrite
=
getProperty
(
NodeProperties
.
GROUP_WRITE_URI
,
"group2 group3"
);
Node
node
=
new
DataNode
();
node
.
setUri
(
"vos://example.com!vospace/mydata4"
);
node
.
getProperties
().
add
(
parentGroupRead
);
node
.
getProperties
().
add
(
parentGroupWrite
);
dao
.
createNode
(
node
);
Node
child1
=
new
DataNode
();
child1
.
setUri
(
"vos://example.com!vospace/mydata4/child1"
);
child1
.
getProperties
().
add
(
getProperty
(
NodeProperties
.
GROUP_READ_URI
,
"group3"
));
child1
.
getProperties
().
add
(
getProperty
(
NodeProperties
.
GROUP_WRITE_URI
,
"group3 group4"
));
dao
.
createNode
(
child1
);
Node
child2
=
new
DataNode
();
child2
.
setUri
(
"vos://example.com!vospace/mydata4/child1/child2"
);
child2
.
getProperties
().
add
(
getProperty
(
NodeProperties
.
GROUP_READ_URI
,
"group2 group5"
));
child2
.
getProperties
().
add
(
getProperty
(
NodeProperties
.
GROUP_WRITE_URI
,
"group6"
));
dao
.
createNode
(
child2
);
parentGroupRead
.
setValue
(
"group1 group5"
);
// remove group2; add group5
parentGroupWrite
.
setValue
(
"group2 group6"
);
// remove group3; add group6
// Recursively set node
dao
.
setNode
(
node
,
true
);
node
=
dao
.
listNode
(
"/mydata4"
).
get
();
child1
=
dao
.
listNode
(
"/mydata4/child1"
).
get
();
child2
=
dao
.
listNode
(
"/mydata4/child1/child2"
).
get
();
checkGroups
(
NodeProperties
.
getNodePropertyAsListByURI
(
node
,
NodeProperties
.
GROUP_READ_URI
),
"group1"
,
"group5"
);
checkGroups
(
NodeProperties
.
getNodePropertyAsListByURI
(
node
,
NodeProperties
.
GROUP_WRITE_URI
),
"group2"
,
"group6"
);
checkGroups
(
NodeProperties
.
getNodePropertyAsListByURI
(
child1
,
NodeProperties
.
GROUP_READ_URI
),
"group3"
,
"group5"
);
checkGroups
(
NodeProperties
.
getNodePropertyAsListByURI
(
child1
,
NodeProperties
.
GROUP_WRITE_URI
),
"group4"
,
"group6"
);
checkGroups
(
NodeProperties
.
getNodePropertyAsListByURI
(
child2
,
NodeProperties
.
GROUP_READ_URI
),
"group5"
);
checkGroups
(
NodeProperties
.
getNodePropertyAsListByURI
(
child2
,
NodeProperties
.
GROUP_WRITE_URI
),
"group6"
);
}
}
private
Property
getProperty
(
String
uri
,
String
value
)
{
Property
property
=
new
Property
();
property
.
setUri
(
uri
);
property
.
setValue
(
value
);
return
property
;
}
}
return
null
;
private
void
checkGroups
(
List
<
String
>
groups
,
String
...
expectedGroups
)
{
Set
<
String
>
set1
=
new
HashSet
<>(
Arrays
.
asList
(
expectedGroups
));
Set
<
String
>
set2
=
new
HashSet
<>(
groups
);
assertEquals
(
set1
,
set2
);
}
}
private
List
<
View
>
getViews
()
{
private
List
<
View
>
getViews
()
{
...
...
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