Search in sources :

Example 11 with IdmRoleCatalogueDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto 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());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCatalogueRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) UUID(java.util.UUID) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 12 with IdmRoleCatalogueDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto 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));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCatalogueRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 13 with IdmRoleCatalogueDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto in project CzechIdMng by bcvsolutions.

the class DefaultTestHelper method createRoleCatalogue.

@Override
public IdmRoleCatalogueDto createRoleCatalogue(String code) {
    IdmRoleCatalogueDto roleCatalogue = new IdmRoleCatalogueDto();
    code = code == null ? createName() : code;
    roleCatalogue.setName(code);
    roleCatalogue.setCode(code);
    return idmRoleCatalogueService.save(roleCatalogue);
}
Also used : IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto)

Example 14 with IdmRoleCatalogueDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto 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());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCatalogueRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 15 with IdmRoleCatalogueDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto in project CzechIdMng by bcvsolutions.

the class DefaultRoleCatalogueProvisioningTest method provisioningE_DeleteAccount_IntegrityException.

@Test(expected = ResultCodeException.class)
public void provisioningE_DeleteAccount_IntegrityException() {
    IdmRoleCatalogueFilter filter = new IdmRoleCatalogueFilter();
    filter.setName("P1");
    IdmRoleCatalogueDto nodeRoot = treeNodeService.find(filter, null).getContent().get(0);
    Assert.assertNotNull(nodeRoot);
    // Delete IDM node (must invoke provisioning) .. We delete node with some children ... must throw integrity exception
    // Generally we counts with provisioning on every node ... include children (Recursively delete is not good idea!)
    treeNodeService.delete(nodeRoot);
}
Also used : IdmRoleCatalogueFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCatalogueFilter) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmRoleCatalogueDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto)19 Test (org.junit.Test)16 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)14 IdmRoleCatalogueFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCatalogueFilter)9 TestTreeResource (eu.bcvsolutions.idm.acc.entity.TestTreeResource)4 IdmRoleCatalogueRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto)3 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)3 AbstractRestTest (eu.bcvsolutions.idm.test.api.AbstractRestTest)2 LinkedHashMap (java.util.LinkedHashMap)2 UUID (java.util.UUID)2 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)1 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)1 IdmIdentityRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter)1 IdmRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1 Transactional (org.springframework.transaction.annotation.Transactional)1