use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleCatalogueServiceIntegrationTest method testReferentialIntegrity.
@Test
public void testReferentialIntegrity() {
// catalogue
IdmRoleCatalogueDto roleCatalogue = new IdmRoleCatalogueDto();
String catalogueName = "cat_one_" + System.currentTimeMillis();
roleCatalogue.setCode(catalogueName);
roleCatalogue.setName(catalogueName);
roleCatalogue = roleCatalogueService.save(roleCatalogue);
// role
IdmRoleDto role = new IdmRoleDto();
String roleName = "test_r_" + System.currentTimeMillis();
role.setName(roleName);
//
IdmRoleCatalogueRoleDto roleCatalogueRole = new IdmRoleCatalogueRoleDto();
roleCatalogueRole.setRole(role.getId());
roleCatalogueRole.setRoleCatalogue(roleCatalogue.getId());
//
role.setRoleCatalogues(Lists.newArrayList(roleCatalogueRole));
role = roleService.save(role);
//
List<IdmRoleCatalogueRoleDto> list = role.getRoleCatalogues();
assertEquals(1, list.size());
UUID catalogId = list.get(0).getRoleCatalogue();
UUID roleId = list.get(0).getRole();
//
assertNotNull(catalogId);
assertNotNull(roleId);
assertEquals(roleCatalogue.getId(), catalogId);
assertEquals(role.getId(), roleId);
//
roleCatalogueService.delete(roleCatalogue);
//
List<IdmRoleCatalogueDto> roleCatalogues = roleCatalogueService.findAllByRole(role.getId());
assertEquals(0, roleCatalogues.size());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleServiceIntegrationTest method catalogueFilterTest.
@Test
public void catalogueFilterTest() {
IdmRoleDto role = new IdmRoleDto();
role.setName("PetrSadloRole");
role = roleService.save(role);
IdmRoleCatalogueDto catalogue = helper.createRoleCatalogue();
IdmRoleCatalogueRoleDto catalogueRole = new IdmRoleCatalogueRoleDto();
catalogueRole.setRole(role.getId());
catalogueRole.setRoleCatalogue(catalogue.getId());
catalogueRole = idmRoleCatalogueRoleService.save(catalogueRole);
IdmRoleFilter filter = new IdmRoleFilter();
filter.setRoleCatalogueId(catalogue.getId());
Page<IdmRoleDto> result = roleService.find(filter, null);
assertEquals("Wrong catalogue", 1, result.getTotalElements());
assertTrue("Wrong catalogue id #1", result.getContent().contains(role));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultIdentityRoleServiceTest method roleCatalogueTest.
@Test
public void roleCatalogueTest() {
IdmIdentityDto person = testHelper.createIdentity();
IdmIdentityDto person2 = testHelper.createIdentity();
IdmRoleCatalogueDto catalogue = testHelper.createRoleCatalogue();
IdmRoleCatalogueRoleDto catalogueRole = new IdmRoleCatalogueRoleDto();
IdmRoleCatalogueRoleDto catalogueRole2 = new IdmRoleCatalogueRoleDto();
IdmIdentityContractDto contract = testHelper.createIdentityContact(person);
IdmIdentityContractDto contract2 = testHelper.createIdentityContact(person2);
IdmRoleDto role = testHelper.createRole();
IdmRoleDto role2 = testHelper.createRole();
catalogueRole.setRoleCatalogue(catalogue.getId());
catalogueRole.setRole(role.getId());
catalogueRole2.setRoleCatalogue(catalogue.getId());
catalogueRole2.setRole(role2.getId());
IdmIdentityRoleDto roleCover = testHelper.createIdentityRole(contract, role);
IdmIdentityRoleDto roleCover2 = testHelper.createIdentityRole(contract2, role2);
idmRoleCatalogueRoleService.save(catalogueRole);
idmRoleCatalogueRoleService.save(catalogueRole2);
IdmIdentityRoleFilter filter = new IdmIdentityRoleFilter();
filter.setRoleCatalogueId(catalogue.getId());
Page<IdmIdentityRoleDto> result = idmIdentityRoleService.find(filter, null);
assertEquals("Wrong CatalogueRoleId", roleCover.getId(), result.getContent().get(0).getId());
assertEquals("Wrong CatalogueRoleId2", roleCover2.getId(), result.getContent().get(1).getId());
}
Aggregations