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());
}
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());
}
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);
}
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());
}
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();
}
}
Aggregations