Skip to content

Commit

Permalink
Refactor unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sadilchamishka committed Jan 8, 2025
1 parent a7cefda commit 96d26d0
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -629,9 +629,14 @@ public void testFilteringUsersOfGroupWithGET() throws UserStoreException, IOExce

org.wso2.carbon.user.core.common.User testUser1 = new org.wso2.carbon.user.core.common.User(UUID.randomUUID()
.toString(), "testUser1", "testUser1");
testUser1.setUserStoreDomain("PRIMARY");
List<org.wso2.carbon.user.core.common.User> filteredUsers = new ArrayList<>();
filteredUsers.add(testUser1);

scimCommonUtils.when(() -> SCIMCommonUtils.convertLocalToSCIMDialect(anyMap(), anyMap())).thenReturn(new HashMap<String, String>() {{
put(SCIMConstants.CommonSchemaConstants.ID_URI, "1f70378a-69bb-49cf-aa51-a0493c09110c");
}});

when(mockedUserStoreManager.getSecondaryUserStoreManager(domain)).thenReturn(mockedJDBCUserStoreManager);
when(mockedJDBCUserStoreManager.isSCIMEnabled()).thenReturn(true);
scimCommonUtils.when(SCIMCommonUtils::isGroupBasedUserFilteringImprovementsEnabled).thenReturn(true);
Expand All @@ -641,8 +646,10 @@ public void testFilteringUsersOfGroupWithGET() throws UserStoreException, IOExce
when(mockedUserStoreManager.getUserListOfGroupWithID(anyString())).thenReturn(filteredUsers);

UniqueIDUserClaimSearchEntry uniqueIDUserClaimSearchEntry = new UniqueIDUserClaimSearchEntry();
when(mockedUserStoreManager.getUsersClaimValuesWithID(any(), any(), nullable(String.class))).thenReturn(
Collections.singletonList(uniqueIDUserClaimSearchEntry));
List<UniqueIDUserClaimSearchEntry> uniqueIDUserClaimSearchEntries = new ArrayList<>();
uniqueIDUserClaimSearchEntries.add(uniqueIDUserClaimSearchEntry);
when(mockedUserStoreManager.getUsersClaimValuesWithID(any(), any(), nullable(String.class)))
.thenReturn(uniqueIDUserClaimSearchEntries);

UsersGetResponse result = scimUserManager.listUsersWithGET(node, 1, null, null, null, domain, new HashMap<>());
assertEquals(result.getUsers().size(), filteredUsers.size());
Expand Down

0 comments on commit 96d26d0

Please sign in to comment.