OIDCAuthService { public ResponseEntity<DirectoryObjects> searchGroupInAzureAD(String groupName) { String ssoToken = oidcUtil.getSSOToken(); DirectoryObjects groups = new DirectoryObjects(); if (!StringUtils.isEmpty(ssoToken)) { List<DirectoryGroup> allGroups = oidcUtil.getGroupsFromAAD(ssoToken, groupName); DirectoryObjectsList groupsList = new DirectoryObjectsList(); groupsList.setValues(allGroups.toArray(new DirectoryGroup[allGroups.size()])); groups.setData(groupsList); } return ResponseEntity.status(HttpStatus.OK).body(groups); }  ResponseEntity<String> getAuthenticationMounts(String token); ResponseEntity<OIDCEntityResponse> entityLookUp(String token,
			OIDCLookupEntityRequest oidcLookupEntityRequest); ResponseEntity<String> groupEntityLookUp(String token, OIDCLookupEntityRequest oidcLookupEntityRequest); ResponseEntity<String> readEntityAliasById(String token, String id); ResponseEntity<String> readEntityByName(String token, String entityName); ResponseEntity<String> updateEntityByName(String token, OIDCEntityRequest oidcEntityRequest); ResponseEntity<String> updateIdentityGroupByName(String token,
                                                            OIDCIdentityGroupRequest oidcIdentityGroupRequest); ResponseEntity<String> readGroupAliasById(String token, String id); ResponseEntity<String> deleteGroupByName(String token, String name); ResponseEntity<String> deleteGroupAliasByID(String token, String id); ResponseEntity<String> createGroupAlias(String token, GroupAliasRequest groupAliasRequest); ResponseEntity<String> getAuthUrl(OidcRequest oidcRequest); ResponseEntity<String> processOIDCCallback(String state, String code); ResponseEntity<String> getGroupObjectIdFromAzure(String groupName); ResponseEntity<String> getIdentityGroupDetails(String groupName, String token); ResponseEntity<String> getUserName(UserDetails userDetails); ResponseEntity<DirectoryObjects> searchGroupInAzureAD(String groupName);  }
@Test public void test_searchGroupInAzureAD_Success() throws Exception { String ssoToken = "abcd"; String groupName = "testgroup"; when(OIDCUtil.getSSOToken()).thenReturn(ssoToken); DirectoryObjects groups = new DirectoryObjects(); DirectoryObjectsList groupsList = new DirectoryObjectsList(); List<DirectoryGroup> allGroups = new ArrayList<>(); DirectoryGroup directoryGroup1 = new DirectoryGroup(); directoryGroup1.setDisplayName("testgroup"); directoryGroup1.setGroupName("testgroup"); directoryGroup1.setEmail(null); allGroups.add(directoryGroup1); DirectoryGroup directoryGroup2 = new DirectoryGroup(); directoryGroup2.setDisplayName("testgroup1"); directoryGroup2.setGroupName("testgroup1"); directoryGroup2.setEmail(null); allGroups.add(directoryGroup1); groupsList.setValues(allGroups.toArray(new DirectoryGroup[allGroups.size()])); groups.setData(groupsList); when(OIDCUtil.getGroupsFromAAD(ssoToken, groupName)).thenReturn(allGroups); ResponseEntity<DirectoryObjects> responseEntity = oidcAuthService.searchGroupInAzureAD(groupName); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(2, responseEntity.getBody().getData().getValues().length); }