OIDCAuthService { public ResponseEntity<OIDCEntityResponse> entityLookUp(String token, OIDCLookupEntityRequest oidcLookupEntityRequest) { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String> builder() .put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)) .put(LogMessage.ACTION, "Entity Lookup from identity engine") .put(LogMessage.MESSAGE, "Trying to Lookup entity from identity engine") .put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build())); return oidcUtil.entityLookUp(token, oidcLookupEntityRequest); }  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 entityLookUpSuccess() throws Exception { String token = "4EpPYDSfgN2D4Gf7UmNO3nuL"; OIDCLookupEntityRequest oidcLookupEntityRequest = new OIDCLookupEntityRequest(); oidcLookupEntityRequest.setId("1223"); oidcLookupEntityRequest.setAlias_id("123"); oidcLookupEntityRequest.setAlias_mount_accessor("mount"); oidcLookupEntityRequest.setAlias_name("alias_name"); oidcLookupEntityRequest.setName("name"); String jsonStr = JSONUtil.getJSON(oidcLookupEntityRequest); OIDCEntityResponse oidcEntityResponse = new OIDCEntityResponse(); oidcEntityResponse.setEntityName("entity_63f119d2"); List<String> policies = new ArrayList<>(); policies.add("safeadmin"); oidcEntityResponse.setPolicies(policies); Response response = getMockResponse(HttpStatus.OK, true, "\"{\\\"entityName\\\":\\\"entity_63f119d2\\\",\\\"policies\\\":[\\\"safeadmin\\\"]}\""); String responseInput = "\"{\\\"entityName\\\":\\\"entity_63f119d2\\\",\\\"policies\\\":[\\\"safeadmin\\\"]}\""; when(OIDCUtil.getEntityLookUpResponse(responseInput)).thenReturn(oidcEntityResponse); ResponseEntity<OIDCEntityResponse> responseEntityExpected = ResponseEntity.status(HttpStatus.OK) .body(oidcEntityResponse); when(OIDCUtil.entityLookUp(token, oidcLookupEntityRequest)).thenReturn(responseEntityExpected); ResponseEntity<OIDCEntityResponse> responseEntity = oidcAuthService.entityLookUp(token, oidcLookupEntityRequest); assertEquals(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(responseEntityExpected, responseEntity); }