Search in sources :

Example 1 with NamespaceIamRoleAuthorizationUpdateRequest

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

the class NamespaceIamRoleAuthorizationServiceTest method updateNamespaceIamRoleAuthorizationAssertErrorWhenNamespaceIsBlank.

@Test
public void updateNamespaceIamRoleAuthorizationAssertErrorWhenNamespaceIsBlank() {
    String expectedNamespace = " ";
    List<IamRole> iamRoles = new ArrayList<>();
    IamRole iamRole1 = new IamRole("iamRoleName1", "iamRoleDescription1");
    iamRoles.add(iamRole1);
    IamRole iamRole2 = new IamRole("iamRoleName2", " ");
    iamRoles.add(iamRole2);
    NamespaceIamRoleAuthorizationUpdateRequest expectedNamespaceIamRoleAuthorizationUpdateRequest = new NamespaceIamRoleAuthorizationUpdateRequest(iamRoles);
    try {
        namespaceIamRoleAuthorizationServiceImpl.updateNamespaceIamRoleAuthorization(expectedNamespace, expectedNamespaceIamRoleAuthorizationUpdateRequest);
        fail();
    } catch (Exception e) {
        assertEquals(IllegalArgumentException.class, e.getClass());
        assertEquals("Namespace must be specified", e.getMessage());
    }
    verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
Also used : IamRole(org.finra.herd.model.api.xml.IamRole) ArrayList(java.util.ArrayList) NamespaceIamRoleAuthorizationUpdateRequest(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationUpdateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) Test(org.junit.Test)

Example 2 with NamespaceIamRoleAuthorizationUpdateRequest

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

the class NamespaceIamRoleAuthorizationServiceTest method updateNamespaceIamRoleAuthorizationAssertErrorWhenIamRolesEmpty.

@Test
public void updateNamespaceIamRoleAuthorizationAssertErrorWhenIamRolesEmpty() {
    String expectedNamespace = "namespace";
    NamespaceIamRoleAuthorizationUpdateRequest expectedNamespaceIamRoleAuthorizationUpdateRequest = new NamespaceIamRoleAuthorizationUpdateRequest(Collections.emptyList());
    try {
        namespaceIamRoleAuthorizationServiceImpl.updateNamespaceIamRoleAuthorization(expectedNamespace, expectedNamespaceIamRoleAuthorizationUpdateRequest);
        fail();
    } catch (Exception e) {
        assertEquals(IllegalArgumentException.class, e.getClass());
        assertEquals("At least 1 IAM roles must be specified", e.getMessage());
    }
    verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
Also used : NamespaceIamRoleAuthorizationUpdateRequest(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationUpdateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) Test(org.junit.Test)

Example 3 with NamespaceIamRoleAuthorizationUpdateRequest

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

the class NamespaceIamRoleAuthorizationServiceTest method updateNamespaceIamRoleAuthorizationAssertErrorWhenDaoReturnsEmpty.

@Test
public void updateNamespaceIamRoleAuthorizationAssertErrorWhenDaoReturnsEmpty() {
    String expectedNamespace = "namespace";
    List<IamRole> iamRoles = new ArrayList<>();
    IamRole iamRole1 = new IamRole("iamRoleName1", "iamRoleDescription1");
    iamRoles.add(iamRole1);
    IamRole iamRole2 = new IamRole("iamRoleName2", " ");
    iamRoles.add(iamRole2);
    NamespaceIamRoleAuthorizationUpdateRequest expectedNamespaceIamRoleAuthorizationUpdateRequest = new NamespaceIamRoleAuthorizationUpdateRequest(iamRoles);
    NamespaceEntity expectedNamespaceEntity = new NamespaceEntity();
    expectedNamespaceEntity.setCode("NAMESPACE");
    when(namespaceDaoHelper.getNamespaceEntity(any())).thenReturn(expectedNamespaceEntity);
    when(namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(any())).thenReturn(Collections.emptyList());
    try {
        namespaceIamRoleAuthorizationServiceImpl.updateNamespaceIamRoleAuthorization(expectedNamespace, expectedNamespaceIamRoleAuthorizationUpdateRequest);
        fail();
    } catch (Exception e) {
        assertEquals(ObjectNotFoundException.class, e.getClass());
        assertEquals(String.format("Namespace IAM role authorizations for namespace \"%s\" do not exist", expectedNamespaceEntity.getCode()), e.getMessage());
    }
    verify(namespaceDaoHelper).getNamespaceEntity(expectedNamespace);
    verify(namespaceIamRoleAuthorizationDao).getNamespaceIamRoleAuthorizations(expectedNamespaceEntity);
    verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) IamRole(org.finra.herd.model.api.xml.IamRole) ArrayList(java.util.ArrayList) NamespaceIamRoleAuthorizationUpdateRequest(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationUpdateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) Test(org.junit.Test)

Example 4 with NamespaceIamRoleAuthorizationUpdateRequest

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

the class NamespaceIamRoleAuthorizationServiceTest method updateNamespaceIamRoleAuthorizationAssertErrorWhenRoleNameIsBlank.

@Test
public void updateNamespaceIamRoleAuthorizationAssertErrorWhenRoleNameIsBlank() {
    String expectedNamespace = "namespace";
    List<IamRole> iamRoles = new ArrayList<>();
    IamRole iamRole1 = new IamRole(" ", "iamRoleDescription1");
    iamRoles.add(iamRole1);
    IamRole iamRole2 = new IamRole(" ", " ");
    iamRoles.add(iamRole2);
    NamespaceIamRoleAuthorizationUpdateRequest expectedNamespaceIamRoleAuthorizationUpdateRequest = new NamespaceIamRoleAuthorizationUpdateRequest(iamRoles);
    try {
        namespaceIamRoleAuthorizationServiceImpl.updateNamespaceIamRoleAuthorization(expectedNamespace, expectedNamespaceIamRoleAuthorizationUpdateRequest);
        fail();
    } catch (Exception e) {
        assertEquals(IllegalArgumentException.class, e.getClass());
        assertEquals("IAM role name must be specified", e.getMessage());
    }
    verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
Also used : IamRole(org.finra.herd.model.api.xml.IamRole) ArrayList(java.util.ArrayList) NamespaceIamRoleAuthorizationUpdateRequest(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationUpdateRequest) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) Test(org.junit.Test)

Example 5 with NamespaceIamRoleAuthorizationUpdateRequest

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

the class NamespaceIamRoleAuthorizationRestControllerTest method updateNamespaceIamRoleAuthorizationAssertCallsService.

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

Aggregations

NamespaceIamRoleAuthorizationUpdateRequest (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationUpdateRequest)7 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)5 IamRole (org.finra.herd.model.api.xml.IamRole)5 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)4 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)4 NamespaceIamRoleAuthorization (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization)3 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)3 NamespaceIamRoleAuthorizationEntity (org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity)2