Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IA2
GMS
Commits
3a68a2f0
Commit
3a68a2f0
authored
Nov 15, 2020
by
Sonia Zorba
Browse files
Bugfix Root name
parent
f9697fb4
Pipeline
#639
passed with stages
in 33 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gms-client/gms-cli/src/main/java/it/inaf/ia2/gms/cli/CLI.java
View file @
3a68a2f0
...
...
@@ -4,6 +4,7 @@ import it.inaf.ia2.client.ClientException;
import
it.inaf.ia2.gms.client.GmsClient
;
import
it.inaf.ia2.gms.client.model.Permission
;
import
it.inaf.ia2.rap.client.RapClient
;
import
it.inaf.ia2.rap.data.AccessTokenResponse
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
...
...
@@ -106,11 +107,12 @@ public class CLI {
if
(
token
!=
null
)
{
client
.
setAccessToken
(
token
);
}
else
{
}
else
{
RapClient
rapClient
=
new
RapClient
(
rapBaseUrl
)
.
setClientId
(
clientId
)
.
setClientSecret
(
clientSecret
);
client
.
setAccessToken
(
rapClient
.
getAccessTokenFromClientCredentials
());
.
setClientSecret
(
clientSecret
);
AccessTokenResponse
accessTokenResponse
=
rapClient
.
getAccessTokenFromClientCredentials
();
client
.
setAccessToken
(
accessTokenResponse
.
getAccessToken
());
}
}
...
...
gms/src/main/java/it/inaf/ia2/gms/service/GroupNameService.java
View file @
3a68a2f0
...
...
@@ -47,7 +47,7 @@ public class GroupNameService {
List
<
String
>
names
=
new
ArrayList
<>(
groupsDAO
.
getGroupCompleteNamesFromId
(
groupIds
).
values
());
if
(
groupIds
.
contains
(
"ROOT"
))
{
names
.
add
(
"
Root
"
);
names
.
add
(
get
Root
().
getName
()
);
}
Collections
.
sort
(
names
);
...
...
@@ -72,7 +72,7 @@ public class GroupNameService {
Map
<
String
,
List
<
String
>>
result
=
new
HashMap
<>();
if
(
groupIds
.
contains
(
"ROOT"
))
{
result
.
put
(
"ROOT"
,
Collections
.
singletonList
(
"
Root
"
));
result
.
put
(
"ROOT"
,
Collections
.
singletonList
(
get
Root
().
getName
()
));
}
for
(
Map
.
Entry
<
String
,
String
>
entry
:
groupsDAO
.
getGroupCompleteNamesFromId
(
groupIds
).
entrySet
())
{
...
...
gms/src/main/resources/application.properties
View file @
3a68a2f0
...
...
@@ -13,7 +13,6 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username
=
gms
spring.datasource.password
=
gms
rap.ws-url
=
http://localhost/rap-ia2/ws
support.contact.label
=
IA2 team
support.contact.email
=
ia2@inaf.it
...
...
gms/src/test/java/it/inaf/ia2/gms/manager/PermissionsManagerIntegrationTest.java
View file @
3a68a2f0
...
...
@@ -62,7 +62,7 @@ public class PermissionsManagerIntegrationTest {
// Create root
GroupEntity
root
=
new
GroupEntity
();
root
.
setId
(
"ROOT"
);
root
.
setName
(
"R
oot
"
);
root
.
setName
(
"R
OOT
"
);
root
.
setPath
(
""
);
root
=
groupsDAO
.
createGroup
(
root
);
...
...
gms/src/test/java/it/inaf/ia2/gms/service/GroupNameServiceTest.java
View file @
3a68a2f0
...
...
@@ -8,11 +8,13 @@ import java.util.HashMap;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Set
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
eq
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
...
...
@@ -58,12 +60,20 @@ public class GroupNameServiceTest {
when
(
groupsDAO
.
getGroupCompleteNamesFromId
(
any
())).
thenReturn
(
new
HashMap
<>());
GroupEntity
root
=
new
GroupEntity
();
root
.
setId
(
"ROOT"
);
root
.
setName
(
"ROOT"
);
root
.
setPath
(
""
);
when
(
groupsDAO
.
findGroupById
(
eq
(
"ROOT"
)))
.
thenReturn
(
Optional
.
of
(
root
));
List
<
Map
.
Entry
<
String
,
String
>>
groupsIdPath
=
new
ArrayList
<>();
groupsIdPath
.
add
(
new
AbstractMap
.
SimpleEntry
<>(
"ROOT"
,
""
));
Map
<
String
,
List
<
String
>>
names
=
groupNameService
.
getNamesFromIds
(
groupIds
);
assertEquals
(
1
,
names
.
size
());
assertEquals
(
1
,
names
.
get
(
"ROOT"
).
size
());
assertEquals
(
"R
oot
"
,
names
.
get
(
"ROOT"
).
get
(
0
));
assertEquals
(
"R
OOT
"
,
names
.
get
(
"ROOT"
).
get
(
0
));
}
}
gms/src/test/java/it/inaf/ia2/gms/service/SearchServiceTest.java
View file @
3a68a2f0
...
...
@@ -69,7 +69,7 @@ public class SearchServiceTest {
List
<
String
>
names
=
new
ArrayList
<>();
switch
(
group
.
getId
())
{
case
"ROOT"
:
names
.
add
(
"R
oot
"
);
names
.
add
(
"R
OOT
"
);
break
;
case
"group1_id"
:
names
.
add
(
"Group 1"
);
...
...
@@ -169,7 +169,7 @@ public class SearchServiceTest {
GroupEntity
root
=
new
GroupEntity
();
root
.
setId
(
"ROOT"
);
root
.
setName
(
"R
oot
"
);
root
.
setName
(
"R
OOT
"
);
root
.
setPath
(
""
);
when
(
groupsManager
.
getRoot
()).
thenReturn
(
root
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment