/** Create and persist a {@link Group} instance for testing. */ private void loadGroups() { IdentityManager identityManager = getIdentityManager(); this.group = identityManager.getGroup(GROUP_NAME + 1); this.user = identityManager.getUser(USER_NAME); this.parentGroup = identityManager.getGroup(GROUP_PARENT_NAME); // if groups are already loaded then do nothing if (this.group != null) { return; } this.user = identityManager.createUser(USER_NAME); this.parentGroup = identityManager.createGroup(GROUP_PARENT_NAME, (Group) null); for (int i = 0; i < 10; i++) { int index = i + 1; Group currentGroup = identityManager.createGroup(GROUP_NAME + index, parentGroup); // store the instance used for testing if (this.group == null) { this.group = currentGroup; } Role role = identityManager.createRole(ROLE_NAME_PREFIX + index); identityManager.grantRole(role, user, currentGroup); currentGroup.setAttribute("attribute1", "attributeValue1"); currentGroup.setAttribute("attribute1", "attributeValue12"); currentGroup.setAttribute("attribute1", "attributeValue123"); currentGroup.setAttribute("attribute2", "attributeValue2"); } }
private boolean contains(List<Group> result, String roleId) { for (Group resultGroup : result) { if (resultGroup.getName().equals(roleId)) { return true; } } return false; }