From 5866a22801e093867ca174e341e05d8aa1fc3c2e Mon Sep 17 00:00:00 2001 From: Chanika Ruchini <36252774+ChanikaRuchini@users.noreply.github.com> Date: Mon, 11 Dec 2023 10:05:42 +0530 Subject: [PATCH] Revert "Improve getRoles service of Role v2 management" --- .../DefaultRoleManagementListener.java | 20 +++--- .../v2/mgt/core/RoleManagementService.java | 33 +++++----- .../mgt/core/RoleManagementServiceImpl.java | 22 +++---- .../role/v2/mgt/core/dao/RoleDAO.java | 31 +++++----- .../role/v2/mgt/core/dao/RoleDAOImpl.java | 61 +++---------------- .../AbstractRoleManagementListener.java | 4 +- .../core/listener/RoleManagementListener.java | 30 ++++----- .../role/v2/mgt/core/dao/RoleDAOTest.java | 16 +++-- 8 files changed, 82 insertions(+), 135 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/DefaultRoleManagementListener.java b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/DefaultRoleManagementListener.java index 6d981f2794f0..53054659f8d8 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/DefaultRoleManagementListener.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/listener/DefaultRoleManagementListener.java @@ -108,19 +108,19 @@ public void preGetRoles(Integer limit, Integer offset, String sortBy, String sor } @Override - public void postGetRoles(List roleInfoList, Integer limit, Integer offset, + public void postGetRoles(List roleBasicInfoList, Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain) throws IdentityRoleManagementException { - Iterator iterator = roleInfoList.iterator(); + Iterator iterator = roleBasicInfoList.iterator(); while (iterator.hasNext()) { - Role roleInfo = iterator.next(); - if (APPLICATION.equalsIgnoreCase(roleInfo.getAudience())) { - String applicationName = getApplicationName(roleInfo.getAudienceId(), tenantDomain); + RoleBasicInfo roleBasicInfo = iterator.next(); + if (APPLICATION.equalsIgnoreCase(roleBasicInfo.getAudience())) { + String applicationName = getApplicationName(roleBasicInfo.getAudienceId(), tenantDomain); if (applicationName == null) { iterator.remove(); } - roleInfo.setAudienceName(applicationName); + roleBasicInfo.setAudienceName(applicationName); } } } @@ -132,13 +132,13 @@ public void preGetRoles(String filter, Integer limit, Integer offset, String sor } @Override - public void postGetRoles(List roleInfoList, String filter, Integer limit, Integer offset, + public void postGetRoles(List roleBasicInfoList, String filter, Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain) throws IdentityRoleManagementException { - for (Role roleInfo : roleInfoList) { - if (APPLICATION.equalsIgnoreCase(roleInfo.getAudience())) { - roleInfo.setAudienceName(getApplicationName(roleInfo.getAudienceId(), tenantDomain)); + for (RoleBasicInfo roleBasicInfo : roleBasicInfoList) { + if (APPLICATION.equalsIgnoreCase(roleBasicInfo.getAudience())) { + roleBasicInfo.setAudienceName(getApplicationName(roleBasicInfo.getAudienceId(), tenantDomain)); } } } diff --git a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/RoleManagementService.java b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/RoleManagementService.java index 2497c78cba44..d5353030ce38 100644 --- a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/RoleManagementService.java +++ b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/RoleManagementService.java @@ -55,33 +55,32 @@ RoleBasicInfo addRole(String roleName, List userList, List group /** * Retrieve available roles. * - * @param limit Limit value. - * @param offset Offset value. - * @param sortBy SortBy value. - * @param sortOrder Sort order value. - * @param tenantDomain Tenant domain. - * @param requiredAttributes Required attributes. + * @param limit Limit value. + * @param offset Offset value. + * @param sortBy SortBy value. + * @param sortOrder Sort order value. + * @param tenantDomain Tenant domain. * @return List of roles. * @throws IdentityRoleManagementException IdentityRoleManagementException. */ - List getRoles(Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain, - List requiredAttributes) throws IdentityRoleManagementException; + List getRoles(Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain) + throws IdentityRoleManagementException; /** * Retrieve available roles. * - * @param filter Filter for the Role ID. - * @param limit Limit value. - * @param offset Offset value. - * @param sortBy SortBy value. - * @param sortOrder Sort order value. - * @param tenantDomain Tenant domain. - * @param requiredAttributes Required attributes. + * @param filter Filter for the Role ID. + * @param limit Limit value. + * @param offset Offset value. + * @param sortBy SortBy value. + * @param sortOrder Sort order value. + * @param tenantDomain Tenant domain. * @return List of roles. * @throws IdentityRoleManagementException IdentityRoleManagementException. */ - List getRoles(String filter, Integer limit, Integer offset, String sortBy, String sortOrder, - String tenantDomain, List requiredAttributes) throws IdentityRoleManagementException; + List getRoles(String filter, Integer limit, Integer offset, String sortBy, String sortOrder, + String tenantDomain) + throws IdentityRoleManagementException; /** * Retrieve the given role. diff --git a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/RoleManagementServiceImpl.java b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/RoleManagementServiceImpl.java index 030e3505c08a..931fa1c3ea82 100644 --- a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/RoleManagementServiceImpl.java +++ b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/RoleManagementServiceImpl.java @@ -137,8 +137,8 @@ public RoleBasicInfo addRole(String roleName, List userList, List getRoles(Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain, - List requiredAttributes) throws IdentityRoleManagementException { + public List getRoles(Integer limit, Integer offset, String sortBy, String sortOrder, + String tenantDomain) throws IdentityRoleManagementException { List roleManagementListenerList = RoleManagementServiceComponentHolder.getInstance() .getRoleManagementListenerList(); @@ -151,23 +151,23 @@ public List getRoles(Integer limit, Integer offset, String sortBy, String .getInstance(); roleManagementEventPublisherProxy.publishPreGetRolesWithException(limit, offset, sortBy, sortOrder, tenantDomain); - List roleList = roleDAO.getRoles(limit, offset, sortBy, sortOrder, tenantDomain, requiredAttributes); + List roleBasicInfoList = roleDAO.getRoles(limit, offset, sortBy, sortOrder, tenantDomain); roleManagementEventPublisherProxy.publishPostGetRoles(limit, offset, sortBy, sortOrder, tenantDomain); for (RoleManagementListener roleManagementListener : roleManagementListenerList) { if (roleManagementListener.isEnable()) { - roleManagementListener.postGetRoles(roleList, limit, offset, sortBy, sortOrder, + roleManagementListener.postGetRoles(roleBasicInfoList, limit, offset, sortBy, sortOrder, tenantDomain); } } if (log.isDebugEnabled()) { log.debug(String.format("%s get roles successfully.", getUser(tenantDomain))); } - return roleList; + return roleBasicInfoList; } @Override - public List getRoles(String filter, Integer limit, Integer offset, String sortBy, String sortOrder, - String tenantDomain, List requiredAttributes) + public List getRoles(String filter, Integer limit, Integer offset, String sortBy, String sortOrder, + String tenantDomain) throws IdentityRoleManagementException { List roleManagementListenerList = RoleManagementServiceComponentHolder.getInstance() @@ -182,19 +182,19 @@ public List getRoles(String filter, Integer limit, Integer offset, String roleManagementEventPublisherProxy.publishPreGetRolesWithException(filter, limit, offset, sortBy, sortOrder, tenantDomain); List expressionNodes = getExpressionNodes(filter); - List roleInfoList = roleDAO.getRoles(expressionNodes, limit, offset, sortBy, - sortOrder, tenantDomain, requiredAttributes); + List roleBasicInfoList = roleDAO.getRoles(expressionNodes, limit, offset, sortBy, + sortOrder, tenantDomain); roleManagementEventPublisherProxy.publishPostGetRoles(filter, limit, offset, sortBy, sortOrder, tenantDomain); for (RoleManagementListener roleManagementListener : roleManagementListenerList) { if (roleManagementListener.isEnable()) { - roleManagementListener.postGetRoles(roleInfoList, filter, limit, offset, sortBy, sortOrder, + roleManagementListener.postGetRoles(roleBasicInfoList, filter, limit, offset, sortBy, sortOrder, tenantDomain); } } if (log.isDebugEnabled()) { log.debug(String.format("%s get filtered roles successfully.", getUser(tenantDomain))); } - return roleInfoList; + return roleBasicInfoList; } @Override diff --git a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAO.java b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAO.java index 2eced18230d3..ccb3bf9823d9 100644 --- a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAO.java +++ b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAO.java @@ -56,34 +56,31 @@ RoleBasicInfo addRole(String roleName, List userList, List group /** * Retrieve available roles. * - * @param limit Limit value. - * @param offset Offset value. - * @param sortBy SortBy value. - * @param sortOrder Sort order value. - * @param tenantDomain Tenant domain. - * @param requiredAttributes Required attributes. + * @param limit Limit value. + * @param offset Offset value. + * @param sortBy SortBy value. + * @param sortOrder Sort order value. + * @param tenantDomain Tenant domain. * @return List of roles. * @throws IdentityRoleManagementException IdentityRoleManagementException. */ - List getRoles(Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain, - List requiredAttributes) + List getRoles(Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain) throws IdentityRoleManagementException; /** * Retrieve available roles matching the provided filter. * - * @param expressionNodes List of expressionNodes. - * @param limit Limit value. - * @param offset Offset value. - * @param sortBy SortBy value. - * @param sortOrder Sort order value. - * @param tenantDomain Tenant domain. - * @param requiredAttributes Required attributes. + * @param expressionNodes List of expressionNodes. + * @param limit Limit value. + * @param offset Offset value. + * @param sortBy SortBy value. + * @param sortOrder Sort order value. + * @param tenantDomain Tenant domain. * @return List of roles. * @throws IdentityRoleManagementException IdentityRoleManagementException. */ - List getRoles(List expressionNodes, Integer limit, Integer offset, String sortBy, - String sortOrder, String tenantDomain, List requiredAttributes) + List getRoles(List expressionNodes, Integer limit, Integer offset, String sortBy, + String sortOrder, String tenantDomain) throws IdentityRoleManagementException; /** diff --git a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAOImpl.java b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAOImpl.java index e1ca703105cb..750a2cf9c7dd 100644 --- a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAOImpl.java +++ b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAOImpl.java @@ -194,10 +194,6 @@ public class RoleDAOImpl implements RoleDAO { private final GroupIDResolver groupIDResolver = new GroupIDResolver(); private final UserIDResolver userIDResolver = new UserIDResolver(); private final Set systemRoles = getSystemRoles(); - private final String users = "users"; - private final String groups = "groups"; - private final String permissions = "permissions"; - private final String associatedApplications = "associatedApplications"; @Override public RoleBasicInfo addRole(String roleName, List userList, List groupList, @@ -284,8 +280,8 @@ public RoleBasicInfo addRole(String roleName, List userList, List getRoles(Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain, - List requiredAttributes) throws IdentityRoleManagementException { + public List getRoles(Integer limit, Integer offset, String sortBy, String sortOrder, + String tenantDomain) throws IdentityRoleManagementException { int tenantId = IdentityTenantUtil.getTenantId(tenantDomain); limit = validateLimit(limit); @@ -304,12 +300,12 @@ public List getRoles(Integer limit, Integer offset, String sortBy, String throw new IdentityRoleManagementServerException(UNEXPECTED_SERVER_ERROR.getCode(), "Error while listing roles in tenantDomain: " + tenantDomain, e); } - return getRolesRequestedAttributes(roles, requiredAttributes, tenantDomain); + return roles; } @Override - public List getRoles(List expressionNodes, Integer limit, Integer offset, String sortBy, - String sortOrder, String tenantDomain, List requiredAttributes) + public List getRoles(List expressionNodes, Integer limit, Integer offset, + String sortBy, String sortOrder, String tenantDomain) throws IdentityRoleManagementException { int tenantId = IdentityTenantUtil.getTenantId(tenantDomain); @@ -339,50 +335,7 @@ public List getRoles(List expressionNodes, Integer limit, throw new IdentityRoleManagementServerException(RoleConstants.Error.UNEXPECTED_SERVER_ERROR.getCode(), "Error while listing roles in tenantDomain: " + tenantDomain, e); } - return getRolesRequestedAttributes(roles, requiredAttributes, tenantDomain); - } - - private List getRolesRequestedAttributes(List roles, List requiredAttributes, - String tenantDomain) - throws IdentityRoleManagementException { - - List rolesList = new ArrayList(); - for (RoleBasicInfo roleBasicInfo : roles) { - Role role = new Role(); - role.setId(roleBasicInfo.getId()); - role.setName(roleBasicInfo.getName()); - role.setAudienceId(roleBasicInfo.getAudienceId()); - role.setAudienceName(roleBasicInfo.getAudienceName()); - role.setAudience(roleBasicInfo.getAudience()); - if (requiredAttributes != null && !requiredAttributes.isEmpty()) { - if (requiredAttributes.contains(users)) { - role.setUsers(getUserListOfRole(roleBasicInfo.getId(), tenantDomain)); - } - if (requiredAttributes.contains(groups)) { - role.setGroups(getGroupListOfRole(roleBasicInfo.getId(), tenantDomain)); - role.setIdpGroups(getIdpGroupListOfRole(roleBasicInfo.getId(), tenantDomain)); - } - if (requiredAttributes.contains(permissions)) { - if (isSharedRole(roleBasicInfo.getId(), tenantDomain)) { - role.setPermissions(getPermissionsOfSharedRole(roleBasicInfo.getId(), tenantDomain)); - } else { - role.setPermissions(getPermissions(roleBasicInfo.getId(), tenantDomain)); - } - } - if (requiredAttributes.contains(associatedApplications)) { - if (ORGANIZATION.equals(roleBasicInfo.getAudience())) { - role.setAssociatedApplications(getAssociatedAppsById(roleBasicInfo.getId(), tenantDomain)); - } else if (APPLICATION.equals(roleBasicInfo.getAudience())) { - List associatedApplications = new ArrayList<>(); - associatedApplications.add(new AssociatedApplication(roleBasicInfo.getAudienceId(), - roleBasicInfo.getAudienceName())); - role.setAssociatedApplications(associatedApplications); - } - } - } - rolesList.add(role); - } - return rolesList; + return roles; } @Override @@ -3216,7 +3169,7 @@ private void deleteSharedHybridRoles(String roleId, int mainTenantId, Connection try (ResultSet resultSet = selectStatement.executeQuery()) { while (resultSet.next()) { idsToDelete.add(new AbstractMap.SimpleEntry<>( - resultSet.getInt(1), resultSet.getInt(2))); + resultSet.getInt(1), resultSet.getInt(2))); } } try (NamedPreparedStatement deleteStatement = new NamedPreparedStatement(connection, DELETE_SHARED_ROLE)) { diff --git a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/listener/AbstractRoleManagementListener.java b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/listener/AbstractRoleManagementListener.java index ee85e832f4f5..6ec3a028214a 100644 --- a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/listener/AbstractRoleManagementListener.java +++ b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/listener/AbstractRoleManagementListener.java @@ -54,7 +54,7 @@ public void preGetRoles(Integer limit, Integer offset, String sortBy, String sor } @Override - public void postGetRoles(List roleBasicInfoList, Integer limit, Integer offset, String sortBy, + public void postGetRoles(List roleBasicInfoList, Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain) throws IdentityRoleManagementException { } @@ -66,7 +66,7 @@ public void preGetRoles(String filter, Integer limit, Integer offset, String sor } @Override - public void postGetRoles(List roleInfoList, String filter, Integer limit, Integer offset, + public void postGetRoles(List roleBasicInfoList, String filter, Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain) throws IdentityRoleManagementException { diff --git a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/listener/RoleManagementListener.java b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/listener/RoleManagementListener.java index 27d138ce606f..65b3cf725955 100644 --- a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/listener/RoleManagementListener.java +++ b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/listener/RoleManagementListener.java @@ -105,15 +105,15 @@ void preGetRoles(Integer limit, Integer offset, String sortBy, String sortOrder, /** * Invoked after retrieving a list of roles based on specified criteria. * - * @param roleInfoList The list of role basic info. - * @param limit The maximum number of roles to retrieve. - * @param offset The starting index from which to retrieve roles. - * @param sortBy The attribute by which the roles should be sorted (e.g., "name", "creationDate"). - * @param sortOrder The order in which to sort the roles. - * @param tenantDomain The domain in which the operation is being performed. + * @param roleBasicInfoList The list of role basic info. + * @param limit The maximum number of roles to retrieve. + * @param offset The starting index from which to retrieve roles. + * @param sortBy The attribute by which the roles should be sorted (e.g., "name", "creationDate"). + * @param sortOrder The order in which to sort the roles. + * @param tenantDomain The domain in which the operation is being performed. * @throws IdentityRoleManagementException If an error occurs during the pre-retrieval phase. */ - void postGetRoles(List roleInfoList, Integer limit, Integer offset, String sortBy, + void postGetRoles(List roleBasicInfoList, Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain) throws IdentityRoleManagementException; /** @@ -133,16 +133,16 @@ void preGetRoles(String filter, Integer limit, Integer offset, String sortBy, St /** * Invoked after retrieving a list of roles based on specified criteria. * - * @param roleInfoList The list of role basic info. - * @param filter The filter value. - * @param limit The maximum number of roles to retrieve. - * @param offset The starting index from which to retrieve roles. - * @param sortBy The attribute by which the roles should be sorted (e.g., "name", "creationDate"). - * @param sortOrder The order in which to sort the roles. - * @param tenantDomain The domain in which the operation is being performed. + * @param roleBasicInfoList The list of role basic info. + * @param filter The filter value. + * @param limit The maximum number of roles to retrieve. + * @param offset The starting index from which to retrieve roles. + * @param sortBy The attribute by which the roles should be sorted (e.g., "name", "creationDate"). + * @param sortOrder The order in which to sort the roles. + * @param tenantDomain The domain in which the operation is being performed. * @throws IdentityRoleManagementException If an error occurs during the pre-retrieval phase. */ - void postGetRoles(List roleInfoList, String filter, Integer limit, Integer offset, + void postGetRoles(List roleBasicInfoList, String filter, Integer limit, Integer offset, String sortBy, String sortOrder, String tenantDomain) throws IdentityRoleManagementException; /** diff --git a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/test/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAOTest.java b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/test/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAOTest.java index 8349c1978db6..4ceac6372c5b 100644 --- a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/test/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAOTest.java +++ b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/test/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAOTest.java @@ -43,7 +43,6 @@ import org.wso2.carbon.identity.role.v2.mgt.core.exception.IdentityRoleManagementException; import org.wso2.carbon.identity.role.v2.mgt.core.model.IdpGroup; import org.wso2.carbon.identity.role.v2.mgt.core.model.Permission; -import org.wso2.carbon.identity.role.v2.mgt.core.model.Role; import org.wso2.carbon.identity.role.v2.mgt.core.model.RoleAudience; import org.wso2.carbon.identity.role.v2.mgt.core.model.RoleBasicInfo; import org.wso2.carbon.user.api.AuthorizationManager; @@ -281,8 +280,8 @@ public void testGetRoles() throws Exception { when(IdentityDatabaseUtil.getDBConnection(anyBoolean())).thenReturn(connection8); doCallRealMethod().when(IdentityUtil.class, "extractDomainFromName", anyString()); doCallRealMethod().when(UserCoreUtil.class, "removeDomainFromName", anyString()); - List roles = roleDAO.getRoles(2, 1, null, null, - SAMPLE_TENANT_DOMAIN, null); + List roles = roleDAO.getRoles(2, 1, null, null, + SAMPLE_TENANT_DOMAIN); Assert.assertEquals(getRoleNamesList(roles), expectedRoles); } } @@ -318,16 +317,15 @@ public void testGetRolesWithFilter() throws Exception { when(UserCoreUtil.isEveryoneRole(anyString(), any(RealmConfiguration.class))).thenReturn(false); when(IdentityUtil.getDefaultItemsPerPage()).thenReturn(IdentityCoreConstants.DEFAULT_ITEMS_PRE_PAGE); - when(IdentityUtil.getMaximumItemPerPage()). - thenReturn(IdentityCoreConstants.DEFAULT_MAXIMUM_ITEMS_PRE_PAGE); + when(IdentityUtil.getMaximumItemPerPage()).thenReturn(IdentityCoreConstants.DEFAULT_MAXIMUM_ITEMS_PRE_PAGE); when(IdentityDatabaseUtil.getUserDBConnection(anyBoolean())).thenReturn(connection7); when(IdentityDatabaseUtil.getDBConnection(anyBoolean())).thenReturn(connection8); doCallRealMethod().when(IdentityUtil.class, "extractDomainFromName", anyString()); doCallRealMethod().when(UserCoreUtil.class, "removeDomainFromName", anyString()); List expressionNodes = getExpressionNodes("name co roleA and audience co application and audienceId co test-app-id"); - List roles = roleDAO.getRoles(expressionNodes, 2, 1, null, null, - SAMPLE_TENANT_DOMAIN, null); + List roles = roleDAO.getRoles(expressionNodes, 2, 1, null, null, + SAMPLE_TENANT_DOMAIN); Assert.assertEquals(getRoleNamesList(roles), expectedRoles); } } @@ -803,10 +801,10 @@ private void mockRealmConfiguration() throws UserStoreException { when(mockUserRealm.getRealmConfiguration()).thenReturn(realmConfiguration); } - private List getRoleNamesList(List roles) { + private List getRoleNamesList(List roles) { List roleNames = new ArrayList<>(); - for (Role role : roles) { + for (RoleBasicInfo role : roles) { roleNames.add(role.getName()); } return roleNames.stream().sorted().collect(Collectors.toList());