use of org.finra.herd.model.api.xml.UserNamespaceAuthorization in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceImpl method createUserNamespaceAuthorizationFromEntity.
/**
* Creates the user namespace authorization from the persisted entity.
*
* @param userNamespaceAuthorizationEntity the user namespace authorization entity
*
* @return the user namespace authorization
*/
private UserNamespaceAuthorization createUserNamespaceAuthorizationFromEntity(UserNamespaceAuthorizationEntity userNamespaceAuthorizationEntity) {
UserNamespaceAuthorization userNamespaceAuthorization = new UserNamespaceAuthorization();
userNamespaceAuthorization.setId(userNamespaceAuthorizationEntity.getId());
UserNamespaceAuthorizationKey userNamespaceAuthorizationKey = new UserNamespaceAuthorizationKey();
userNamespaceAuthorization.setUserNamespaceAuthorizationKey(userNamespaceAuthorizationKey);
userNamespaceAuthorizationKey.setUserId(userNamespaceAuthorizationEntity.getUserId());
userNamespaceAuthorizationKey.setNamespace(userNamespaceAuthorizationEntity.getNamespace().getCode());
userNamespaceAuthorization.setNamespacePermissions(userNamespaceAuthorizationHelper.getNamespacePermissions(userNamespaceAuthorizationEntity));
return userNamespaceAuthorization;
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorization in project herd by FINRAOS.
the class UserNamespaceAuthorizationRestControllerTest method testDeleteUserNamespaceAuthorization.
@Test
public void testDeleteUserNamespaceAuthorization() {
// Create a user namespace authorization key
UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
UserNamespaceAuthorization userNamespaceAuthorization = new UserNamespaceAuthorization(ID, key, SUPPORTED_NAMESPACE_PERMISSIONS);
when(userNamespaceAuthorizationService.deleteUserNamespaceAuthorization(key)).thenReturn(userNamespaceAuthorization);
// Delete this user namespace authorization.
UserNamespaceAuthorization deletedUserNamespaceAuthorization = userNamespaceAuthorizationRestController.deleteUserNamespaceAuthorization(key.getUserId(), key.getNamespace());
// Verify the external calls.
verify(userNamespaceAuthorizationService).deleteUserNamespaceAuthorization(key);
verifyNoMoreInteractions(userNamespaceAuthorizationService);
// Validate the returned object.
assertEquals(userNamespaceAuthorization, deletedUserNamespaceAuthorization);
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorization in project herd by FINRAOS.
the class UserNamespaceAuthorizationRestControllerTest method testCreateUserNamespaceAuthorization.
@Test
public void testCreateUserNamespaceAuthorization() {
// Create a user namespace authorization key.
UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
UserNamespaceAuthorizationCreateRequest request = new UserNamespaceAuthorizationCreateRequest(key, Arrays.asList(NamespacePermissionEnum.READ, NamespacePermissionEnum.WRITE, NamespacePermissionEnum.EXECUTE, NamespacePermissionEnum.GRANT));
UserNamespaceAuthorization userNamespaceAuthorization = new UserNamespaceAuthorization(ID, key, SUPPORTED_NAMESPACE_PERMISSIONS);
// Mock calls to external method.
when(userNamespaceAuthorizationService.createUserNamespaceAuthorization(request)).thenReturn(userNamespaceAuthorization);
UserNamespaceAuthorization response = userNamespaceAuthorizationRestController.createUserNamespaceAuthorization(request);
// Verify the external calls.
verify(userNamespaceAuthorizationService).createUserNamespaceAuthorization(request);
verifyNoMoreInteractions(userNamespaceAuthorizationService);
// Validate the returned object.
assertEquals(userNamespaceAuthorization, response);
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorization in project herd by FINRAOS.
the class UserNamespaceAuthorizationRestControllerTest method testGetUserNamespaceAuthorization.
@Test
public void testGetUserNamespaceAuthorization() {
// Create a user namespace authorization key
UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
UserNamespaceAuthorization userNamespaceAuthorization = new UserNamespaceAuthorization(ID, key, SUPPORTED_NAMESPACE_PERMISSIONS);
when(userNamespaceAuthorizationService.getUserNamespaceAuthorization(key)).thenReturn(userNamespaceAuthorization);
// Get a user namespace authorization.
UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationRestController.getUserNamespaceAuthorization(key.getUserId(), key.getNamespace());
// Verify the external calls.
verify(userNamespaceAuthorizationService).getUserNamespaceAuthorization(key);
verifyNoMoreInteractions(userNamespaceAuthorizationService);
// Validate the returned object.
assertEquals(userNamespaceAuthorization, resultUserNamespaceAuthorization);
}
use of org.finra.herd.model.api.xml.UserNamespaceAuthorization in project herd by FINRAOS.
the class UserNamespaceAuthorizationServiceTest method testCreateUserNamespaceAuthorizationLowerCaseParameters.
@Test
public void testCreateUserNamespaceAuthorizationLowerCaseParameters() {
// Create a user namespace authorization key.
UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
// Create and persist the relative database entities.
namespaceDaoTestHelper.createNamespaceEntity(key.getNamespace());
// Create a user namespace authorization using lowercase input parameters.
UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationService.createUserNamespaceAuthorization(new UserNamespaceAuthorizationCreateRequest(new UserNamespaceAuthorizationKey(key.getUserId().toLowerCase(), key.getNamespace().toLowerCase()), SUPPORTED_NAMESPACE_PERMISSIONS));
// Validate the returned object.
assertEquals(new UserNamespaceAuthorization(resultUserNamespaceAuthorization.getId(), new UserNamespaceAuthorizationKey(key.getUserId().toLowerCase(), key.getNamespace()), SUPPORTED_NAMESPACE_PERMISSIONS), resultUserNamespaceAuthorization);
}
Aggregations