use of org.finra.herd.model.api.xml.UserNamespaceAuthorizations in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorizationsByNamespaceLowerCaseParameters.
@Test
public void testGetUserNamespaceAuthorizationsByNamespaceLowerCaseParameters() throws Exception {
// Create a user namespace authorization key.
UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
// Create and persist the relative database entities.
UserNamespaceAuthorizationEntity userNamespaceAuthorizationEntity = userNamespaceAuthorizationDaoTestHelper.createUserNamespaceAuthorizationEntity(key, SUPPORTED_NAMESPACE_PERMISSIONS);
// Get user namespace authorizations for the specified namespace using lowercase namespace code.
UserNamespaceAuthorizations resultUserNamespaceAuthorizations = userNamespaceAuthorizationService.getUserNamespaceAuthorizationsByNamespace(key.getNamespace().toLowerCase());
// Validate the returned object.
assertEquals(new UserNamespaceAuthorizations(Arrays.asList(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS))), resultUserNamespaceAuthorizations);
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorizations in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorizationsByUserIdEmptyList.
@Test
public void testGetUserNamespaceAuthorizationsByUserIdEmptyList() throws Exception {
// Retrieve an empty list of user namespace authorizations.
UserNamespaceAuthorizations resultUserNamespaceAuthorizations = userNamespaceAuthorizationService.getUserNamespaceAuthorizationsByUserId("I_DO_NOT_EXIST");
// Validate the returned object.
assertEquals(new UserNamespaceAuthorizations(), resultUserNamespaceAuthorizations);
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorizations in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceImpl method getUserNamespaceAuthorizationsByUserId.
@Override
public UserNamespaceAuthorizations getUserNamespaceAuthorizationsByUserId(String userId) {
// Validate and trim the user id.
Assert.hasText(userId, "A user id must be specified.");
String userIdLocal = userId.trim();
// Retrieve and return a list of user namespace authorization entities for the specified user id.
List<UserNamespaceAuthorizationEntity> userNamespaceAuthorizationEntities = userNamespaceAuthorizationDao.getUserNamespaceAuthorizationsByUserId(userIdLocal);
// Create and populate the user namespace authorizations object from the returned entities.
UserNamespaceAuthorizations userNamespaceAuthorizations = new UserNamespaceAuthorizations();
userNamespaceAuthorizations.getUserNamespaceAuthorizations().addAll(createUserNamespaceAuthorizationsFromEntities(userNamespaceAuthorizationEntities));
return userNamespaceAuthorizations;
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorizations in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceImpl method getUserNamespaceAuthorizationsByNamespace.
@NamespacePermission(fields = "#namespace", permissions = NamespacePermissionEnum.READ)
@Override
public UserNamespaceAuthorizations getUserNamespaceAuthorizationsByNamespace(String namespace) {
// Validate and trim the namespace code.
Assert.hasText(namespace, "A namespace must be specified.");
String namespaceLocal = namespace.trim();
// Validate that specified namespace exists.
namespaceDaoHelper.getNamespaceEntity(namespaceLocal);
// Retrieve and return a list of user namespace authorization entities for the specified namespace.
List<UserNamespaceAuthorizationEntity> userNamespaceAuthorizationEntities = userNamespaceAuthorizationDao.getUserNamespaceAuthorizationsByNamespace(namespaceLocal);
// Create and populate the user namespace authorizations object from the returned entities.
UserNamespaceAuthorizations userNamespaceAuthorizations = new UserNamespaceAuthorizations();
userNamespaceAuthorizations.getUserNamespaceAuthorizations().addAll(createUserNamespaceAuthorizationsFromEntities(userNamespaceAuthorizationEntities));
return userNamespaceAuthorizations;
}
Aggregations