Search in sources :

Example 1 with NamespaceIamRoleAuthorization

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

the class NamespaceIamRoleAuthorizationServiceImpl method deleteNamespaceIamRoleAuthorization.

@NamespacePermission(fields = "#namespace", permissions = NamespacePermissionEnum.GRANT)
@Override
public NamespaceIamRoleAuthorization deleteNamespaceIamRoleAuthorization(String namespace) {
    Assert.hasText(namespace, "Namespace must be specified");
    NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(namespace.trim());
    List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizationEntities = getNamespaeIamRoleAuthorizationEntities(namespaceEntity);
    NamespaceIamRoleAuthorization result = new NamespaceIamRoleAuthorization(namespaceEntity.getCode(), new ArrayList<>());
    for (NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity : namespaceIamRoleAuthorizationEntities) {
        namespaceIamRoleAuthorizationDao.delete(namespaceIamRoleAuthorizationEntity);
        result.getIamRoles().add(new IamRole(namespaceIamRoleAuthorizationEntity.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getDescription()));
    }
    return result;
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) NamespaceIamRoleAuthorization(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization) IamRole(org.finra.herd.model.api.xml.IamRole) NamespaceIamRoleAuthorizationEntity(org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 2 with NamespaceIamRoleAuthorization

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

the class NamespaceIamRoleAuthorizationServiceImpl method getNamespaceIamRoleAuthorization.

@NamespacePermission(fields = "#namespace", permissions = NamespacePermissionEnum.READ)
@Override
public NamespaceIamRoleAuthorization getNamespaceIamRoleAuthorization(String namespace) {
    Assert.hasText(namespace, "Namespace must be specified");
    NamespaceEntity namespaceEntity = namespaceDaoHelper.getNamespaceEntity(namespace.trim());
    List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizationEntities = getNamespaeIamRoleAuthorizationEntities(namespaceEntity);
    NamespaceIamRoleAuthorization result = new NamespaceIamRoleAuthorization(namespaceEntity.getCode(), new ArrayList<>());
    for (NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity : namespaceIamRoleAuthorizationEntities) {
        result.getIamRoles().add(new IamRole(namespaceIamRoleAuthorizationEntity.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getDescription()));
    }
    return result;
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) NamespaceIamRoleAuthorization(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization) IamRole(org.finra.herd.model.api.xml.IamRole) NamespaceIamRoleAuthorizationEntity(org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity) NamespacePermission(org.finra.herd.model.annotation.NamespacePermission)

Example 3 with NamespaceIamRoleAuthorization

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

the class NamespaceIamRoleAuthorizationRestControllerTest method deleteNamespaceIamRoleAuthorizationAssertCallsService.

/**
 * Asserts that deleteNamespaceIamRoleAuthorization() calls service with correct parameters, and returns whatever the service returns.
 */
@Test
public void deleteNamespaceIamRoleAuthorizationAssertCallsService() {
    String expectedNamespace = "namespace";
    NamespaceIamRoleAuthorization expectedResult = new NamespaceIamRoleAuthorization();
    when(namespaceIamRoleAuthorizationService.deleteNamespaceIamRoleAuthorization(any())).thenReturn(expectedResult);
    NamespaceIamRoleAuthorization actualResult = namespaceIamRoleAuthorizationRestController.deleteNamespaceIamRoleAuthorization(expectedNamespace);
    verify(namespaceIamRoleAuthorizationService).deleteNamespaceIamRoleAuthorization(expectedNamespace);
    verifyNoMoreInteractions(namespaceIamRoleAuthorizationService);
    assertEquals(expectedResult, actualResult);
}
Also used : NamespaceIamRoleAuthorization(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization) Test(org.junit.Test)

Example 4 with NamespaceIamRoleAuthorization

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

the class NamespaceIamRoleAuthorizationRestControllerTest method createNamespaceIamRoleAuthorizationAssertCallsService.

/**
 * Asserts that createNamespaceIamRoleAuthorization() calls service with correct parameters, and returns whatever the service returns.
 */
@Test
public void createNamespaceIamRoleAuthorizationAssertCallsService() {
    NamespaceIamRoleAuthorizationCreateRequest expectedRequest = new NamespaceIamRoleAuthorizationCreateRequest();
    NamespaceIamRoleAuthorization expectedResult = new NamespaceIamRoleAuthorization();
    when(namespaceIamRoleAuthorizationService.createNamespaceIamRoleAuthorization(any())).thenReturn(expectedResult);
    NamespaceIamRoleAuthorization actualResult = namespaceIamRoleAuthorizationRestController.createNamespaceIamRoleAuthorization(expectedRequest);
    verify(namespaceIamRoleAuthorizationService).createNamespaceIamRoleAuthorization(expectedRequest);
    verifyNoMoreInteractions(namespaceIamRoleAuthorizationService);
    assertEquals(expectedResult, actualResult);
}
Also used : NamespaceIamRoleAuthorizationCreateRequest(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationCreateRequest) NamespaceIamRoleAuthorization(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization) Test(org.junit.Test)

Example 5 with NamespaceIamRoleAuthorization

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

the class NamespaceIamRoleAuthorizationRestControllerTest method getNamespaceIamRoleAuthorizationAssertCallsService.

/**
 * Asserts that getNamespaceIamRoleAuthorization() calls service with correct parameters, and returns whatever the service returns.
 */
@Test
public void getNamespaceIamRoleAuthorizationAssertCallsService() {
    String expectedNamespace = "namespace";
    NamespaceIamRoleAuthorization expectedResult = new NamespaceIamRoleAuthorization();
    when(namespaceIamRoleAuthorizationService.getNamespaceIamRoleAuthorization(any())).thenReturn(expectedResult);
    NamespaceIamRoleAuthorization actualResult = namespaceIamRoleAuthorizationRestController.getNamespaceIamRoleAuthorization(expectedNamespace);
    verify(namespaceIamRoleAuthorizationService).getNamespaceIamRoleAuthorization(expectedNamespace);
    verifyNoMoreInteractions(namespaceIamRoleAuthorizationService);
    assertEquals(expectedResult, actualResult);
}
Also used : NamespaceIamRoleAuthorization(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization) Test(org.junit.Test)

Aggregations

NamespaceIamRoleAuthorization (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization)18 IamRole (org.finra.herd.model.api.xml.IamRole)14 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)13 Test (org.junit.Test)13 NamespaceIamRoleAuthorizationEntity (org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity)12 ArrayList (java.util.ArrayList)7 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)4 NamespaceIamRoleAuthorizationCreateRequest (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationCreateRequest)3 NamespaceIamRoleAuthorizationUpdateRequest (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationUpdateRequest)3 NamespaceIamRoleAuthorizations (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizations)2 LinkedHashMap (java.util.LinkedHashMap)1