use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter in project CzechIdMng by bcvsolutions.
the class RoleExportBulkActionIntegrationTest method findGuarantees.
private List<IdmRoleGuaranteeDto> findGuarantees(IdmRoleDto role) {
IdmRoleGuaranteeFilter filter = new IdmRoleGuaranteeFilter();
filter.setRole(role.getId());
return roleGuaranteeService.find(filter, null).getContent();
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleGuaranteeServiceIntegrationTest method testFindRoleGuaranteeByGuarantee.
@Test
public void testFindRoleGuaranteeByGuarantee() {
IdmIdentityDto guarantee = getHelper().createIdentity((GuardedString) null);
//
IdmRoleDto role1 = getHelper().createRole();
IdmRoleDto role2 = getHelper().createRole();
IdmRoleDto role3 = getHelper().createRole();
//
IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role1.getId());
roleGuarantee.setGuarantee(guarantee.getId());
roleGuaranteeService.save(roleGuarantee);
//
roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role2.getId());
roleGuarantee.setGuarantee(guarantee.getId());
roleGuaranteeService.save(roleGuarantee);
//
roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role3.getId());
roleGuarantee.setGuarantee(guarantee.getId());
roleGuaranteeService.save(roleGuarantee);
//
IdmRoleGuaranteeFilter filter = new IdmRoleGuaranteeFilter();
filter.setGuarantee(guarantee.getId());
List<IdmRoleGuaranteeDto> list = roleGuaranteeService.find(filter, null).getContent();
Assert.assertEquals(3, list.size());
//
List<UUID> roles = list.stream().map(IdmRoleGuaranteeDto::getRole).collect(Collectors.toList());
roleGuarantee = list.get(0);
Assert.assertEquals(guarantee.getId(), roleGuarantee.getGuarantee());
Assert.assertTrue(roles.contains(role1.getId()));
Assert.assertTrue(roles.contains(role2.getId()));
Assert.assertTrue(roles.contains(role3.getId()));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleGuaranteeServiceIntegrationTest method testFindRoleGuaranteeByGuaranteeAndType.
@Test
public void testFindRoleGuaranteeByGuaranteeAndType() {
IdmRoleDto role1 = getHelper().createRole();
IdmRoleDto role2 = getHelper().createRole();
//
IdmIdentityDto guarantee = getHelper().createIdentity((GuardedString) null);
String guarranteeType = getHelper().createName();
getHelper().createRoleGuarantee(role1, guarantee, guarranteeType);
getHelper().createRoleGuarantee(role2, guarantee, null);
//
IdmRoleGuaranteeFilter filter = new IdmRoleGuaranteeFilter();
filter.setGuarantee(guarantee.getId());
filter.setType(guarranteeType);
List<IdmRoleGuaranteeDto> list = roleGuaranteeService.find(filter, null).getContent();
Assert.assertEquals(1, list.size());
//
IdmRoleGuaranteeDto roleGuaranteeFirst = list.get(0);
Assert.assertEquals(guarantee.getId(), roleGuaranteeFirst.getGuarantee());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleGuaranteeServiceIntegrationTest method testFindRoleGuaranteeByRole.
@Test
public void testFindRoleGuaranteeByRole() {
IdmIdentityDto guarantee1 = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto guarantee2 = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto guarantee3 = getHelper().createIdentity((GuardedString) null);
//
IdmRoleDto role = getHelper().createRole();
//
IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role.getId());
roleGuarantee.setGuarantee(guarantee1.getId());
roleGuaranteeService.save(roleGuarantee);
//
roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role.getId());
roleGuarantee.setGuarantee(guarantee2.getId());
roleGuaranteeService.save(roleGuarantee);
//
roleGuarantee = new IdmRoleGuaranteeDto();
roleGuarantee.setRole(role.getId());
roleGuarantee.setGuarantee(guarantee3.getId());
roleGuaranteeService.save(roleGuarantee);
//
IdmRoleGuaranteeFilter filter = new IdmRoleGuaranteeFilter();
filter.setRole(role.getId());
List<IdmRoleGuaranteeDto> list = roleGuaranteeService.find(filter, null).getContent();
Assert.assertEquals(3, list.size());
//
List<UUID> guarantees = list.stream().map(IdmRoleGuaranteeDto::getGuarantee).collect(Collectors.toList());
roleGuarantee = list.get(0);
Assert.assertEquals(role.getId(), roleGuarantee.getRole());
Assert.assertTrue(guarantees.contains(guarantee3.getId()));
Assert.assertTrue(guarantees.contains(guarantee2.getId()));
Assert.assertTrue(guarantees.contains(guarantee1.getId()));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleServiceIntegrationTest method testReferentialIntegrity.
@Test
public void testReferentialIntegrity() {
IdmIdentityDto identity = getHelper().createIdentity(new GuardedString("heslo"));
// role
IdmRoleDto role = getHelper().createRole();
getHelper().createRoleGuarantee(role, identity);
//
// guarantee by role
IdmRoleGuaranteeRoleDto roleGuaranteeOne = new IdmRoleGuaranteeRoleDto();
roleGuaranteeOne.setRole(role.getId());
roleGuaranteeOne.setGuaranteeRole(getHelper().createRole().getId());
roleGuaranteeRoleService.save(roleGuaranteeOne);
IdmRoleGuaranteeRoleDto roleGuaranteeTwo = new IdmRoleGuaranteeRoleDto();
roleGuaranteeTwo.setRole(getHelper().createRole().getId());
roleGuaranteeTwo.setGuaranteeRole(role.getId());
roleGuaranteeRoleService.save(roleGuaranteeTwo);
//
// after save
IdmRoleGuaranteeFilter guaranteeFilter = new IdmRoleGuaranteeFilter();
guaranteeFilter.setRole(role.getId());
IdmRoleGuaranteeRoleFilter guaranteeRoleFilter = new IdmRoleGuaranteeRoleFilter();
guaranteeRoleFilter.setRole(role.getId());
IdmRoleGuaranteeRoleFilter guaranteeRoleRoleFilter = new IdmRoleGuaranteeRoleFilter();
guaranteeRoleRoleFilter.setGuaranteeRole(role.getId());
//
Assert.assertNotNull(roleService.getByCode(role.getCode()));
Assert.assertEquals(1, roleGuaranteeService.find(guaranteeFilter, null).getTotalElements());
Assert.assertEquals(1, roleGuaranteeRoleService.find(guaranteeRoleFilter, null).getTotalElements());
Assert.assertEquals(1, roleGuaranteeRoleService.find(guaranteeRoleFilter, null).getTotalElements());
roleService.delete(role);
//
// after delete
Assert.assertNull(roleService.getByCode(role.getCode()));
Assert.assertEquals(0, roleGuaranteeService.find(guaranteeFilter, null).getTotalElements());
Assert.assertEquals(0, roleGuaranteeRoleService.find(guaranteeRoleFilter, null).getTotalElements());
Assert.assertEquals(0, roleGuaranteeRoleService.find(guaranteeRoleFilter, null).getTotalElements());
}
Aggregations