Search in sources :

Example 21 with UserNamespaceAuthorization

use of org.finra.herd.model.api.xml.UserNamespaceAuthorization in project herd by FINRAOS.

the class UserNamespaceAuthorizationServiceTest method testDeleteUserNamespaceAuthorizationUpperCaseParameters.

@Test
public void testDeleteUserNamespaceAuthorizationUpperCaseParameters() {
    // 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);
    // Validate that this user namespace authorization exists.
    assertNotNull(userNamespaceAuthorizationDao.getUserNamespaceAuthorizationByKey(key));
    // Delete a user namespace authorization using uppercase input parameters.
    UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationService.deleteUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(key.getUserId().toUpperCase(), key.getNamespace().toUpperCase()));
    // Validate the returned object.
    assertEquals(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS), resultUserNamespaceAuthorization);
    // Ensure that this user namespace authorization is no longer there.
    assertNull(userNamespaceAuthorizationDao.getUserNamespaceAuthorizationByKey(key));
}
Also used : UserNamespaceAuthorizationKey(org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey) UserNamespaceAuthorizationEntity(org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity) UserNamespaceAuthorization(org.finra.herd.model.api.xml.UserNamespaceAuthorization) Test(org.junit.Test)

Example 22 with UserNamespaceAuthorization

use of org.finra.herd.model.api.xml.UserNamespaceAuthorization in project herd by FINRAOS.

the class UserNamespaceAuthorizationServiceTest method testDeleteUserNamespaceAuthorizationLowerCaseParameters.

@Test
public void testDeleteUserNamespaceAuthorizationLowerCaseParameters() {
    // 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);
    // Validate that this user namespace authorization exists.
    assertNotNull(userNamespaceAuthorizationDao.getUserNamespaceAuthorizationByKey(key));
    // Delete a user namespace authorization using lowercase input parameters.
    UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationService.deleteUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(key.getUserId().toLowerCase(), key.getNamespace().toLowerCase()));
    // Validate the returned object.
    assertEquals(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS), resultUserNamespaceAuthorization);
    // Ensure that this user namespace authorization is no longer there.
    assertNull(userNamespaceAuthorizationDao.getUserNamespaceAuthorizationByKey(key));
}
Also used : UserNamespaceAuthorizationKey(org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey) UserNamespaceAuthorizationEntity(org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity) UserNamespaceAuthorization(org.finra.herd.model.api.xml.UserNamespaceAuthorization) Test(org.junit.Test)

Example 23 with UserNamespaceAuthorization

use of org.finra.herd.model.api.xml.UserNamespaceAuthorization in project herd by FINRAOS.

the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorizationsByUserIdLowerCaseParameters.

@Test
public void testGetUserNamespaceAuthorizationsByUserIdLowerCaseParameters() 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 user id using lowercase user id value.
    UserNamespaceAuthorizations resultUserNamespaceAuthorizations = userNamespaceAuthorizationService.getUserNamespaceAuthorizationsByUserId(key.getUserId().toLowerCase());
    // Validate the returned object.
    assertEquals(new UserNamespaceAuthorizations(Arrays.asList(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS))), resultUserNamespaceAuthorizations);
}
Also used : UserNamespaceAuthorizations(org.finra.herd.model.api.xml.UserNamespaceAuthorizations) UserNamespaceAuthorizationKey(org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey) UserNamespaceAuthorizationEntity(org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity) UserNamespaceAuthorization(org.finra.herd.model.api.xml.UserNamespaceAuthorization) Test(org.junit.Test)

Example 24 with UserNamespaceAuthorization

use of org.finra.herd.model.api.xml.UserNamespaceAuthorization in project herd by FINRAOS.

the class UserNamespaceAuthorizationServiceTest method testDeleteUserNamespaceAuthorization.

// Unit tests for deleteUserNamespaceAuthorization().
@Test
public void testDeleteUserNamespaceAuthorization() {
    // 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);
    // Validate that this user namespace authorization exists.
    assertNotNull(userNamespaceAuthorizationDao.getUserNamespaceAuthorizationByKey(key));
    // Delete this user namespace authorization.
    UserNamespaceAuthorization deletedUserNamespaceAuthorization = userNamespaceAuthorizationService.deleteUserNamespaceAuthorization(key);
    // Validate the returned object.
    assertEquals(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS), deletedUserNamespaceAuthorization);
    // Ensure that this user namespace authorization is no longer there.
    assertNull(userNamespaceAuthorizationDao.getUserNamespaceAuthorizationByKey(key));
}
Also used : UserNamespaceAuthorizationKey(org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey) UserNamespaceAuthorizationEntity(org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity) UserNamespaceAuthorization(org.finra.herd.model.api.xml.UserNamespaceAuthorization) Test(org.junit.Test)

Example 25 with UserNamespaceAuthorization

use of org.finra.herd.model.api.xml.UserNamespaceAuthorization in project herd by FINRAOS.

the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorizationsByUserIdTrimParameters.

@Test
public void testGetUserNamespaceAuthorizationsByUserIdTrimParameters() 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 user id using user id value with leading and trailing empty spaces.
    UserNamespaceAuthorizations resultUserNamespaceAuthorizations = userNamespaceAuthorizationService.getUserNamespaceAuthorizationsByUserId(addWhitespace(key.getUserId()));
    // Validate the returned object.
    assertEquals(new UserNamespaceAuthorizations(Arrays.asList(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS))), resultUserNamespaceAuthorizations);
}
Also used : UserNamespaceAuthorizations(org.finra.herd.model.api.xml.UserNamespaceAuthorizations) UserNamespaceAuthorizationKey(org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey) UserNamespaceAuthorizationEntity(org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity) UserNamespaceAuthorization(org.finra.herd.model.api.xml.UserNamespaceAuthorization) Test(org.junit.Test)

Aggregations

UserNamespaceAuthorization (org.finra.herd.model.api.xml.UserNamespaceAuthorization)29 UserNamespaceAuthorizationKey (org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey)29 Test (org.junit.Test)28 UserNamespaceAuthorizationEntity (org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity)18 UserNamespaceAuthorizations (org.finra.herd.model.api.xml.UserNamespaceAuthorizations)8 UserNamespaceAuthorizationCreateRequest (org.finra.herd.model.api.xml.UserNamespaceAuthorizationCreateRequest)5 UserNamespaceAuthorizationUpdateRequest (org.finra.herd.model.api.xml.UserNamespaceAuthorizationUpdateRequest)5 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)2