use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleValidRequestSchedulerTest method createNonValidRoleAndValid.
@Test
public void createNonValidRoleAndValid() throws InterruptedException, ExecutionException {
IdmIdentityDto identity = createAndSaveIdentity();
IdmRoleDto role = createAndSaveRole();
createAndSaveRoleSystem(role, system);
IdmTreeTypeDto treeType = createAndSaveTreeType();
IdmTreeNodeDto treeNode = createAndSaveTreeNode(treeType);
IdmIdentityContractDto identityContract = createAndSaveIdentityContract(identity, treeNode);
LocalDate validFrom = new LocalDate();
// set plus days
validFrom = validFrom.plusDays(5);
// provisioning is not executed, role isn't valid from now
createAndSaveIdentityRole(identityContract, role, null, validFrom);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
List<AccIdentityAccountDto> list = identityAccountService.find(filter, null).getContent();
// it must not exists
assertEquals(true, list.isEmpty());
//
IdentityRoleValidRequestTaskExecutor taskExecutor1 = new IdentityRoleValidRequestTaskExecutor();
LongRunningFutureTask<Boolean> futureTask1 = longRunningTaskManager.execute(taskExecutor1);
assertEquals(true, futureTask1.getFutureTask().get());
IdmLongRunningTaskDto longRunningTask1 = longRunningTaskService.get(taskExecutor1.getLongRunningTaskId());
assertEquals(OperationState.EXECUTED, longRunningTask1.getResult().getState());
list = identityAccountService.find(filter, null).getContent();
// still empty, role isn't valid
assertEquals(true, list.isEmpty());
List<IdmIdentityRole> roles = identityRoleRepository.findAllByIdentityContract_Identity_Id(identity.getId(), null);
assertEquals(1, roles.size());
IdmIdentityRole identityRole = roles.get(0);
validFrom = new LocalDate();
validFrom = validFrom.minusDays(5);
identityRole.setValidFrom(validFrom);
identityRoleRepository.save(identityRole);
// execute again
IdentityRoleValidRequestTaskExecutor taskExecutor2 = new IdentityRoleValidRequestTaskExecutor();
LongRunningFutureTask<Boolean> futureTask2 = longRunningTaskManager.execute(taskExecutor2);
assertEquals(true, futureTask2.getFutureTask().get());
IdmLongRunningTaskDto longRunningTask2 = longRunningTaskService.get(taskExecutor2.getLongRunningTaskId());
assertEquals(OperationState.EXECUTED, longRunningTask2.getResult().getState());
list = identityAccountService.find(filter, null).getContent();
assertEquals(false, list.isEmpty());
assertEquals(1, list.size());
// newly created accounts
assertNotNull(list.get(0));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleValidRequestSchedulerTest method createLotsOfValidRequests.
@Test
public void createLotsOfValidRequests() throws InterruptedException, ExecutionException {
IdmRoleDto role = createAndSaveRole();
createAndSaveRoleSystem(role, system);
IdmTreeTypeDto treeType = createAndSaveTreeType();
IdmTreeNodeDto treeNode = createAndSaveTreeNode(treeType);
LocalDate validFrom = new LocalDate();
// set plus days
validFrom = validFrom.plusDays(5);
// clear request, if any
List<IdmIdentityRoleValidRequestDto> list = identityRoleValidRequestService.findAllValid();
for (IdmIdentityRoleValidRequestDto request : list) {
identityRoleValidRequestService.delete(request);
}
List<IdmIdentityDto> identities = new ArrayList<>();
for (int index = 0; index < MAX_CREATE; index++) {
IdmIdentityDto identity = createAndSaveIdentity();
IdmIdentityContractDto identityContract = createAndSaveIdentityContract(identity, treeNode);
// provisioning is not executed, role isn't valid from now
createAndSaveIdentityRole(identityContract, role, null, validFrom);
identities.add(identity);
}
list = identityRoleValidRequestService.findAllValid();
assertEquals(0, list.size());
validFrom = validFrom.minusDays(15);
for (IdmIdentityDto identity : identities) {
List<IdmIdentityRole> roles = identityRoleRepository.findAllByIdentityContract_Identity_Id(identity.getId(), null);
assertEquals(1, roles.size());
IdmIdentityRole identityRole = roles.get(0);
identityRole.setValidFrom(validFrom);
identityRoleRepository.save(identityRole);
}
list = identityRoleValidRequestService.findAllValid();
assertEquals(MAX_CREATE, list.size());
IdentityRoleValidRequestTaskExecutor taskExecutor = new IdentityRoleValidRequestTaskExecutor();
LongRunningFutureTask<Boolean> futureTask = longRunningTaskManager.execute(taskExecutor);
assertEquals(true, futureTask.getFutureTask().get());
IdmLongRunningTaskDto longRunningTask = longRunningTaskService.get(taskExecutor.getLongRunningTaskId());
assertEquals(OperationState.EXECUTED, longRunningTask.getResult().getState());
list = identityRoleValidRequestService.findAllValid();
assertEquals(0, list.size());
for (IdmIdentityDto identity : identities) {
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
List<AccIdentityAccountDto> accountsList = identityAccountService.find(filter, null).getContent();
assertEquals(false, accountsList.isEmpty());
assertEquals(1, accountsList.size());
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdentityFilterTest method testSubordinatesForFilter.
@Test
public void testSubordinatesForFilter() {
IdmIdentityDto person = getIdmIdentity("ThisIsTestName005", "ThisIsTestName005", "ThisIsTestName005@gemail.eu", "000000005", false);
IdmIdentityDto manager = getIdmIdentity("ThisIsTestName006", "ThisIsTestName006", "ThisIsTestName006@gemail.eu", "000000006", false);
UUID manager_id = manager.getId();
IdmTreeTypeDto type1 = helper.createTreeType("ThisIsTestType001");
IdmTreeNodeDto node2 = helper.createTreeNode(type1, "Somename002", null);
IdmTreeNodeDto node1 = helper.createTreeNode(type1, "ThisIsTestNode001", node2);
helper.createIdentityContact(manager, node2);
helper.createIdentityContact(person, node1);
// contract.setGuarantee(manager_id);
// IdmIdentityContractDto contract2 = idmIdentityContractService.save(contract);
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setSubordinatesFor(manager_id);
filter.setSubordinatesByTreeType(type1.getId());
Page<IdmIdentityDto> result = identityService.find(filter, null);
assertEquals("Wrong SubordinatesFor", 1, result.getTotalElements());
assertEquals("Wrong SuborganizedFor user ID", person.getId(), result.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdentityFilterTest method testTreeNodeFilter.
@Test
public void testTreeNodeFilter() {
IdmIdentityDto person = getIdmIdentity("ThisIsTestName008", "ThisIsTestName008", "ThisIsTestName008@gemail.eu", "000000008", false);
IdmTreeTypeDto type = helper.createTreeType("ThisIsTestType003");
IdmTreeNodeDto node = helper.createTreeNode(type, "ThisIsTestNode003", null);
UUID nodeUuid = node.getId();
helper.createIdentityContact(person, node);
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setTreeNode(nodeUuid);
filter.setRecursively(false);
Page<IdmIdentityDto> result = identityService.find(filter, null);
assertEquals("Wrong TreeNode", 1, result.getTotalElements());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto 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 = helper.createTreeType("ThisIsTestType005x");
IdmTreeTypeDto type2 = helper.createTreeType("ThisIsTestType006x");
/*
r1 o
/
n1 o
/
n2 o
*/
IdmTreeNodeDto node1 = helper.createTreeNode(type1, "ThisIsTestNode005", null);
IdmTreeNodeDto node11 = helper.createTreeNode(type1, "ThisIsTestNode006", node1);
IdmTreeNodeDto node12 = helper.createTreeNode(type1, "ThisIsTestNode007", node11);
/*
r2 o
*/
IdmTreeNodeDto node2 = helper.createTreeNode(type2, "ThisIsTestNode008", null);
// contracts
helper.createIdentityContact(person1, node1);
helper.createIdentityContact(person2, node11);
helper.createIdentityContact(person3, node12);
helper.createIdentityContact(person4, node2);
// node1 UUID
UUID node1id = node1.getId();
// test
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setFirstName(person1.getFirstName());
filter.setRecursively(true);
filter.setTreeNode(node1id);
Page<IdmIdentityDto> result = identityService.find(filter, null);
assertEquals("Wrong Recursive firstname", 4, result.getTotalElements());
filter.setRecursively(false);
result = identityService.find(filter, null);
assertEquals("Wrong NonRecursive firstname", 1, result.getTotalElements());
}
Aggregations