use of eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto in project CzechIdMng by bcvsolutions.
the class DefaultAccTestHelper method checkSyncLog.
@Override
public SysSyncLogDto checkSyncLog(AbstractSysSyncConfigDto config, SynchronizationActionType actionType, int count, OperationResultType resultType) {
SysSyncConfigFilter logFilter = new SysSyncConfigFilter();
logFilter.setId(config.getId());
logFilter.setIncludeLastLog(Boolean.TRUE);
List<AbstractSysSyncConfigDto> configs = syncConfigService.find(logFilter, null).getContent();
assertEquals(1, configs.size());
SysSyncLogDto log = configs.get(0).getLastSyncLog();
if (actionType == null) {
return log;
}
SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
actionLogFilter.setSynchronizationLogId(log.getId());
List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
if (resultType == null) {
return actionType == action.getSyncAction();
}
return actionType == action.getSyncAction() && action.getOperationResult() == resultType;
}).findFirst().get();
if (resultType != null) {
assertEquals(resultType, actionLog.getOperationResult());
}
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(actionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
assertEquals(count, items.size());
return log;
}
use of eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto in project CzechIdMng by bcvsolutions.
the class RoleWorkflowAdSyncTest method checkSyncLog.
private SysSyncLogDto checkSyncLog(AbstractSysSyncConfigDto config, SynchronizationActionType actionType, int count, OperationResultType resultType) {
SysSyncLogFilter logFilter = new SysSyncLogFilter();
logFilter.setSynchronizationConfigId(config.getId());
List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
Assert.assertEquals(1, logs.size());
SysSyncLogDto log = logs.get(0);
if (actionType == null) {
return log;
}
SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
actionLogFilter.setSynchronizationLogId(log.getId());
List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
return actionType == action.getSyncAction();
}).findFirst().orElse(null);
Assert.assertNotNull(actionLog);
Assert.assertEquals(resultType, actionLog.getOperationResult());
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(actionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(count, items.size());
return log;
}
use of eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceIntegrationTest method testExecuteDeferredResultOnCreateSyncItemLog.
@Test
public void testExecuteDeferredResultOnCreateSyncItemLog() {
DefaultLongPollingManager defaultPollingManager = (DefaultLongPollingManager) longPollingManager;
// Clear deferred result and subscribers
defaultPollingManager.getSuspendedRequests().clear();
defaultPollingManager.getRegistredSubscribers().clear();
// create test system and sync
SysSystemDto system = helper.createTestResourceSystem(true);
AbstractSysSyncConfigDto syncConfig = createSync(system);
DeferredResult<OperationResultDto> result = new DeferredResult<OperationResultDto>(1000000l, new OperationResultDto(OperationState.NOT_EXECUTED));
DeferredResultWrapper wrapper = new DeferredResultWrapper(system.getId(), system.getClass(), result);
wrapper.onCheckResultCallback(new CheckLongPollingResult() {
@Override
public void checkDeferredResult(DeferredResult<OperationResultDto> result, LongPollingSubscriber subscriber) {
systemController.checkDeferredRequest(result, subscriber);
}
});
Queue<DeferredResultWrapper> suspendedRequests = defaultPollingManager.getSuspendedRequests();
assertEquals(0, suspendedRequests.size());
longPollingManager.addSuspendedResult(wrapper);
suspendedRequests = defaultPollingManager.getSuspendedRequests();
assertEquals(1, suspendedRequests.size());
longPollingManager.checkDeferredRequests(SysSystemDto.class);
suspendedRequests = defaultPollingManager.getSuspendedRequests();
assertEquals(1, suspendedRequests.size());
helper.startSynchronization(syncConfig);
SysSyncConfigFilter logFilter = new SysSyncConfigFilter();
logFilter.setId(syncConfig.getId());
logFilter.setIncludeLastLog(Boolean.TRUE);
List<AbstractSysSyncConfigDto> configs = syncConfigService.find(logFilter, null).getContent();
Assert.assertEquals(1, configs.size());
SysSyncLogDto log = new SysSyncLogDto();
log.setSynchronizationConfig(syncConfig.getId());
log = syncLogService.save(log);
SysSyncActionLogDto mockAction = new SysSyncActionLogDto();
mockAction.setSyncAction(SynchronizationActionType.IGNORE);
mockAction.setSyncLog(log.getId());
mockAction.setOperationResult(OperationResultType.IGNORE);
mockAction = syncActionLogService.save(mockAction);
// Sync item log created -> must be detected
SysSyncItemLogDto mockItemLogDto = new SysSyncItemLogDto();
mockItemLogDto.setSyncActionLog(mockAction.getId());
mockItemLogDto.setIdentification(helper.createName());
mockItemLogDto = syncItemLogService.save(mockItemLogDto);
// Check must be called twice, because first detect the change and second remove
// ended deferred result (from some reason is not invoked method
// result.onCompleted)
longPollingManager.checkDeferredRequests(SysSystemDto.class);
longPollingManager.checkDeferredRequests(SysSystemDto.class);
suspendedRequests = defaultPollingManager.getSuspendedRequests();
assertEquals(0, suspendedRequests.size());
// Clear deferred result and subscribers
defaultPollingManager.getSuspendedRequests().clear();
defaultPollingManager.getRegistredSubscribers().clear();
}
use of eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto 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(\"" + helper.getSchemaColumnName("PARENT") + "\").getValue();" + " def uidValue = account.getAttributeByName(\"__NAME__\").getValue();" + " if(parentValue != null && parentValue.equals(uidValue)){" + " account.getAttributeByName(\"" + helper.getSchemaColumnName("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);
//
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());
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.SysSyncItemLogDto 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));
//
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());
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);
}
Aggregations