Added role names to user-group list

Change-Id: I49cc002072f564179253f8f7eacbfedad4e0d49d
diff --git a/Changes b/Changes
index 639a5fe..d4f1302 100644
--- a/Changes
+++ b/Changes
@@ -22,7 +22,7 @@
 - Disallow scope all for non super clients.
 - Changed memberUsername to member in the new member-role-addition web-service.
 - Removed user-privileges from user-group list response.
-- 
+- Added role names to user-group list
 
 
 # version 0.74.1-SNAPSHOT
diff --git a/src/main/java/de/ids_mannheim/korap/dto/UserGroupMemberDto.java b/src/main/java/de/ids_mannheim/korap/dto/UserGroupMemberDto.java
index 40ea6d4..f311248 100644
--- a/src/main/java/de/ids_mannheim/korap/dto/UserGroupMemberDto.java
+++ b/src/main/java/de/ids_mannheim/korap/dto/UserGroupMemberDto.java
@@ -1,6 +1,7 @@
 package de.ids_mannheim.korap.dto;
 
 import java.util.List;
+import java.util.Set;
 
 import de.ids_mannheim.korap.constant.PrivilegeType;
 import lombok.Getter;
@@ -17,5 +18,6 @@
 @Getter
 public class UserGroupMemberDto {
     private String userId;
+    private Set<String> roles;
     private List<PrivilegeType> privileges;
 }
diff --git a/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java b/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java
index 7fbaa10..f959264 100644
--- a/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java
+++ b/src/main/java/de/ids_mannheim/korap/dto/converter/UserGroupConverter.java
@@ -2,6 +2,7 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -43,6 +44,7 @@
 
                 UserGroupMemberDto memberDto = new UserGroupMemberDto();
                 memberDto.setUserId(member.getUserId());
+                memberDto.setRoles(createUniqueRoles(member.getRoles()));
                 memberDto.setPrivileges(createPrivilegeList(member.getRoles()));
                 memberDtos.add(memberDto);
             }
@@ -55,6 +57,14 @@
         return dto;
     }
 
+    private Set<String> createUniqueRoles (Set<Role> roles) {
+        Set<String> uniqueRoles = new HashSet<String>();
+        for (Role r : roles) {
+            uniqueRoles.add(r.getName().name());
+        }
+        return uniqueRoles;
+    }
+
     private List<PrivilegeType> createPrivilegeList (Set<Role> roles) {
         List<PrivilegeType> privileges = new ArrayList<>(roles.size());
         for (Role r : roles) {
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/usergroup/UserGroupListTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/usergroup/UserGroupListTest.java
index b96467a..51c1d50 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/usergroup/UserGroupListTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/usergroup/UserGroupListTest.java
@@ -28,6 +28,15 @@
         assertEquals(group.at("/owner").asText(), "dory");
         assertEquals(3, group.at("/members").size());
         
+        assertEquals(group.at("/members/0/userId").asText(), "dory");
+        assertEquals(group.at("/members/0/roles").size(), 1);
+        assertEquals(group.at("/members/0/roles/0").asText(), "GROUP_ADMIN");
+        assertEquals(group.at("/members/0/privileges").size(), 5);
+        
+        assertEquals(group.at("/members/1/userId").asText(), "marlin");
+        assertEquals(group.at("/members/1/roles").size(), 1);
+        assertEquals(group.at("/members/1/roles/0").asText(), "GROUP_MEMBER");
+        
         testListNemoGroups();
         testListMarlinGroups();