use of org.wso2.identity.integration.test.rest.api.server.user.store.v1.model.AvailableUserStoreClassesRes in project product-is by wso2.
the class UserStoreSuccessTest method testGetAvailableUserStoreClasses.
@Test(dependsOnMethods = { "testAddSecondaryUserStore" })
public void testGetAvailableUserStoreClasses() throws IOException {
Map<String, AvailableUserStoreClassesRes> userStoreClassesResMap;
String expectedResponse = readResource("get-available-user-store-classes.json");
ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory());
List<AvailableUserStoreClassesRes> availableUserStoreClassesResList = Arrays.asList(jsonWriter.readValue(expectedResponse, AvailableUserStoreClassesRes[].class));
userStoreClassesResMap = availableUserStoreClassesResList.stream().collect(Collectors.toMap(AvailableUserStoreClassesRes::getTypeId, c -> c));
Response response = getResponseOfGet(USER_STORE_PATH_COMPONENT + USER_STORE_META_COMPONENT);
ValidatableResponse validatableResponse = response.then().log().ifValidationFails().assertThat().statusCode(HttpStatus.SC_OK);
for (Map.Entry<String, AvailableUserStoreClassesRes> resEntry : userStoreClassesResMap.entrySet()) {
validatableResponse.body("find{ it.typeId == '" + resEntry.getKey() + "' }.typeName", equalTo(resEntry.getValue().getTypeName()));
validatableResponse.body("find{ it.typeId == '" + resEntry.getKey() + "' }.className", equalTo(resEntry.getValue().getClassName()));
validatableResponse.body("find{ it.typeId == '" + resEntry.getKey() + "' }.self", equalTo("/t/" + tenant + "/api/server/v1" + USER_STORE_PATH_COMPONENT + PATH_SEPARATOR + "meta/types/" + resEntry.getValue().getTypeId()));
}
}
use of org.wso2.identity.integration.test.rest.api.server.user.store.v1.model.AvailableUserStoreClassesRes in project identity-api-server by wso2.
the class ServerUserStoreService method getAvailableUserStoreTypes.
/**
* To retrieve the available user store classes.
*
* @return List<AvailableUserStoreClassesRes>.
*/
public List<AvailableUserStoreClassesRes> getAvailableUserStoreTypes() {
UserStoreConfigService userStoreConfigService = UserStoreConfigServiceHolder.getInstance().getUserStoreConfigService();
Set<String> classNames;
try {
classNames = userStoreConfigService.getAvailableUserStoreClasses();
List<AvailableUserStoreClassesRes> propertiesToAdd = new ArrayList<>();
Map<String, Boolean> userStoreManagersType = UserStoreManagerRegistry.getUserStoreManagersType();
for (String className : classNames) {
AvailableUserStoreClassesRes availableUserStoreClassesResDTO = new AvailableUserStoreClassesRes();
String typeId = base64URLEncodeId(Objects.requireNonNull(getUserStoreTypeName(className)));
availableUserStoreClassesResDTO.setClassName(className);
availableUserStoreClassesResDTO.setTypeName(getUserStoreTypeName(className));
availableUserStoreClassesResDTO.setTypeId(typeId);
availableUserStoreClassesResDTO.setSelf(ContextLoader.buildURIForBody(String.format(V1_API_PATH_COMPONENT + UserStoreConstants.USER_STORE_PATH_COMPONENT + "/meta/types/%s", typeId)).toString());
if (userStoreManagersType.containsKey(className)) {
availableUserStoreClassesResDTO.setIsLocal(userStoreManagersType.get(className));
}
propertiesToAdd.add(availableUserStoreClassesResDTO);
}
return propertiesToAdd;
} catch (IdentityUserStoreMgtException e) {
UserStoreConstants.ErrorMessage errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_RETRIEVING_USER_STORE_TYPE;
throw handleIdentityUserStoreMgtException(e, errorEnum);
}
}
Aggregations