use of org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationUpdateRequest in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceTest method updateNamespaceIamRoleAuthorizationAssertCallsDependenciesAndResultExpected.
@Test
public void updateNamespaceIamRoleAuthorizationAssertCallsDependenciesAndResultExpected() {
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);
List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizationEntities = new ArrayList<>();
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntities.add(namespaceIamRoleAuthorizationEntity);
when(namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(any())).thenReturn(namespaceIamRoleAuthorizationEntities);
NamespaceIamRoleAuthorization result = namespaceIamRoleAuthorizationServiceImpl.updateNamespaceIamRoleAuthorization(expectedNamespace, expectedNamespaceIamRoleAuthorizationUpdateRequest);
assertNotNull(result);
assertEquals(expectedNamespaceEntity.getCode(), result.getNamespace());
assertNotNull(result.getIamRoles());
assertEquals(2, result.getIamRoles().size());
{
IamRole iamRole = result.getIamRoles().get(0);
assertNotNull(iamRole);
assertEquals(iamRole1.getIamRoleName(), iamRole.getIamRoleName());
assertEquals(iamRole1.getIamRoleDescription(), iamRole.getIamRoleDescription());
}
{
IamRole iamRole = result.getIamRoles().get(1);
assertNotNull(iamRole);
assertEquals(iamRole2.getIamRoleName(), iamRole.getIamRoleName());
assertEquals(null, iamRole.getIamRoleDescription());
}
verify(namespaceDaoHelper).getNamespaceEntity(expectedNamespace);
verify(namespaceIamRoleAuthorizationDao).getNamespaceIamRoleAuthorizations(expectedNamespaceEntity);
verify(namespaceIamRoleAuthorizationDao).delete(namespaceIamRoleAuthorizationEntity);
verify(namespaceIamRoleAuthorizationDao).saveAndRefresh(namespaceIamRoleAuthorizationEntityEq(expectedNamespaceEntity.getCode(), iamRole1.getIamRoleName(), iamRole1.getIamRoleDescription()));
verify(namespaceIamRoleAuthorizationDao).saveAndRefresh(namespaceIamRoleAuthorizationEntityEq(expectedNamespaceEntity.getCode(), iamRole2.getIamRoleName(), null));
verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
use of org.finra.herd.model.api.xml.NamespaceIamRoleAuthorizationUpdateRequest in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationServiceTest method updateNamespaceIamRoleAuthorizationAssertInputsTrimmed.
@Test
public void updateNamespaceIamRoleAuthorizationAssertInputsTrimmed() {
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);
List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizationEntities = new ArrayList<>();
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntities.add(namespaceIamRoleAuthorizationEntity);
when(namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(any())).thenReturn(namespaceIamRoleAuthorizationEntities);
NamespaceIamRoleAuthorization result = namespaceIamRoleAuthorizationServiceImpl.updateNamespaceIamRoleAuthorization(expectedNamespace, expectedNamespaceIamRoleAuthorizationUpdateRequest);
assertNotNull(result);
assertEquals(expectedNamespaceEntity.getCode(), result.getNamespace());
assertNotNull(result.getIamRoles());
assertEquals(2, result.getIamRoles().size());
{
IamRole iamRole = result.getIamRoles().get(0);
assertNotNull(iamRole);
assertEquals(iamRole1.getIamRoleName().trim(), iamRole.getIamRoleName());
assertEquals(iamRole1.getIamRoleDescription().trim(), iamRole.getIamRoleDescription());
}
{
IamRole iamRole = result.getIamRoles().get(1);
assertNotNull(iamRole);
assertEquals(iamRole2.getIamRoleName().trim(), iamRole.getIamRoleName());
assertEquals(null, iamRole.getIamRoleDescription());
}
verify(namespaceDaoHelper).getNamespaceEntity(expectedNamespace.trim());
verify(namespaceIamRoleAuthorizationDao).getNamespaceIamRoleAuthorizations(expectedNamespaceEntity);
verify(namespaceIamRoleAuthorizationDao).delete(namespaceIamRoleAuthorizationEntity);
verify(namespaceIamRoleAuthorizationDao).saveAndRefresh(namespaceIamRoleAuthorizationEntityEq(expectedNamespaceEntity.getCode(), iamRole1.getIamRoleName().trim(), iamRole1.getIamRoleDescription().trim()));
verify(namespaceIamRoleAuthorizationDao).saveAndRefresh(namespaceIamRoleAuthorizationEntityEq(expectedNamespaceEntity.getCode(), iamRole2.getIamRoleName().trim(), null));
verifyNoMoreInteractions(namespaceDaoHelper, namespaceIamRoleAuthorizationDao);
}
Aggregations