Search in sources :

Example 11 with UserNamespaceAuthorization

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

the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorizationUpperCaseParameters.

@Test
public void testGetUserNamespaceAuthorizationUpperCaseParameters() {
    // Create a user namespace authorization key.
    UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
    // Create and persist the relative database entities.
    NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(key.getNamespace());
    UserNamespaceAuthorizationEntity userNamespaceAuthorizationEntity = userNamespaceAuthorizationDaoTestHelper.createUserNamespaceAuthorizationEntity(key, SUPPORTED_NAMESPACE_PERMISSIONS);
    // Get a user namespace authorization using uppercase input parameters.
    UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationService.getUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(key.getUserId().toUpperCase(), key.getNamespace().toUpperCase()));
    // Validate the returned object.
    assertEquals(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS), resultUserNamespaceAuthorization);
}
Also used : UserNamespaceAuthorizationKey(org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey) NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) UserNamespaceAuthorizationEntity(org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity) UserNamespaceAuthorization(org.finra.herd.model.api.xml.UserNamespaceAuthorization) Test(org.junit.Test)

Example 12 with UserNamespaceAuthorization

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

the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorizationLowerCaseParameters.

@Test
public void testGetUserNamespaceAuthorizationLowerCaseParameters() {
    // Create a user namespace authorization key.
    UserNamespaceAuthorizationKey key = new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE);
    // Create and persist the relative database entities.
    NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(key.getNamespace());
    UserNamespaceAuthorizationEntity userNamespaceAuthorizationEntity = userNamespaceAuthorizationDaoTestHelper.createUserNamespaceAuthorizationEntity(key, SUPPORTED_NAMESPACE_PERMISSIONS);
    // Get a user namespace authorization using lowercase input parameters.
    UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationService.getUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(key.getUserId().toLowerCase(), key.getNamespace().toLowerCase()));
    // Validate the returned object.
    assertEquals(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS), resultUserNamespaceAuthorization);
}
Also used : UserNamespaceAuthorizationKey(org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey) NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) UserNamespaceAuthorizationEntity(org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity) UserNamespaceAuthorization(org.finra.herd.model.api.xml.UserNamespaceAuthorization) Test(org.junit.Test)

Example 13 with UserNamespaceAuthorization

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

the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorizationsByUserId.

// Unit tests for getUserNamespaceAuthorizationsByUserId().
@Test
public void testGetUserNamespaceAuthorizationsByUserId() throws Exception {
    // Create user namespace authorization keys. The keys are listed out of order to validate the order by logic.
    List<UserNamespaceAuthorizationKey> keys = Arrays.asList(new UserNamespaceAuthorizationKey(USER_ID_2, NAMESPACE_2), new UserNamespaceAuthorizationKey(USER_ID_2, NAMESPACE), new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE_2), new UserNamespaceAuthorizationKey(USER_ID, NAMESPACE));
    // Create and persist the relative database entities.
    for (UserNamespaceAuthorizationKey key : keys) {
        userNamespaceAuthorizationDaoTestHelper.createUserNamespaceAuthorizationEntity(key, SUPPORTED_NAMESPACE_PERMISSIONS);
    }
    // Get user namespace authorizations for the specified user id.
    UserNamespaceAuthorizations resultUserNamespaceAuthorizations = userNamespaceAuthorizationService.getUserNamespaceAuthorizationsByUserId(USER_ID);
    // Validate the returned object.
    assertEquals(new UserNamespaceAuthorizations(Arrays.asList(new UserNamespaceAuthorization(resultUserNamespaceAuthorizations.getUserNamespaceAuthorizations().get(0).getId(), keys.get(3), SUPPORTED_NAMESPACE_PERMISSIONS), new UserNamespaceAuthorization(resultUserNamespaceAuthorizations.getUserNamespaceAuthorizations().get(1).getId(), keys.get(2), SUPPORTED_NAMESPACE_PERMISSIONS))), resultUserNamespaceAuthorizations);
}
Also used : UserNamespaceAuthorizations(org.finra.herd.model.api.xml.UserNamespaceAuthorizations) UserNamespaceAuthorizationKey(org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey) UserNamespaceAuthorization(org.finra.herd.model.api.xml.UserNamespaceAuthorization) Test(org.junit.Test)

Example 14 with UserNamespaceAuthorization

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

the class UserNamespaceAuthorizationServiceTest method testDeleteUserNamespaceAuthorizationTrimParameters.

@Test
public void testDeleteUserNamespaceAuthorizationTrimParameters() {
    // 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 input parameters with leading and trailing empty spaces.
    UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationService.deleteUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(addWhitespace(key.getUserId()), addWhitespace(key.getNamespace())));
    // 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 15 with UserNamespaceAuthorization

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

the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorization.

// Unit tests for getUserNamespaceAuthorization().
@Test
public void testGetUserNamespaceAuthorization() {
    // 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 a user namespace authorization.
    UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationService.getUserNamespaceAuthorization(key);
    // Validate the returned object.
    assertEquals(new UserNamespaceAuthorization(userNamespaceAuthorizationEntity.getId(), key, SUPPORTED_NAMESPACE_PERMISSIONS), resultUserNamespaceAuthorization);
}
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)

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