use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleRequestServiceIntegrationTest method testDeleteTreeAutomaticRole.
@Test
public void testDeleteTreeAutomaticRole() {
IdmRoleDto role = prepareRole();
IdmTreeNodeDto nodeOne = getHelper().createTreeNode();
IdmRoleTreeNodeDto automaticRole = new IdmRoleTreeNodeDto();
automaticRole.setRole(role.getId());
automaticRole.setName(role.getCode());
automaticRole.setTreeNode(nodeOne.getId());
// Create automatic role via manager
automaticRole = automaticRoleManager.createAutomaticRoleByTree(automaticRole, true);
Assert.assertNotNull(automaticRole.getId());
IdmRoleTreeNodeDto treeAutomaticRole = roleTreeNodeService.get(automaticRole.getId());
Assert.assertNotNull(treeAutomaticRole);
Assert.assertEquals(nodeOne.getId(), treeAutomaticRole.getTreeNode());
Assert.assertEquals(role.getId(), treeAutomaticRole.getRole());
// Delete automatic role via manager
automaticRoleManager.deleteAutomaticRole(automaticRole, true);
IdmRoleTreeNodeDto deletedAutomaticRole = roleTreeNodeService.get(automaticRole.getId());
Assert.assertNull(deletedAutomaticRole);
}
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 testDontAssingRoleForDisabledContractWhenPositionIsChanged.
@Test
public void testDontAssingRoleForDisabledContractWhenPositionIsChanged() {
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
//
IdmIdentityContractDto contractD = new IdmIdentityContractDto();
contractD.setIdentity(identity.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);
//
contractD.setWorkPosition(nodeD.getId());
contractD = service.save(contractD);
//
// check
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contractD.getId());
assertEquals(0, identityRoles.size());
}
Aggregations