Search in sources :

Example 21 with UserNamespaceAuthorizationEntity

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

the class UserNamespaceAuthorizationServiceTest method testUpdateUserNamespaceAuthorizationUpperCaseParameters.

@Test
public void testUpdateUserNamespaceAuthorizationUpperCaseParameters() {
    // 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 uppercase input parameters.
    UserNamespaceAuthorization resultUserNamespaceAuthorization = userNamespaceAuthorizationService.updateUserNamespaceAuthorization(new UserNamespaceAuthorizationKey(key.getUserId().toUpperCase(), key.getNamespace().toUpperCase()), 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 22 with UserNamespaceAuthorizationEntity

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

the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorizationsByUserIdUpperCaseParameters.

@Test
public void testGetUserNamespaceAuthorizationsByUserIdUpperCaseParameters() 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 uppercase user id value.
    UserNamespaceAuthorizations resultUserNamespaceAuthorizations = userNamespaceAuthorizationService.getUserNamespaceAuthorizationsByUserId(key.getUserId().toUpperCase());
    // 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 23 with UserNamespaceAuthorizationEntity

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

the class UserNamespaceAuthorizationServiceTest method testGetUserNamespaceAuthorizationsByNamespaceUpperCaseParameters.

@Test
public void testGetUserNamespaceAuthorizationsByNamespaceUpperCaseParameters() 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 uppercase namespace code.
    UserNamespaceAuthorizations resultUserNamespaceAuthorizations = userNamespaceAuthorizationService.getUserNamespaceAuthorizationsByNamespace(key.getNamespace().toUpperCase());
    // 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 UserNamespaceAuthorizationEntity

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

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

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