use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultTreeSynchronizationServiceTest method provisioningD_UpdateAccount.
@Test
public void provisioningD_UpdateAccount() {
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.assertNotNull(one);
Assert.assertEquals("P12", one.getCode());
nodeOne.setCode(CHANGED);
// Save IDM changed node (must invoke provisioning)
treeNodeService.save(nodeOne);
// Check state before provisioning
one = entityManager.find(TestTreeResource.class, "P12");
Assert.assertNotNull(one);
Assert.assertEquals(CHANGED, one.getCode());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultTreeSynchronizationServiceTest method provisioningC_CreateAccounts_correct.
@Test
public void provisioningC_CreateAccounts_correct() {
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);
TestTreeResource root = entityManager.find(TestTreeResource.class, "P1");
Assert.assertNull(root);
// Save IDM node again (must invoke provisioning)
// Root first
treeNodeService.save(nodeRoot);
// Node next
treeNodeService.save(nodeOne);
// Check state before provisioning
root = entityManager.find(TestTreeResource.class, "P1");
Assert.assertNotNull(root);
one = entityManager.find(TestTreeResource.class, "P12");
Assert.assertNotNull(one);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultTreeSynchronizationServiceTest method doStartSyncB_MissingAccount_DeleteEntity.
@Test
public void doStartSyncB_MissingAccount_DeleteEntity() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
// Remove node code to changed
this.getBean().removeOne();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
// Set sync config
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.DELETE_ENTITY);
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.assertNotNull(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(3, actions.size());
SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
return SynchronizationActionType.DELETE_ENTITY == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(actionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(1, items.size());
// Check state after sync
treeNode = treeNodeService.get(treeNode.getId());
Assert.assertNull(treeNode);
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto 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
synchornizationService.setSynchronizationConfigId(config.getId());
synchornizationService.process();
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.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractService method prepareMainContract.
@Override
public IdmIdentityContractDto prepareMainContract(UUID identityId) {
Assert.notNull(identityId);
//
// set identity
IdmIdentityContractDto contract = new IdmIdentityContractDto();
contract.setIdentity(identityId);
contract.setMain(true);
//
// set default contract name
// TODO: add boolean attribute
contract.setPosition(DEFAULT_POSITION_NAME);
//
// set working position
IdmTreeNodeDto defaultTreeNode = treeConfiguration.getDefaultNode();
if (defaultTreeNode != null) {
contract.setWorkPosition(defaultTreeNode.getId());
}
return contract;
}
Aggregations