Search in sources :

Example 6 with UserNamespaceAuthorizationEntity

use of org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity in project herd by FINRAOS.

the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorizationsByNamespaceTrimParameters.

@Test
public void testGetUserNamespaceAuthorizationsByNamespaceTrimParameters() 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 namespace code with leading and trailing empty spaces.
    UserNamespaceAuthorizations resultUserNamespaceAuthorizations = userNamespaceAuthorizationService.getUserNamespaceAuthorizationsByNamespace(addWhitespace(key.getNamespace()));
    // 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 7 with UserNamespaceAuthorizationEntity

use of org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity in project herd by FINRAOS.

the class UserNamespaceAuthorizationServiceTest method testUpdateUserNamespaceAuthorizationLowerCaseParameters.

@Test
public void testUpdateUserNamespaceAuthorizationLowerCaseParameters() {
    // 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, Arrays.asList(NamespacePermissionEnum.READ, NamespacePermissionEnum.WRITE));
    // Update a user namespace authorization using lowercase input parameters.
    UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationService.updateUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(key.getUserId().toLowerCase(), key.getNamespace().toLowerCase()), new UserNamespaceAuthorizationUpdateRequest(SUPPORTED_NAMESPACE_PERMISSIONS));
    // 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) UserNamespaceAuthorizationUpdateRequest(org.finra.herd.model.api.xml.UserNamespaceAuthorizationUpdateRequest) UserNamespaceAuthorization(org.finra.herd.model.api.xml.UserNamespaceAuthorization) Test(org.junit.Test)

Example 8 with UserNamespaceAuthorizationEntity

use of org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity in project herd by FINRAOS.

the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorizationTrimParameters.

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

Example 9 with UserNamespaceAuthorizationEntity

use of org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity 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 10 with UserNamespaceAuthorizationEntity

use of org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity 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)

Aggregations

UserNamespaceAuthorizationEntity (org.finra.herd.model.jpa.UserNamespaceAuthorizationEntity)38 Test (org.junit.Test)25 UserNamespaceAuthorizationKey (org.finra.herd.model.api.xml.UserNamespaceAuthorizationKey)22 UserNamespaceAuthorization (org.finra.herd.model.api.xml.UserNamespaceAuthorization)18 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)12 UserNamespaceAuthorizations (org.finra.herd.model.api.xml.UserNamespaceAuthorizations)8 ArrayList (java.util.ArrayList)7 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)5 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)4 Predicate (javax.persistence.criteria.Predicate)4 UserNamespaceAuthorizationUpdateRequest (org.finra.herd.model.api.xml.UserNamespaceAuthorizationUpdateRequest)4 NamespaceAuthorization (org.finra.herd.model.api.xml.NamespaceAuthorization)3 ApplicationUser (org.finra.herd.model.dto.ApplicationUser)3 Order (javax.persistence.criteria.Order)2 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)1