use of org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizations in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceTest method getNamespaceIamRoleAuthorizationsAssertResultEmptyWhenDaoReturnsEmpty.
@Test
public void getNamespaceIamRoleAuthorizationsAssertResultEmptyWhenDaoReturnsEmpty() {
when(namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(any())).thenReturn(Collections.emptyList());
NamespaceIamRoleAuthorizations result = namespaceIamRoleAuthorizationServiceImpl.getNamespaceIamRoleAuthorizations();
assertNotNull(result);
assertNotNull(result.getNamespaceIamRoleAuthorizations());
assertEquals(0, result.getNamespaceIamRoleAuthorizations().size());
verify(namespaceIamRoleAuthorizationDao).getNamespaceIamRoleAuthorizations(null);
verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
use of org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizations in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationRestControllerTest method getNamespaceIamRoleAuthorizationsAssertCallsService.
/**
* Asserts that getNamespaceIamRoleAuthorizations() calls service with correct parameters, and returns whatever the service returns.
*/
@Test
public void getNamespaceIamRoleAuthorizationsAssertCallsService() {
NamespaceIamRoleAuthorizations expectedResult = new NamespaceIamRoleAuthorizations();
when(namespaceIamRoleAuthorizationService.getNamespaceIamRoleAuthorizations()).thenReturn(expectedResult);
NamespaceIamRoleAuthorizations actualResult = namespaceIamRoleAuthorizationRestController.getNamespaceIamRoleAuthorizations();
verify(namespaceIamRoleAuthorizationService).getNamespaceIamRoleAuthorizations();
verifyNoMoreInteractions(namespaceIamRoleAuthorizationService);
assertEquals(expectedResult, actualResult);
}
use of org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizations in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceTest method getNamespaceIamRoleAuthorizationsAssertCallsDependenciesAndResultExpected.
@Test
public void getNamespaceIamRoleAuthorizationsAssertCallsDependenciesAndResultExpected() {
NamespaceEntity namespaceEntity1 = new NamespaceEntity();
namespaceEntity1.setCode("namespace1");
NamespaceEntity namespaceEntity2 = new NamespaceEntity();
namespaceEntity2.setCode("namespace2");
List<NamespaceIamRoleAuthorizationEntity> expectedNamespaceIamRoleAuthorizationEntities = new ArrayList<>();
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity1 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity1.setNamespace(namespaceEntity1);
namespaceIamRoleAuthorizationEntity1.setIamRoleName("iamRoleName1");
namespaceIamRoleAuthorizationEntity1.setDescription("description1");
expectedNamespaceIamRoleAuthorizationEntities.add(namespaceIamRoleAuthorizationEntity1);
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity2 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity2.setNamespace(namespaceEntity1);
namespaceIamRoleAuthorizationEntity2.setIamRoleName("iamRoleName2");
namespaceIamRoleAuthorizationEntity2.setDescription("description2");
expectedNamespaceIamRoleAuthorizationEntities.add(namespaceIamRoleAuthorizationEntity2);
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity3 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity3.setNamespace(namespaceEntity2);
namespaceIamRoleAuthorizationEntity3.setIamRoleName("iamRoleName3");
namespaceIamRoleAuthorizationEntity3.setDescription("description3");
expectedNamespaceIamRoleAuthorizationEntities.add(namespaceIamRoleAuthorizationEntity3);
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity4 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity4.setNamespace(namespaceEntity2);
namespaceIamRoleAuthorizationEntity4.setIamRoleName("iamRoleName4");
namespaceIamRoleAuthorizationEntity4.setDescription("description4");
expectedNamespaceIamRoleAuthorizationEntities.add(namespaceIamRoleAuthorizationEntity4);
when(namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(any())).thenReturn(expectedNamespaceIamRoleAuthorizationEntities);
NamespaceIamRoleAuthorizations result = namespaceIamRoleAuthorizationServiceImpl.getNamespaceIamRoleAuthorizations();
assertNotNull(result);
assertNotNull(result.getNamespaceIamRoleAuthorizations());
assertEquals(2, result.getNamespaceIamRoleAuthorizations().size());
{
NamespaceIamRoleAuthorization namespaceIamRoleAuthorization = result.getNamespaceIamRoleAuthorizations().get(0);
assertNotNull(namespaceIamRoleAuthorization);
assertEquals(namespaceEntity1.getCode(), namespaceIamRoleAuthorization.getNamespace());
assertNotNull(namespaceIamRoleAuthorization.getIamRoles());
assertEquals(2, namespaceIamRoleAuthorization.getIamRoles().size());
{
IamRole iamRole = namespaceIamRoleAuthorization.getIamRoles().get(0);
assertNotNull(iamRole);
assertEquals(namespaceIamRoleAuthorizationEntity1.getIamRoleName(), iamRole.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity1.getDescription(), iamRole.getIamRoleDescription());
}
{
IamRole iamRole = namespaceIamRoleAuthorization.getIamRoles().get(1);
assertNotNull(iamRole);
assertEquals(namespaceIamRoleAuthorizationEntity2.getIamRoleName(), iamRole.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity2.getDescription(), iamRole.getIamRoleDescription());
}
}
{
NamespaceIamRoleAuthorization namespaceIamRoleAuthorization = result.getNamespaceIamRoleAuthorizations().get(1);
assertNotNull(namespaceIamRoleAuthorization);
assertEquals(namespaceEntity2.getCode(), namespaceIamRoleAuthorization.getNamespace());
assertNotNull(namespaceIamRoleAuthorization.getIamRoles());
assertEquals(2, namespaceIamRoleAuthorization.getIamRoles().size());
{
IamRole iamRole = namespaceIamRoleAuthorization.getIamRoles().get(0);
assertNotNull(iamRole);
assertEquals(namespaceIamRoleAuthorizationEntity3.getIamRoleName(), iamRole.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity3.getDescription(), iamRole.getIamRoleDescription());
}
{
IamRole iamRole = namespaceIamRoleAuthorization.getIamRoles().get(1);
assertNotNull(iamRole);
assertEquals(namespaceIamRoleAuthorizationEntity4.getIamRoleName(), iamRole.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity4.getDescription(), iamRole.getIamRoleDescription());
}
}
verify(namespaceIamRoleAuthorizationDao).getNamespaceIamRoleAuthorizations(null);
verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
use of org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizations in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceImpl method getNamespaceIamRoleAuthorizations.
@Override
public NamespaceIamRoleAuthorizations getNamespaceIamRoleAuthorizations() {
List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizationEntities = namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(null);
Map<String, NamespaceIamRoleAuthorization> map = new LinkedHashMap<>();
for (NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity : namespaceIamRoleAuthorizationEntities) {
String namespace = namespaceIamRoleAuthorizationEntity.getNamespace().getCode();
NamespaceIamRoleAuthorization namespaceIamRoleAuthorization = map.get(namespace);
if (namespaceIamRoleAuthorization == null) {
map.put(namespace, namespaceIamRoleAuthorization = new NamespaceIamRoleAuthorization(namespace, new ArrayList<>()));
}
namespaceIamRoleAuthorization.getIamRoles().add(new IamRole(namespaceIamRoleAuthorizationEntity.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getDescription()));
}
return new NamespaceIamRoleAuthorizations(new ArrayList<>(map.values()));
}
Aggregations