Commit 3a68a2f0 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Bugfix Root name

parent f9697fb4
Pipeline #639 passed with stages
in 33 seconds
......@@ -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());
}
}
......
......@@ -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(getRoot().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(getRoot().getName()));
}
for (Map.Entry<String, String> entry : groupsDAO.getGroupCompleteNamesFromId(groupIds).entrySet()) {
......
......@@ -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
......
......@@ -62,7 +62,7 @@ public class PermissionsManagerIntegrationTest {
// Create root
GroupEntity root = new GroupEntity();
root.setId("ROOT");
root.setName("Root");
root.setName("ROOT");
root.setPath("");
root = groupsDAO.createGroup(root);
......
......@@ -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("Root", names.get("ROOT").get(0));
assertEquals("ROOT", names.get("ROOT").get(0));
}
}
......@@ -69,7 +69,7 @@ public class SearchServiceTest {
List<String> names = new ArrayList<>();
switch (group.getId()) {
case "ROOT":
names.add("Root");
names.add("ROOT");
break;
case "group1_id":
names.add("Group 1");
......@@ -169,7 +169,7 @@ public class SearchServiceTest {
GroupEntity root = new GroupEntity();
root.setId("ROOT");
root.setName("Root");
root.setName("ROOT");
root.setPath("");
when(groupsManager.getRoot()).thenReturn(root);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment