use of eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter in project CzechIdMng by bcvsolutions.
the class DefaultTreeSynchronizationServiceTest method provisioningF_DeleteAccount.
@Test
public void provisioningF_DeleteAccount() {
IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
filter.setProperty(NODE_NAME);
filter.setValue("P12");
IdmTreeNodeDto nodeOne = treeNodeService.find(filter, null).getContent().get(0);
Assert.assertNotNull(nodeOne);
// Delete IDM node (must invoke provisioning) .. We delete child
treeNodeService.delete(nodeOne);
Assert.assertTrue(treeNodeService.find(filter, null).getContent().isEmpty());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter in project CzechIdMng by bcvsolutions.
the class IdentityContractSyncTest method defaultWorkPositionTest.
@Test
public void defaultWorkPositionTest() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
Assert.assertTrue(config instanceof SysSyncContractConfigDto);
helper.createIdentity(CONTRACT_OWNER_ONE);
helper.createIdentity(CONTRACT_OWNER_TWO);
helper.createIdentity(CONTRACT_LEADER_ONE);
helper.createIdentity(CONTRACT_LEADER_TWO);
// Set default tree type to sync configuration
IdmTreeTypeDto treeType = treeTypeService.getByCode(InitApplicationData.DEFAULT_TREE_TYPE);
Assert.assertNotNull(treeType);
SysSyncContractConfigDto configContract = (SysSyncContractConfigDto) config;
configContract.setDefaultTreeType(treeType.getId());
// Set default tree node to sync configuration
IdmTreeNodeFilter nodeFilter = new IdmTreeNodeFilter();
nodeFilter.setCode("one");
nodeFilter.setTreeTypeId(treeType.getId());
List<IdmTreeNodeDto> nodes = treeNodeService.find(nodeFilter, null).getContent();
Assert.assertEquals(1, nodes.size());
IdmTreeNodeDto defaultNode = nodes.get(0);
configContract.setDefaultTreeNode(defaultNode.getId());
config = syncConfigService.save(configContract);
IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
contractFilter.setProperty(IdmIdentityContract_.position.getName());
// Start sync
helper.startSynchronization(config);
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
// Default work positions must be set
contractFilter.setValue("1");
List<IdmIdentityContractDto> contractsOne = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsOne.size());
Assert.assertEquals(defaultNode.getId(), contractsOne.get(0).getWorkPosition());
contractFilter.setValue("2");
List<IdmIdentityContractDto> contractsTwo = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsTwo.size());
Assert.assertEquals(defaultNode.getId(), contractsTwo.get(0).getWorkPosition());
contractFilter.setValue("3");
List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsThree.size());
Assert.assertEquals(defaultNode.getId(), contractsThree.get(0).getWorkPosition());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter in project CzechIdMng by bcvsolutions.
the class TreeSyncTest method testTreeWithAutomaticRoles.
@Test
public void testTreeWithAutomaticRoles() {
IdmTreeTypeDto treeType = getHelper().createTreeType();
//
// create synchronization
AbstractSysSyncConfigDto syncConfigCustom = this.getBean().doCreateSyncConfig(treeType.getCode(), true);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
// We want to sync all account under that node!
IdmTreeNodeDto treeNodeExistedNode = helper.createTreeNode(treeType, null);
syncConfigCustom.setRootsFilterScript("if(account){ def parentValue = account.getAttributeByName(\"" + helper.getSchemaColumnName("PARENT") + "\").getValue();" + " if(parentValue == null || parentValue.isEmpty()){" + " account.getAttributeByName(\"" + helper.getSchemaColumnName("PARENT") + "\").setValues([\"" + treeNodeExistedNode.getId() + "\"]); return Boolean.TRUE;}}" + " \nreturn Boolean.FALSE;");
syncConfigService.save(syncConfigCustom);
//
helper.startSynchronization(syncConfigCustom);
//
SysSyncLogFilter logFilter = new SysSyncLogFilter();
logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
Assert.assertEquals(1, logs.size());
SysSyncLogDto log = logs.get(0);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
//
helper.checkSyncLog(syncConfigCustom, SynchronizationActionType.CREATE_ENTITY, 6, OperationResultType.SUCCESS);
//
// prepare contracts
IdmTreeNodeFilter nodeFilter = new IdmTreeNodeFilter();
nodeFilter.setTreeTypeId(treeType.getId());
nodeFilter.setCode("112");
List<IdmTreeNodeDto> results = treeNodeService.find(nodeFilter, null).getContent();
IdmTreeNodeDto parentNode = results.get(0);
nodeFilter.setCode("1111");
// parent will be set by synchronization
IdmTreeNodeDto node = treeNodeService.find(nodeFilter, null).getContent().get(0);
// define automatic role for parent
IdmRoleDto role = getHelper().createRole();
IdmRoleTreeNodeDto automaticRole = getHelper().createRoleTreeNode(role, parentNode, RecursionType.DOWN, true);
// create identity with contract on node
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
getHelper().createContract(identity, node);
// no role should be assigned now
List<IdmIdentityRoleDto> assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
Assert.assertTrue(assignedRoles.isEmpty());
//
// change tree structure and synchronize
this.getBean().changeParent("1111", "112");
helper.startSynchronization(syncConfigCustom);
log = helper.checkSyncLog(syncConfigCustom, SynchronizationActionType.UPDATE_ENTITY, 6, OperationResultType.SUCCESS);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
//
assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
Assert.assertEquals(1, assignedRoles.size());
Assert.assertEquals(automaticRole.getId(), assignedRoles.get(0).getAutomaticRole());
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter in project CzechIdMng by bcvsolutions.
the class IdmTreeNodeControllerRestTest method testFindByDefaultTreeType.
@Test
@Transactional
public void testFindByDefaultTreeType() {
String code = getHelper().createName();
IdmTreeNodeDto nodeDefault;
try {
getHelper().loginAdmin();
//
IdmTreeTypeDto defaultTreeType = getHelper().getDefaultTreeType();
IdmTreeTypeDto treeTypeTwo = getHelper().createTreeType();
//
nodeDefault = getHelper().createTreeNode(defaultTreeType, code, null);
// other
getHelper().createTreeNode(treeTypeTwo, code, null);
} finally {
getHelper().logout();
}
IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
filter.setDefaultTreeType(true);
filter.setCode(code);
List<IdmTreeNodeDto> results = find(filter);
//
Assert.assertEquals(1, results.size());
Assert.assertEquals(nodeDefault, results.get(0));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter in project CzechIdMng by bcvsolutions.
the class IdmTreeNodeControllerRestTest method testFindByRootsAndChildren.
@Test
public void testFindByRootsAndChildren() {
IdmTreeTypeDto treeType = getHelper().createTreeType();
IdmTreeNodeDto nodeOne = getHelper().createTreeNode(treeType, null);
IdmTreeNodeDto nodeTwo = getHelper().createTreeNode(treeType, nodeOne);
//
// root
IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
filter.setTreeTypeId(treeType.getId());
filter.setRoots(Boolean.TRUE);
List<IdmTreeNodeDto> results = find(filter);
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(nodeOne.getId())));
// is root - false
filter.setRoots(Boolean.FALSE);
results = find(filter);
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(nodeTwo.getId())));
//
// children
filter.setRoots(null);
filter.setParent(nodeOne.getId());
results = find(filter);
Assert.assertEquals(1, results.size());
Assert.assertTrue(results.stream().anyMatch(r -> r.getId().equals(nodeTwo.getId())));
// no children
filter.setParent(nodeTwo.getId());
results = find(filter);
Assert.assertTrue(results.isEmpty());
}
Aggregations