use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testFindAutomaticRoleWithoutRecursion.
@Test
public void testFindAutomaticRoleWithoutRecursion() {
// prepare
automaticRoleA = new IdmRoleTreeNodeDto();
automaticRoleA.setRecursionType(RecursionType.NO);
automaticRoleA.setRole(roleA.getId());
automaticRoleA.setTreeNode(nodeD.getId());
automaticRoleA = saveAutomaticRole(automaticRoleA, false);
//
// test
Set<IdmRoleTreeNodeDto> automaticRoles = roleTreeNodeService.getAutomaticRolesByTreeNode(nodeD.getId());
assertEquals(1, automaticRoles.size());
assertEquals(roleA.getId(), automaticRoles.iterator().next().getRole());
assertTrue(roleTreeNodeService.getAutomaticRolesByTreeNode(nodeB.getId()).isEmpty());
assertTrue(roleTreeNodeService.getAutomaticRolesByTreeNode(nodeF.getId()).isEmpty());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testDontRemoveSameRole.
@Test
public void testDontRemoveSameRole() {
automaticRoleF = new IdmRoleTreeNodeDto();
automaticRoleF.setRecursionType(RecursionType.UP);
automaticRoleF.setRole(roleA.getId());
automaticRoleF.setTreeNode(nodeF.getId());
automaticRoleF = saveAutomaticRole(automaticRoleF, false);
//
automaticRoleE = new IdmRoleTreeNodeDto();
automaticRoleE.setRecursionType(RecursionType.NO);
automaticRoleE.setRole(roleA.getId());
automaticRoleE.setTreeNode(nodeE.getId());
automaticRoleE = saveAutomaticRole(automaticRoleE, false);
//
// prepare identity and contract
IdmIdentityDto identity = helper.createIdentity("test");
IdmIdentityContractDto contract = new IdmIdentityContractDto();
contract.setIdentity(identity.getId());
contract.setWorkPosition(nodeF.getId());
contract = service.save(contract);
//
// check assigned role after creation
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contract.getId());
assertEquals(1, identityRoles.size());
assertEquals(roleA.getId(), identityRoles.get(0).getRole());
assertEquals(automaticRoleF.getId(), identityRoles.get(0).getRoleTreeNode());
//
UUID id = identityRoles.get(0).getId();
//
// change
contract.setWorkPosition(nodeE.getId());
contract = service.save(contract);
//
// check assigned role after creation
identityRoles = identityRoleService.findAllByContract(contract.getId());
assertEquals(1, identityRoles.size());
assertEquals(roleA.getId(), identityRoles.get(0).getRole());
assertEquals(automaticRoleE.getId(), identityRoles.get(0).getRoleTreeNode());
assertEquals(id, identityRoles.get(0).getId());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testReferentialIntegrityOnRole.
@Test
public void testReferentialIntegrityOnRole() {
helper.setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, false);
try {
// prepare data
IdmRoleDto role = helper.createRole();
IdmTreeNodeDto treeNode = helper.createTreeNode();
// automatic role
IdmRoleTreeNodeDto roleTreeNode = helper.createRoleTreeNode(role, treeNode, false);
//
assertNotNull(roleTreeNode.getId());
assertEquals(roleTreeNode.getId(), roleTreeNodeService.get(roleTreeNode.getId()).getId());
//
helper.deleteRole(role.getId());
//
assertNull(roleTreeNodeService.get(roleTreeNode.getId()));
} finally {
helper.setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, true);
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testAssingRoleByNewAutomaticRoleForExistingContracts.
@Test
public void testAssingRoleByNewAutomaticRoleForExistingContracts() {
IdmIdentityDto identity = helper.createIdentity("test-exists");
//
IdmIdentityContractDto contract = new IdmIdentityContractDto();
contract.setIdentity(identity.getId());
contract.setPosition("new position");
contract = service.save(contract);
//
IdmIdentityContractDto contractF = new IdmIdentityContractDto();
contractF.setIdentity(identity.getId());
contractF.setWorkPosition(nodeF.getId());
contractF = service.save(contractF);
//
IdmIdentityContractDto contractD = new IdmIdentityContractDto();
contractD.setIdentity(identity.getId());
contractD.setWorkPosition(nodeD.getId());
contractD = service.save(contractD);
//
IdmIdentityContractDto contractB = new IdmIdentityContractDto();
contractB.setIdentity(identity.getId());
contractB.setWorkPosition(nodeB.getId());
contractB = service.save(contractB);
//
// create new automatic role
automaticRoleD = new IdmRoleTreeNodeDto();
automaticRoleD.setRecursionType(RecursionType.DOWN);
automaticRoleD.setRole(roleA.getId());
automaticRoleD.setTreeNode(nodeD.getId());
automaticRoleD = saveAutomaticRole(automaticRoleD, true);
//
// check
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contractB.getId());
assertTrue(identityRoles.isEmpty());
//
identityRoles = identityRoleService.findAllByContract(contractD.getId());
assertEquals(1, identityRoles.size());
assertEquals(automaticRoleD.getId(), identityRoles.get(0).getRoleTreeNode());
//
identityRoles = identityRoleService.findAllByContract(contractF.getId());
assertEquals(1, identityRoles.size());
assertEquals(automaticRoleD.getId(), identityRoles.get(0).getRoleTreeNode());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testDontAssingRoleForDisabledContract.
@Test
public void testDontAssingRoleForDisabledContract() {
IdmIdentityDto identity = helper.createIdentity();
//
IdmIdentityContractDto contractD = new IdmIdentityContractDto();
contractD.setIdentity(identity.getId());
contractD.setWorkPosition(nodeD.getId());
contractD.setState(ContractState.DISABLED);
contractD = service.save(contractD);
//
// create new automatic role
automaticRoleD = new IdmRoleTreeNodeDto();
automaticRoleD.setRecursionType(RecursionType.NO);
automaticRoleD.setRole(roleA.getId());
automaticRoleD.setTreeNode(nodeD.getId());
automaticRoleD = saveAutomaticRole(automaticRoleD, true);
//
// check
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contractD.getId());
assertEquals(0, identityRoles.size());
}
Aggregations