Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-datamodel
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
Container registry
Model registry
Operate
Environments
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-datamodel
Commits
a814126a
Commit
a814126a
authored
4 years ago
by
Nicola Fulvio Calabria
Browse files
Options
Downloads
Patches
Plain Diff
Added convenience method to NodeUtils for last vos path element extraction
parent
1506ac2f
No related branches found
No related tags found
No related merge requests found
Pipeline
#1780
passed
4 years ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/it/inaf/oats/vospace/datamodel/NodeUtils.java
+16
-0
16 additions, 0 deletions
src/main/java/it/inaf/oats/vospace/datamodel/NodeUtils.java
src/test/java/it/inaf/oats/vospace/datamodel/NodeUtilsTest.java
+19
-1
19 additions, 1 deletion
...st/java/it/inaf/oats/vospace/datamodel/NodeUtilsTest.java
with
35 additions
and
1 deletion
src/main/java/it/inaf/oats/vospace/datamodel/NodeUtils.java
+
16
−
0
View file @
a814126a
...
...
@@ -85,6 +85,22 @@ public class NodeUtils {
return
sb
.
toString
();
}
public
static
String
getLastPathElement
(
String
path
)
{
if
(
path
==
null
||
path
.
isBlank
()
||
!
path
.
startsWith
(
"/"
))
{
throw
new
IllegalArgumentException
();
}
String
[]
pathComponents
=
path
.
split
(
"[/]+"
);
if
(
pathComponents
.
length
==
0
)
{
return
"/"
;
}
else
{
return
pathComponents
[
pathComponents
.
length
-
1
];
}
}
public
static
List
<
String
>
subPathComponents
(
String
path
)
{
List
resultList
=
new
ArrayList
<
String
>();
...
...
This diff is collapsed.
Click to expand it.
src/test/java/it/inaf/oats/vospace/datamodel/NodeUtilsTest.java
+
19
−
1
View file @
a814126a
...
...
@@ -2,7 +2,6 @@ package it.inaf.oats.vospace.datamodel;
import
java.util.ArrayList
;
import
java.util.List
;
import
net.ivoa.xml.vospace.v2.ContainerNode
;
import
net.ivoa.xml.vospace.v2.DataNode
;
import
net.ivoa.xml.vospace.v2.LinkNode
;
import
net.ivoa.xml.vospace.v2.Node
;
...
...
@@ -10,6 +9,7 @@ import net.ivoa.xml.vospace.v2.Property;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertArrayEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertThrows
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
org.junit.jupiter.api.Test
;
...
...
@@ -163,6 +163,24 @@ public class NodeUtilsTest {
assertTrue
(
NodeUtils
.
checkIfReadable
(
node
,
"user2"
,
List
.
of
(
"group2"
,
"group3"
)));
}
@Test
public
void
testGetLastPathElement
()
{
assertThrows
(
IllegalArgumentException
.
class
,()
->
{
NodeUtils
.
getLastPathElement
(
null
);}
);
assertThrows
(
IllegalArgumentException
.
class
,()
->
{
NodeUtils
.
getLastPathElement
(
" "
);}
);
assertThrows
(
IllegalArgumentException
.
class
,()
->
{
NodeUtils
.
getLastPathElement
(
"http://asdasd"
);}
);
assertEquals
(
"/"
,
NodeUtils
.
getLastPathElement
(
"/"
));
assertEquals
(
"f1"
,
NodeUtils
.
getLastPathElement
(
"/pippo/test/f1"
));
}
@Test
public
void
testCheckReadableGroupsFalse
()
{
...
...
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