use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class AbstractWorkingPositionFilterIntegrationTest method createPosition.
private IdmTreeNodeDto createPosition(IdmTreeTypeDto type, IdmTreeNodeDto parent) {
IdmTreeNodeDto node = helper.createTreeNode(type, parent);
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmTreeNode.class, FormService.DEFAULT_DEFINITION_CODE);
IdmFormAttributeDto attr = formDefinition.getMappedAttributeByCode(EavCodeSubordinatesFilter.DEFAULT_FORM_ATTRIBUTE_CODE);
if (attr == null) {
attr = new IdmFormAttributeDto();
attr.setName("Parent code");
attr.setCode(EavCodeSubordinatesFilter.DEFAULT_FORM_ATTRIBUTE_CODE);
attr.setFormDefinition(formDefinition.getId());
attr.setPersistentType(PersistentType.TEXT);
attr.setUnmodifiable(true);
attr = formService.saveAttribute(attr);
}
//
formService.saveValues(node, attr, Lists.newArrayList(parent.getCode()));
//
return node;
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class AbstractWorkingPositionFilterIntegrationTest method prepareData.
/**
* prepare identities, tree structures and contracts
* suborinateOne has managerOne by tree structure - structureOne
* suborinateOne has managerTwo by tree structure - structureTwo
* suborinateOne has guaranteeThree by contractOne
* suborinateOne has guaranteeFour by contractTwo
* suborinateOne is manager for suborinateTwo
*/
protected void prepareData() {
managerOne = helper.createIdentity();
managerTwo = helper.createIdentity();
invalidManager = helper.createIdentity();
guaranteeThree = helper.createIdentity();
guaranteeFour = helper.createIdentity();
subordinateOne = helper.createIdentity();
subordinateTwo = helper.createIdentity();
subordinateThree = helper.createIdentity();
//
structureOne = helper.createTreeType();
IdmTreeNodeDto managerOnePosition = helper.createTreeNode(structureOne, null);
helper.createIdentityContact(managerOne, managerOnePosition);
helper.createIdentityContact(invalidManager, managerOnePosition, new LocalDate().plusDays(1), null);
//
structureTwo = helper.createTreeType();
IdmTreeNodeDto managerTwoPosition = helper.createTreeNode(structureTwo, null);
helper.createIdentityContact(managerTwo, managerTwoPosition);
// subordinate one
IdmTreeNodeDto subordinateOnePositionOne = createPosition(structureOne, managerOnePosition);
contractOne = helper.createIdentityContact(subordinateOne, subordinateOnePositionOne);
helper.createContractGuarantee(contractOne.getId(), guaranteeThree.getId());
IdmTreeNodeDto subordinateOnePositionTwo = createPosition(structureTwo, managerTwoPosition);
contractTwo = helper.createIdentityContact(subordinateOne, subordinateOnePositionTwo);
helper.createContractGuarantee(contractTwo.getId(), guaranteeFour.getId());
// subordinate two
IdmTreeNodeDto subordinateTwoPosition = createPosition(structureOne, subordinateOnePositionOne);
IdmIdentityContractDto contractSubordinateTwo = helper.createIdentityContact(subordinateTwo, subordinateTwoPosition);
helper.createContractGuarantee(contractSubordinateTwo.getId(), guaranteeFour.getId());
// subordinate three
helper.createContractGuarantee(helper.createIdentityContact(subordinateThree).getId(), managerOne.getId());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultTreeSynchronizationServiceTest method provisioningB_CreateAccounts_withException.
// Provisioning tree in incorrect order
@Test(expected = ProvisioningException.class)
public void provisioningB_CreateAccounts_withException() {
IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
filter.setProperty(NODE_NAME);
filter.setValue("P1");
IdmTreeNodeDto nodeRoot = treeNodeService.find(filter, null).getContent().get(0);
Assert.assertNotNull(nodeRoot);
filter.setValue("P12");
IdmTreeNodeDto nodeOne = treeNodeService.find(filter, null).getContent().get(0);
Assert.assertNotNull(nodeOne);
// Check state before provisioning
TestTreeResource one = entityManager.find(TestTreeResource.class, "P12");
Assert.assertNull(one);
// Create mapping for provisioning
this.createProvisionigMapping();
// Save IDM node (must invoke provisioning)
// We didn't provisioning for root first ... expect throw exception
treeNodeService.save(nodeOne);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultTreeSynchronizationServiceTest method doStartSyncB_Linked_doEntityUpdate.
@Test
public void doStartSyncB_Linked_doEntityUpdate() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
// Change node code to changed
this.getBean().changeOne();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
// Set sync config
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigService.save(syncConfigCustom);
// Check state before sync
IdmTreeNodeFilter nodeFilter = new IdmTreeNodeFilter();
nodeFilter.setProperty(NODE_NAME);
nodeFilter.setValue("111");
IdmTreeNodeDto treeNode = treeNodeService.find(nodeFilter, null).getContent().get(0);
Assert.assertEquals("111", treeNode.getCode());
synchornizationService.setSynchronizationConfigId(syncConfigCustom.getId());
synchornizationService.process();
//
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());
SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
actionLogFilter.setSynchronizationLogId(log.getId());
List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
Assert.assertEquals(1, actions.size());
SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
return SynchronizationActionType.UPDATE_ENTITY == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(actionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(6, items.size());
// Check state after sync
treeNode = treeNodeService.get(treeNode.getId());
Assert.assertEquals(CHANGED, treeNode.getCode());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultTreeSynchronizationServiceTest method provisioningE_DeleteAccount_IntegrityException.
@Test(expected = TreeNodeException.class)
public void provisioningE_DeleteAccount_IntegrityException() {
IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
filter.setProperty(NODE_NAME);
filter.setValue("P1");
IdmTreeNodeDto nodeRoot = treeNodeService.find(filter, null).getContent().get(0);
Assert.assertNotNull(nodeRoot);
// Delete IDM node (must invoke provisioning) .. We delete node with some children ... must throw integrity exception
// Generally we counts with provisioning on every node ... include children (Recursively delete is not good idea!)
treeNodeService.delete(nodeRoot);
}
Aggregations