Search in sources :

Example 6 with GroupsResource

use of org.keycloak.admin.client.resource.GroupsResource in project keycloak by keycloak.

the class GroupTest method getGroupsWithFullRepresentation.

@Test
public void getGroupsWithFullRepresentation() {
    RealmResource realm = adminClient.realms().realm("test");
    GroupsResource groupsResource = adminClient.realms().realm("test").groups();
    GroupRepresentation group = new GroupRepresentation();
    group.setName("groupWithAttribute");
    Map<String, List<String>> attributes = new HashMap<String, List<String>>();
    attributes.put("attribute1", Arrays.asList("attribute1", "attribute2"));
    group.setAttributes(attributes);
    group = createGroup(realm, group);
    List<GroupRepresentation> groups = groupsResource.groups("groupWithAttribute", 0, 20, false);
    assertFalse(groups.isEmpty());
    assertTrue(groups.get(0).getAttributes().containsKey("attribute1"));
}
Also used : GroupRepresentation(org.keycloak.representations.idm.GroupRepresentation) HashMap(java.util.HashMap) RealmResource(org.keycloak.admin.client.resource.RealmResource) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) GroupsResource(org.keycloak.admin.client.resource.GroupsResource) Test(org.junit.Test)

Aggregations

GroupsResource (org.keycloak.admin.client.resource.GroupsResource)6 Test (org.junit.Test)5 Response (javax.ws.rs.core.Response)3 GroupResource (org.keycloak.admin.client.resource.GroupResource)3 RealmResource (org.keycloak.admin.client.resource.RealmResource)3 GroupRepresentation (org.keycloak.representations.idm.GroupRepresentation)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 UsersResource (org.keycloak.admin.client.resource.UsersResource)2 NotFoundException (javax.ws.rs.NotFoundException)1 Logger (org.jboss.logging.Logger)1 AuthorizationResource (org.keycloak.admin.client.resource.AuthorizationResource)1 UserResource (org.keycloak.admin.client.resource.UserResource)1 UserRepresentation (org.keycloak.representations.idm.UserRepresentation)1 GroupPolicyRepresentation (org.keycloak.representations.idm.authorization.GroupPolicyRepresentation)1