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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations