use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class IdmTreeNodeServiceIntegrationTest method testForestIndexAfterBulkMove.
@Test
public void testForestIndexAfterBulkMove() {
int rootCount = 5;
// prepare new tree type
IdmTreeTypeDto treeType = helper.createTreeType();
// create root nodes
for (int i = 0; i < rootCount; i++) {
helper.createTreeNode(treeType, null);
}
// move nodes to the first node
IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
filter.setTreeTypeId(treeType.getId());
List<IdmTreeNodeDto> nodes = treeNodeService.find(filter, null).getContent();
IdmTreeNodeDto root = nodes.get(0);
for (int i = 0; i < nodes.size(); i++) {
IdmTreeNodeDto node = nodes.get(i);
if (node.equals(root)) {
continue;
}
node.setParent(root.getId());
node = treeNodeService.save(node);
}
// check
Assert.assertEquals(1L, treeNodeService.findRoots(treeType.getId(), null).getTotalElements());
Assert.assertEquals(rootCount - 1, treeNodeService.findChildrenByParent(root.getId(), null).getTotalElements());
Assert.assertEquals(rootCount - 1, treeNodeForestContentService.findDirectChildren(root.getId(), null).getTotalElements());
Assert.assertEquals(rootCount - 1, treeNodeForestContentService.findAllChildren(root.getId(), null).getTotalElements());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleAttributeIntegrationTest method testUpdateWithoutAutomaticRoles.
@Test
public void testUpdateWithoutAutomaticRoles() {
IdmIdentityDto identity = testHelper.createIdentity();
IdmIdentityContractDto primeContract = testHelper.getPrimeContract(identity.getId());
IdmRoleDto basicRole = testHelper.createRole();
testHelper.assignRoles(primeContract, basicRole);
IdmTreeTypeDto type = testHelper.createTreeType();
IdmTreeNodeDto node = testHelper.createTreeNode(type, null);
primeContract.setWorkPosition(node.getId());
identity.setDescription(String.valueOf(System.currentTimeMillis()));
identityContractService.save(primeContract);
identityService.save(identity);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class TreeTypeDeleteBulkActionIntegrationTest method testForceDelete.
@Test
public void testForceDelete() {
logout();
loginAsAdmin();
// create sub tree nodes, automatic roles, contract, contract positions
IdmTreeTypeDto treeType = getHelper().createTreeType();
IdmTreeNodeDto treeNode = getHelper().createTreeNode(treeType, null, null);
IdmTreeNodeDto subTreeNode = getHelper().createTreeNode(treeType, (String) null, treeNode);
IdmTreeNodeDto subSubTreeNode = getHelper().createTreeNode(treeType, (String) null, subTreeNode);
IdmTreeNodeDto otherTreeNode = getHelper().createTreeNode();
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
IdmIdentityContractDto contract = getHelper().createContract(identity, subTreeNode);
IdmContractPositionDto contractPosition = getHelper().createContractPosition(contract, subSubTreeNode);
IdmRoleDto role = getHelper().createRole();
IdmIdentityRoleDto assignedRoleOne = getHelper().createIdentityRole(contract, role);
IdmIdentityRoleDto assignedRoleTwo = getHelper().createIdentityRole(contractPosition, role);
IdmIdentityRoleDto assignedRoleOther = getHelper().createIdentityRole(getHelper().getPrimeContract(identity), role);
IdmRoleTreeNodeDto automaticRole = getHelper().createRoleTreeNode(role, treeNode, RecursionType.DOWN, false);
//
// 3 manual, 2 automatic
Assert.assertEquals(5, identityRoleService.findAllByIdentity(identity.getId()).size());
//
// remove tree type
Map<String, Object> properties = new HashMap<>();
properties.put(EntityEventProcessor.PROPERTY_FORCE_DELETE, Boolean.TRUE);
// delete by bulk action
IdmBulkActionDto bulkAction = this.findBulkAction(IdmTreeType.class, TreeTypeDeleteBulkAction.NAME);
bulkAction.setIdentifiers(Sets.newHashSet(treeType.getId()));
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
//
checkResultLrt(processAction, 1l, 0l, 0l);
//
Assert.assertNull(treeTypeService.get(treeType));
Assert.assertNull(treeNodeService.get(treeNode));
Assert.assertNull(treeNodeService.get(subTreeNode));
Assert.assertNull(treeNodeService.get(subSubTreeNode));
Assert.assertNull(treeNodeService.get(subSubTreeNode));
Assert.assertNotNull(identityRoleService.get(assignedRoleOne));
Assert.assertNotNull(identityRoleService.get(assignedRoleTwo));
Assert.assertNull(identityContractService.get(contract).getWorkPosition());
Assert.assertNull(contractPositionService.get(contractPosition).getWorkPosition());
Assert.assertNull(roleTreeNodeService.get(automaticRole));
//
Assert.assertNotNull(treeNodeService.get(otherTreeNode));
Assert.assertNotNull(getHelper().getPrimeContract(identity));
Assert.assertNotNull(identityRoleService.get(assignedRoleOther));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleValidRequestIntegrationTest method deleteIdentityRole.
@Test
public void deleteIdentityRole() {
IdmIdentityDto identity = createAndSaveIdentity();
IdmRoleDto role = createAndSaveRole();
IdmTreeTypeDto treeType = createAndSaveTreeType();
IdmTreeNodeDto treeNode = createAndSaveTreeNode(treeType);
IdmIdentityContractDto identityContract = createAndSaveIdentityContract(identity, treeNode);
LocalDate from = LocalDate.now();
from = from.plusDays(5);
IdmIdentityRoleDto identityRole = createAndSaveIdentityRole(identityContract, role, null, from);
List<IdmIdentityRoleValidRequestDto> list = identityRoleValidRequestService.find(null).getContent();
int size = list.size();
idmIdentityRoleSerivce.delete(identityRole);
list = identityRoleValidRequestService.find(null).getContent();
assertNotEquals(size, list.size());
list = identityRoleValidRequestService.findAllValidRequestForIdentityRoleId(identityRole.getId());
assertEquals(true, list.isEmpty());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class IdentityFilterTest method testRecursivelyFilter.
@Test
public void testRecursivelyFilter() {
// setting employees
IdmIdentityDto person1 = getIdmIdentity("Klement", "Marek", "ThisIsTestName011@gemail.eu", "000000011", false);
IdmIdentityDto person2 = getIdmIdentity("Klement", "Marek", "ThisIsTestName014@gemail.eu", "000000014", false);
IdmIdentityDto person3 = getIdmIdentity("Klement", "Marek", "ThisIsTestName015@gemail.eu", "000000015", false);
IdmIdentityDto person4 = getIdmIdentity("Klement", "Marek", "ThisIsTestName016@gemail.eu", "000000016", false);
// setting structure
IdmTreeTypeDto type1 = getHelper().createTreeType("ThisIsTestType005x");
IdmTreeTypeDto type2 = getHelper().createTreeType("ThisIsTestType006x");
/*
r1 o
/
n1 o
/
n2 o
*/
IdmTreeNodeDto node1 = getHelper().createTreeNode(type1, "ThisIsTestNode005", null);
IdmTreeNodeDto node11 = getHelper().createTreeNode(type1, "ThisIsTestNode006", node1);
IdmTreeNodeDto node12 = getHelper().createTreeNode(type1, "ThisIsTestNode007", node11);
/*
r2 o
*/
IdmTreeNodeDto node2 = getHelper().createTreeNode(type2, "ThisIsTestNode008", null);
// contracts
getHelper().createContract(person1, node1);
getHelper().createContract(person2, node11);
getHelper().createContract(person3, node12);
getHelper().createContract(person4, node2);
// node1 UUID
UUID node1id = node1.getId();
// test
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setFirstName(person1.getFirstName());
filter.setRecursively(true);
filter.setTreeNode(node1id);
List<IdmIdentityDto> results = identityService.find(filter, null).getContent();
Assert.assertEquals("Wrong Recursive firstname", 3, results.size());
Assert.assertTrue(results.stream().anyMatch(i -> i.getId().equals(person1.getId())));
Assert.assertTrue(results.stream().anyMatch(i -> i.getId().equals(person2.getId())));
Assert.assertTrue(results.stream().anyMatch(i -> i.getId().equals(person3.getId())));
//
filter.setRecursively(false);
results = identityService.find(filter, null).getContent();
Assert.assertEquals("Wrong NonRecursive firstname", 1, results.size());
Assert.assertTrue(results.stream().anyMatch(i -> i.getId().equals(person1.getId())));
}
Aggregations