Search in sources :

Example 6 with IdmTreeTypeDto

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());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 7 with IdmTreeTypeDto

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);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 8 with IdmTreeTypeDto

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));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) HashMap(java.util.HashMap) IdmContractPositionDto(eu.bcvsolutions.idm.core.api.dto.IdmContractPositionDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 9 with IdmTreeTypeDto

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());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) LocalDate(java.time.LocalDate) IdmIdentityRoleValidRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 10 with IdmTreeTypeDto

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())));
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) ZonedDateTime(java.time.ZonedDateTime) IdmIdentityContract(eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) FilterManager(eu.bcvsolutions.idm.core.api.repository.filter.FilterManager) ArrayList(java.util.ArrayList) IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) DataFilter(eu.bcvsolutions.idm.core.api.dto.filter.DataFilter) Lists(com.google.common.collect.Lists) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) DefaultManagersFilter(eu.bcvsolutions.idm.core.model.repository.filter.DefaultManagersFilter) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) EntityUtils(eu.bcvsolutions.idm.core.api.utils.EntityUtils) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) Assert.assertNotNull(org.junit.Assert.assertNotNull) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Assert.assertTrue(org.junit.Assert.assertTrue) MultiValueMap(org.springframework.util.MultiValueMap) Test(org.junit.Test) UUID(java.util.UUID) Field(java.lang.reflect.Field) Page(org.springframework.data.domain.Page) IdentityState(eu.bcvsolutions.idm.core.api.domain.IdentityState) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) FilterBuilder(eu.bcvsolutions.idm.core.api.repository.filter.FilterBuilder) DefaultSubordinatesFilter(eu.bcvsolutions.idm.core.model.repository.filter.DefaultSubordinatesFilter) List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) DefaultContractByManagerFilter(eu.bcvsolutions.idm.core.model.repository.filter.DefaultContractByManagerFilter) IdmIdentity_(eu.bcvsolutions.idm.core.model.entity.IdmIdentity_) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) Assert(org.junit.Assert) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Transactional(org.springframework.transaction.annotation.Transactional) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)123 Test (org.junit.Test)91 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)89 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)64 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)44 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)33 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)32 UUID (java.util.UUID)26 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)21 IdmTreeNodeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter)21 Transactional (org.springframework.transaction.annotation.Transactional)19 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)18 SysSyncContractConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto)18 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)18 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)16 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)13 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)13 IdmIdentityContractFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter)11 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)11 LocalDate (java.time.LocalDate)10