Search in sources :

Example 1 with NamespaceIamRoleAuthorizations

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);
}
Also used : NamespaceIamRoleAuthorizations(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizations) Test(org.junit.Test)

Example 2 with NamespaceIamRoleAuthorizations

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);
}
Also used : NamespaceIamRoleAuthorizations(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizations) Test(org.junit.Test)

Example 3 with NamespaceIamRoleAuthorizations

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);
}
Also used : NamespaceEntity(org.finra.herd.model.jpa.NamespaceEntity) NamespaceIamRoleAuthorizations(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizations) NamespaceIamRoleAuthorization(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization) ArrayList(java.util.ArrayList) IamRole(org.finra.herd.model.api.xml.IamRole) NamespaceIamRoleAuthorizationEntity(org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity) Test(org.junit.Test)

Example 4 with NamespaceIamRoleAuthorizations

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()));
}
Also used : NamespaceIamRoleAuthorizations(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizations) NamespaceIamRoleAuthorization(org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization) IamRole(org.finra.herd.model.api.xml.IamRole) NamespaceIamRoleAuthorizationEntity(org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

NamespaceIamRoleAuthorizations (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizations)4 Test (org.junit.Test)3 IamRole (org.finra.herd.model.api.xml.IamRole)2 NamespaceIamRoleAuthorization (org.finra.herd.model.api.xml.NamespaceIamRoleAuthorization)2 NamespaceIamRoleAuthorizationEntity (org.finra.herd.model.jpa.NamespaceIamRoleAuthorizationEntity)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 NamespaceEntity (org.finra.herd.model.jpa.NamespaceEntity)1