Search in sources :

Example 66 with IdmTreeNodeDto

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

the class IdentityFilterTest method testManagersForFilter.

@Test
public void testManagersForFilter() {
    IdmIdentityDto person = getIdmIdentity("ThisIsTestName009", "ThisIsTestName009", "ThisIsTestName009@gemail.eu", "000000009", false);
    IdmIdentityDto manager = getIdmIdentity("ThisIsTestName010", "ThisIsTestName010", "ThisIsTestName010@gemail.eu", "000000010", false);
    UUID person_id = person.getId();
    manager.getId();
    IdmTreeTypeDto type1 = helper.createTreeType("ThisIsTestType004");
    IdmTreeNodeDto node2 = helper.createTreeNode(type1, "Somename001", null);
    IdmTreeNodeDto node1 = helper.createTreeNode(type1, "ThisIsTestNode004", node2);
    helper.createIdentityContact(manager, node2);
    helper.createIdentityContact(person, node1);
    // contract.setGuarantee(manager_id);
    // IdmIdentityContractDto contract2 = idmIdentityContractService.save(contract);
    IdmIdentityFilter filter = new IdmIdentityFilter();
    // filter.setIncludeGuarantees(true);
    filter.setManagersFor(person_id);
    filter.setManagersByTreeType(type1.getId());
    Page<IdmIdentityDto> result = identityService.find(filter, null);
    assertEquals("Wrong ManagersFor", 1, result.getTotalElements());
    assertEquals("Wrong ManagersFor user ID", manager.getId(), result.getContent().get(0).getId());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) 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) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 67 with IdmTreeNodeDto

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

the class IdentityFindPositionsTest method findManagers.

@Test
public void findManagers() {
    IdmIdentityDto user = createAndSaveIdentity("test_position_01");
    IdmIdentityDto user2 = createAndSaveIdentity("test_position_02");
    IdmIdentityDto user3 = createAndSaveIdentity("test_position_03");
    IdmIdentityDto user4 = createAndSaveIdentity("test_position_04");
    IdmTreeTypeDto treeTypeFirst = new IdmTreeTypeDto();
    treeTypeFirst.setCode("TEST_TYPE_CODE_FIRST");
    treeTypeFirst.setName("TEST_TYPE_NAME_FIRST");
    treeTypeFirst = treeTypeService.save(treeTypeFirst);
    IdmTreeTypeDto treeTypeSecond = new IdmTreeTypeDto();
    treeTypeSecond.setCode("TEST_TYPE_CODE_SECOND");
    treeTypeSecond.setName("TEST_TYPE_NAME_SECOND");
    treeTypeSecond = treeTypeService.save(treeTypeSecond);
    // create root for second type
    IdmTreeNodeDto nodeRootSec = new IdmTreeNodeDto();
    nodeRootSec.setName("TEST_NODE_NAME_ROOT_SEC");
    nodeRootSec.setCode("TEST_NODE_CODE_ROOT_SEC");
    nodeRootSec.setTreeType(treeTypeSecond.getId());
    nodeRootSec = treeNodeService.save(nodeRootSec);
    // create root for first type
    IdmTreeNodeDto nodeRoot = new IdmTreeNodeDto();
    nodeRoot.setName("TEST_NODE_NAME_ROOT");
    nodeRoot.setCode("TEST_NODE_CODE_ROOT");
    nodeRoot.setTreeType(treeTypeFirst.getId());
    nodeRoot = treeNodeService.save(nodeRoot);
    // create one for first type
    IdmTreeNodeDto nodeOne = new IdmTreeNodeDto();
    nodeOne.setName("TEST_NODE_NAME_ONE");
    nodeOne.setCode("TEST_NODE_CODE_ONE");
    nodeOne.setParent(nodeRoot.getId());
    nodeOne.setTreeType(treeTypeFirst.getId());
    nodeOne = treeNodeService.save(nodeOne);
    // create two for first type
    IdmTreeNodeDto nodeTwo = new IdmTreeNodeDto();
    nodeTwo.setName("TEST_NODE_NAME_TWO");
    nodeTwo.setCode("TEST_NODE_CODE_TWO");
    nodeTwo.setParent(nodeOne.getId());
    nodeTwo.setTreeType(treeTypeFirst.getId());
    nodeTwo = treeNodeService.save(nodeTwo);
    createIdentityContract(user, null, nodeRoot);
    createIdentityContract(user2, null, nodeOne);
    createIdentityContract(user3, null, nodeOne);
    createIdentityContract(user4, null, nodeTwo);
    // createIdentityContract(user, manager3, null);
    List<IdmIdentityDto> managersList = identityService.findAllManagers(user3.getId(), treeTypeFirst.getId());
    assertEquals(1, managersList.size());
    IdmIdentityDto manager = managersList.get(0);
    assertEquals(user.getId(), manager.getId());
    managersList = identityService.findAllManagers(user4.getId(), treeTypeFirst.getId());
    assertEquals(2, managersList.size());
    managersList = identityService.findAllManagers(user.getId(), treeTypeFirst.getId());
    assertEquals(1, managersList.size());
    createIdentityContract(user, null, nodeTwo);
    managersList = identityService.findAllManagers(user.getId(), treeTypeFirst.getId());
    assertEquals(2, managersList.size());
    List<IdmIdentityDto> managersListSec = identityService.findAllManagers(user.getId(), treeTypeSecond.getId());
    // user with superAdminRole
    assertEquals(1, managersListSec.size());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 68 with IdmTreeNodeDto

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

the class IdentityRoleValidRequestIntegrationTest method createAndSaveTreeNode.

private IdmTreeNodeDto createAndSaveTreeNode(IdmTreeTypeDto treeType) {
    IdmTreeNodeDto entity = new IdmTreeNodeDto();
    entity.setCode("valid_tree_node_" + System.currentTimeMillis());
    entity.setName("valid_tree_node_" + System.currentTimeMillis());
    entity.setTreeType(treeType.getId());
    return saveInTransaction(entity, treeNodeService);
}
Also used : IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)

Example 69 with IdmTreeNodeDto

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

the class IdentityRoleValidRequestIntegrationTest method deleteIdentity.

@Test
public void deleteIdentity() {
    IdmIdentityDto identity = createAndSaveIdentity();
    IdmRoleDto role = createAndSaveRole();
    IdmTreeTypeDto treeType = createAndSaveTreeType();
    IdmTreeNodeDto treeNode = createAndSaveTreeNode(treeType);
    IdmIdentityContractDto identityContract = createAndSaveIdentityContract(identity, treeNode);
    LocalDate from = new LocalDate();
    from = from.plusDays(5);
    createAndSaveIdentityRole(identityContract, role, null, from);
    List<IdmIdentityRoleValidRequestDto> list = identityRoleValidRequestService.find(null).getContent();
    int size = list.size();
    identityService.delete(identity);
    list = identityRoleValidRequestService.find(null).getContent();
    assertNotEquals(size, list.size());
    list = identityRoleValidRequestService.findAllValidRequestForIdentityId(identity.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) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) LocalDate(org.joda.time.LocalDate) IdmIdentityRoleValidRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleValidRequestDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 70 with IdmTreeNodeDto

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

the class IdmTreeNodeServiceIntegrationTest method testBadTreeTypeCreate.

@Test
public void testBadTreeTypeCreate() {
    IdmTreeTypeDto parent1 = helper.createTreeType();
    IdmTreeTypeDto parent2 = helper.createTreeType();
    // 
    IdmTreeNodeDto node1 = helper.createTreeNode(parent1, null);
    IdmTreeNodeDto node2 = helper.createTreeNode(parent1, node1);
    IdmTreeNodeDto node3 = helper.createTreeNode(parent1, node2);
    // 
    try {
        helper.createTreeNode(parent2, node1);
        Assert.fail();
    } catch (TreeNodeException ex) {
        Assert.assertTrue(ex.getMessage().contains("bad type"));
    } catch (Exception e) {
        Assert.fail();
    }
    // 
    try {
        helper.createTreeNode(parent2, node3);
        Assert.fail();
    } catch (TreeNodeException ex) {
        Assert.assertTrue(ex.getMessage().contains("bad type"));
    } catch (Exception e) {
        Assert.fail();
    }
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) TreeNodeException(eu.bcvsolutions.idm.core.exception.TreeNodeException) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) TreeNodeException(eu.bcvsolutions.idm.core.exception.TreeNodeException) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Aggregations

IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)79 Test (org.junit.Test)48 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)44 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)35 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)31 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)26 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)21 UUID (java.util.UUID)13 IdmTreeNodeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter)12 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)12 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)9 LocalDate (org.joda.time.LocalDate)9 IdmIdentityContractFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter)7 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)6 IdmRoleTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto)6 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)6 ApiOperation (io.swagger.annotations.ApiOperation)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)5