use of eu.bcvsolutions.idm.acc.dto.SysSyncLogDto 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.acc.dto.SysSyncLogDto in project CzechIdMng by bcvsolutions.
the class DefaultTreeSynchronizationServiceTest method doStartSyncC_MissingEntity.
@Test
public void doStartSyncC_MissingEntity() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
syncConfigCustom.setRootsFilterScript("if(account){ def parentValue = account.getAttributeByName(\"PARENT\").getValue();" + " def uidValue = account.getAttributeByName(\"__NAME__\").getValue();" + " if(parentValue != null && parentValue.equals(uidValue)){" + " account.getAttributeByName(\"PARENT\").setValues(null); return Boolean.TRUE;}}" + " \nreturn Boolean.FALSE;");
// Set sync config
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigService.save(syncConfigCustom);
//
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(2, actions.size());
SysSyncActionLogDto createEntityActionLog = actions.stream().filter(action -> {
return SynchronizationActionType.CREATE_ENTITY == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(createEntityActionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(6, items.size());
IdmTreeTypeDto treeType = treeTypeService.find(null).getContent().stream().filter(tree -> {
return tree.getName().equals(TREE_TYPE_TEST);
}).findFirst().get();
Assert.assertEquals(2, treeNodeService.findRoots(treeType.getId(), null).getContent().size());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.acc.dto.SysSyncLogDto in project CzechIdMng by bcvsolutions.
the class DefaultTreeSynchronizationServiceTest method doStartSyncA_MissingEntity.
@Test
public void doStartSyncA_MissingEntity() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
//
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 createEntityActionLog = actions.stream().filter(action -> {
return SynchronizationActionType.CREATE_ENTITY == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(createEntityActionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(6, items.size());
IdmTreeTypeDto treeType = treeTypeService.find(null).getContent().stream().filter(tree -> {
return tree.getName().equals(TREE_TYPE_TEST);
}).findFirst().get();
Assert.assertEquals(1, treeNodeService.findRoots(treeType.getId(), null).getContent().size());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.acc.dto.SysSyncLogDto in project CzechIdMng by bcvsolutions.
the class IdentityContractSyncTest method checkContractInvalidTest.
@Test
public /**
* HR process are not executed during sync. If contract is invalid, then HR
* process disable the Identity. But in the sync we need skip this
* functionality.
*/
void checkContractInvalidTest() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
Assert.assertTrue(config instanceof SysSyncContractConfigDto);
((SysSyncContractConfigDto) config).setStartOfHrProcesses(false);
syncConfigService.save(config);
IdmIdentityDto ownerOne = helper.createIdentity(CONTRACT_OWNER_ONE);
IdmIdentityDto ownerTwo = helper.createIdentity(CONTRACT_OWNER_TWO);
helper.createIdentity(CONTRACT_LEADER_ONE);
contractService.findAllByIdentity(ownerOne.getId()).forEach(contract -> {
IdentityContractEvent event = new IdentityContractEvent(IdentityContractEventType.DELETE, contract);
event.getProperties().put(IdmIdentityContractService.SKIP_HR_PROCESSES, Boolean.TRUE);
contractService.publish(event);
});
contractService.findAllByIdentity(ownerTwo.getId()).forEach(contract -> {
IdentityContractEvent event = new IdentityContractEvent(IdentityContractEventType.DELETE, contract);
event.getProperties().put(IdmIdentityContractService.SKIP_HR_PROCESSES, Boolean.TRUE);
contractService.publish(event);
});
IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
contractFilter.setProperty(IdmIdentityContract_.position.getName());
contractFilter.setValue("1");
Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
contractFilter.setValue("2");
Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
// Change resources (set to invalid) .. must be call in transaction
this.getBean().initContractCheckInvalidTest();
synchornizationService.setSynchronizationConfigId(config.getId());
synchornizationService.process();
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 2);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
contractFilter.setValue("1");
List<IdmIdentityContractDto> contractsOne = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsOne.size());
Assert.assertFalse(contractsOne.get(0).isValid());
contractFilter.setValue("3");
List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsThree.size());
Assert.assertTrue(contractsThree.get(0).isValid());
// HR processes was not started, identity have to be in "incorrect" state
ownerOne = identityService.getByUsername(CONTRACT_OWNER_ONE);
Assert.assertFalse(ownerOne.isDisabled());
ownerTwo = identityService.getByUsername(CONTRACT_OWNER_TWO);
Assert.assertFalse(ownerTwo.isDisabled());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.acc.dto.SysSyncLogDto in project CzechIdMng by bcvsolutions.
the class IdentityContractSyncTest method testLinkAndUpdateContract.
@Test
public void testLinkAndUpdateContract() {
String position1 = "test-link-update-1-" + System.currentTimeMillis();
String position2 = "test-link-update-2-" + System.currentTimeMillis();
String position3 = "test-link-update-3-" + System.currentTimeMillis();
IdmIdentityDto leader = helper.createIdentity();
IdmTreeNodeDto workPosition = helper.createTreeNode();
SysSystemDto system = initData();
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
this.getBean().deleteAllResourceData();
config.setUnlinkedAction(SynchronizationUnlinkedActionType.LINK_AND_UPDATE_ENTITY);
config = (SysSyncContractConfigDto) syncConfigService.save(config);
IdmIdentityDto identity1 = helper.createIdentity();
IdmIdentityDto identity2 = helper.createIdentity();
IdmIdentityDto identity3 = helper.createIdentity();
IdmIdentityContractDto contrac1 = helper.getPrimeContract(identity1.getId());
IdmIdentityContractDto contrac2 = helper.getPrimeContract(identity2.getId());
IdmIdentityContractDto contrac3 = helper.getPrimeContract(identity3.getId());
contrac1.setPosition(position1);
contrac1.setDescription(position1);
contrac2.setPosition(position2);
contrac2.setDescription(position2);
contrac3.setPosition(position3);
contrac3.setDescription(position3);
contrac1 = contractService.save(contrac1);
contrac2 = contractService.save(contrac2);
contrac3 = contractService.save(contrac3);
// check empty guarantee
IdmContractGuaranteeFilter guaranteeFilter = new IdmContractGuaranteeFilter();
guaranteeFilter.setIdentityContractId(contrac1.getId());
List<IdmContractGuaranteeDto> gurantees = guaranteeService.find(guaranteeFilter, null).getContent();
assertTrue(gurantees.isEmpty());
guaranteeFilter.setIdentityContractId(contrac2.getId());
gurantees = guaranteeService.find(guaranteeFilter, null).getContent();
assertTrue(gurantees.isEmpty());
guaranteeFilter.setIdentityContractId(contrac3.getId());
gurantees = guaranteeService.find(guaranteeFilter, null).getContent();
assertTrue(gurantees.isEmpty());
assertNull(contrac1.getState());
assertNull(contrac2.getState());
assertNull(contrac3.getState());
this.getBean().createContractData(position1, identity1.getUsername(), leader.getUsername(), Boolean.TRUE.toString(), workPosition.getId().toString(), "10", Boolean.FALSE.toString());
this.getBean().createContractData(position2, identity2.getUsername(), leader.getUsername(), Boolean.TRUE.toString(), workPosition.getId().toString(), "10", Boolean.FALSE.toString());
this.getBean().createContractData(position3, identity3.getUsername(), leader.getUsername(), Boolean.TRUE.toString(), workPosition.getId().toString(), "10", Boolean.FALSE.toString());
// Start sync
synchornizationService.setSynchronizationConfigId(config.getId());
synchornizationService.process();
contractService.findAllByIdentity(identity1.getId());
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.LINK_AND_UPDATE_ENTITY, 3);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
IdmIdentityContractDto updatedContract1 = helper.getPrimeContract(identity1.getId());
IdmIdentityContractDto updatedContract2 = helper.getPrimeContract(identity2.getId());
IdmIdentityContractDto updatedContract3 = helper.getPrimeContract(identity3.getId());
assertNotEquals(updatedContract1.getModified(), contrac1.getModified());
assertNotEquals(updatedContract2.getModified(), contrac2.getModified());
assertNotEquals(updatedContract3.getModified(), contrac3.getModified());
assertNotEquals(updatedContract1.getState(), contrac1.getState());
assertNotEquals(updatedContract2.getState(), contrac2.getState());
assertNotEquals(updatedContract3.getState(), contrac3.getState());
assertEquals(ContractState.EXCLUDED, updatedContract1.getState());
assertEquals(ContractState.EXCLUDED, updatedContract2.getState());
assertEquals(ContractState.EXCLUDED, updatedContract3.getState());
assertEquals(contrac1.getId(), updatedContract1.getId());
assertEquals(contrac2.getId(), updatedContract2.getId());
assertEquals(contrac3.getId(), updatedContract3.getId());
guaranteeFilter.setIdentityContractId(contrac1.getId());
gurantees = guaranteeService.find(guaranteeFilter, null).getContent();
assertFalse(gurantees.isEmpty());
assertEquals(leader.getId(), gurantees.get(0).getGuarantee());
guaranteeFilter.setIdentityContractId(contrac2.getId());
gurantees = guaranteeService.find(guaranteeFilter, null).getContent();
assertFalse(gurantees.isEmpty());
assertEquals(leader.getId(), gurantees.get(0).getGuarantee());
guaranteeFilter.setIdentityContractId(contrac3.getId());
gurantees = guaranteeService.find(guaranteeFilter, null).getContent();
assertFalse(gurantees.isEmpty());
assertEquals(leader.getId(), gurantees.get(0).getGuarantee());
}
Aggregations