use of org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationCreateRequest 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);
}
use of org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationCreateRequest in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceTest method createNamespaceIamRoleAuthorizationAssertErrorWhenNamespaceIsBlank.
@Test
public void createNamespaceIamRoleAuthorizationAssertErrorWhenNamespaceIsBlank() {
IamRole expectedIamRole1 = new IamRole("iamRoleName1", "iamRoleDescription1");
IamRole expectedIamRole2 = new IamRole("iamRoleName2", " ");
List<IamRole> expectedIamRoles = Arrays.asList(expectedIamRole1, expectedIamRole2);
NamespaceIamRoleAuthorizationCreateRequest expectedRequest = new NamespaceIamRoleAuthorizationCreateRequest(" ", expectedIamRoles);
try {
namespaceIamRoleAuthorizationServiceImpl.createNamespaceIamRoleAuthorization(expectedRequest);
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.NamespaceIamRoleAuthorizationCreateRequest in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceTest method createNamespaceIamRoleAuthorizationAssertErrorWhenRoleNameIsBlank.
@Test
public void createNamespaceIamRoleAuthorizationAssertErrorWhenRoleNameIsBlank() {
IamRole expectedIamRole1 = new IamRole("iamRoleName1", "iamRoleDescription1");
IamRole expectedIamRole2 = new IamRole(" ", "iamRoleDescription2");
List<IamRole> expectedIamRoles = Arrays.asList(expectedIamRole1, expectedIamRole2);
NamespaceIamRoleAuthorizationCreateRequest expectedRequest = new NamespaceIamRoleAuthorizationCreateRequest("namespace", expectedIamRoles);
try {
namespaceIamRoleAuthorizationServiceImpl.createNamespaceIamRoleAuthorization(expectedRequest);
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.NamespaceIamRoleAuthorizationCreateRequest in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceTest method createNamespaceIamRoleAuthorizationAssertErrorWhenIamRolesEmpty.
@Test
public void createNamespaceIamRoleAuthorizationAssertErrorWhenIamRolesEmpty() {
List<IamRole> expectedIamRoles = Arrays.asList();
NamespaceIamRoleAuthorizationCreateRequest expectedRequest = new NamespaceIamRoleAuthorizationCreateRequest("namespace", expectedIamRoles);
try {
namespaceIamRoleAuthorizationServiceImpl.createNamespaceIamRoleAuthorization(expectedRequest);
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.NamespaceIamRoleAuthorizationCreateRequest in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceTest method createNamespaceIamRoleAuthorizationAssertErrorWhenAuthorizationAlreadyExist.
@Test
public void createNamespaceIamRoleAuthorizationAssertErrorWhenAuthorizationAlreadyExist() {
IamRole expectedIamRole1 = new IamRole("iamRoleName1", "iamRoleDescription1");
IamRole expectedIamRole2 = new IamRole("iamRoleName2", "iamRoleDescription2");
List<IamRole> expectedIamRoles = Arrays.asList(expectedIamRole1, expectedIamRole2);
NamespaceIamRoleAuthorizationCreateRequest expectedRequest = new NamespaceIamRoleAuthorizationCreateRequest("namespace", expectedIamRoles);
NamespaceEntity expectedNamespaceEntity = new NamespaceEntity();
expectedNamespaceEntity.setCode("NAMESPACE");
when(namespaceDaoHelper.getNamespaceEntity(any())).thenReturn(expectedNamespaceEntity);
when(namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(any())).thenReturn(Arrays.asList(new NamespaceIamRoleAuthorizationEntity()));
try {
namespaceIamRoleAuthorizationServiceImpl.createNamespaceIamRoleAuthorization(expectedRequest);
fail();
} catch (Exception e) {
assertEquals(AlreadyExistsException.class, e.getClass());
assertEquals(String.format("Namespace IAM role authorizations with namespace \"%s\" already exist", expectedNamespaceEntity.getCode()), e.getMessage());
}
verify(namespaceDaoHelper).getNamespaceEntity(expectedRequest.getNamespace());
verify(namespaceIamRoleAuthorizationDao).getNamespaceIamRoleAuthorizations(expectedNamespaceEntity);
verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
Aggregations