use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceFilterTest method testFilterBySchemaName.
@Test
public void testFilterBySchemaName() {
SysSystemDto system = this.getHelper().createTestResourceSystem(true, getHelper().createName());
// Generate second system for add mapped attributes
this.getHelper().createTestResourceSystem(true, getHelper().createName());
SysSystemMappingFilter filterMapping = new SysSystemMappingFilter();
filterMapping.setSystemId(system.getId());
List<SysSystemMappingDto> mappings = systemMappingService.find(filterMapping, null).getContent();
assertEquals(1, mappings.size());
SysSystemMappingDto mappingDto = mappings.get(0);
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemMappingId(mappingDto.getId());
filter.setName(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME);
List<SysSystemAttributeMappingDto> attributeMappings = systemAttributeMappingService.find(filter, null).getContent();
assertEquals(1, attributeMappings.size());
SysSystemAttributeMappingDto attributeMappingDto = attributeMappings.get(0);
assertEquals(TestHelper.ATTRIBUTE_MAPPING_FIRSTNAME, attributeMappingDto.getName());
assertEquals(mappingDto.getId(), attributeMappingDto.getSystemMapping());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceFilterTest method testFilterByOperationTypeFound.
@Test
public void testFilterByOperationTypeFound() {
SysSystemDto system = this.getHelper().createTestResourceSystem(true, getHelper().createName());
// Generate second system for add mapped attributes
this.getHelper().createTestResourceSystem(true, getHelper().createName());
SysSystemMappingFilter filterMapping = new SysSystemMappingFilter();
filterMapping.setSystemId(system.getId());
List<SysSystemMappingDto> mappings = systemMappingService.find(filterMapping, null).getContent();
assertEquals(1, mappings.size());
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemId(system.getId());
filter.setOperationType(SystemOperationType.PROVISIONING);
List<SysSystemAttributeMappingDto> attributeMappings = systemAttributeMappingService.find(filter, null).getContent();
// Six is default for standard test resource
assertEquals(6, attributeMappings.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceFilterTest method testFilterByNameNotFound.
@Test
public void testFilterByNameNotFound() {
SysSystemDto system = this.getHelper().createTestResourceSystem(true, getHelper().createName());
// Generate second system for add mapped attributes
this.getHelper().createTestResourceSystem(true, getHelper().createName());
SysSystemMappingFilter filterMapping = new SysSystemMappingFilter();
filterMapping.setSystemId(system.getId());
List<SysSystemMappingDto> mappings = systemMappingService.find(filterMapping, null).getContent();
assertEquals(1, mappings.size());
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemId(system.getId());
filter.setName(IdmIdentity_.state.getName());
List<SysSystemAttributeMappingDto> attributeMappings = systemAttributeMappingService.find(filter, null).getContent();
assertEquals(0, attributeMappings.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemAttributeMappingServiceFilterTest method testFilterByOperationTypeNotFound.
@Test
public void testFilterByOperationTypeNotFound() {
SysSystemDto system = this.getHelper().createTestResourceSystem(true, getHelper().createName());
// Generate second system for add mapped attributes
this.getHelper().createTestResourceSystem(true, getHelper().createName());
SysSystemMappingFilter filterMapping = new SysSystemMappingFilter();
filterMapping.setSystemId(system.getId());
List<SysSystemMappingDto> mappings = systemMappingService.find(filterMapping, null).getContent();
assertEquals(1, mappings.size());
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemId(system.getId());
filter.setOperationType(SystemOperationType.SYNCHRONIZATION);
List<SysSystemAttributeMappingDto> attributeMappings = systemAttributeMappingService.find(filter, null).getContent();
assertEquals(0, attributeMappings.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultTreeSynchronizationServiceTest method syncCorellationAttribute.
@Test
public void syncCorellationAttribute() {
this.getBean().deleteAllResourceData();
this.getBean().initTreeData();
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));
IdmTreeTypeDto treeTypeOne = getHelper().createTreeType();
IdmTreeTypeDto treeTypeTwo = getHelper().createTreeType();
// Set tree type to the mapping
SysSystemMappingDto mappingDto = DtoUtils.getEmbedded(syncConfigCustom, SysSyncConfig_.systemMapping.getName(), SysSystemMappingDto.class);
mappingDto.setTreeType(treeTypeOne.getId());
systemMappingService.save(mappingDto);
// Set sync config
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.LINK);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom.setRootsFilterScript(null);
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(syncConfigCustom.getSystemMapping());
attributeMappingFilter.setIdmPropertyName(IdmTreeNode_.code.getName());
// Set correlation attribute
List<SysSystemAttributeMappingDto> attributes = attributeMappingService.find(attributeMappingFilter, null).getContent();
Assert.assertEquals(1, attributes.size());
SysSystemAttributeMappingDto correlationAttribute = attributes.get(0);
syncConfigCustom.setCorrelationAttribute(correlationAttribute.getId());
syncConfigService.save(syncConfigCustom);
// Check state before sync
// For first tree type
IdmTreeNodeFilter nodeFilter = new IdmTreeNodeFilter();
nodeFilter.setProperty(IdmTreeNode_.code.getName());
nodeFilter.setValue("111");
nodeFilter.setTreeTypeId(treeTypeOne.getId());
List<IdmTreeNodeDto> nodes = treeNodeService.find(nodeFilter, null).getContent();
Assert.assertEquals(0, nodes.size());
// For second tree type
nodeFilter.setTreeTypeId(treeTypeTwo.getId());
nodes = treeNodeService.find(nodeFilter, null).getContent();
Assert.assertEquals(0, nodes.size());
IdmTreeNodeDto node = new IdmTreeNodeDto();
node.setTreeType(treeTypeTwo.getId());
node.setName("111");
node.setCode(node.getName());
node = treeNodeService.save(node);
nodes = treeNodeService.find(nodeFilter, null).getContent();
Assert.assertEquals(1, nodes.size());
// Start sync
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();
boolean linkActionLogExists = actions.stream().filter(action -> {
return SynchronizationActionType.LINK == action.getSyncAction();
}).findFirst().isPresent();
// Must be false, because node is in the different tree type!
assertFalse(linkActionLogExists);
// Delete log
syncLogService.delete(log);
treeNodeService.delete(node);
// Create node for tree type One
node = new IdmTreeNodeDto();
node.setTreeType(treeTypeOne.getId());
node.setName("111");
node.setCode(node.getName());
node = treeNodeService.save(node);
nodeFilter.setTreeTypeId(treeTypeOne.getId());
nodes = treeNodeService.find(nodeFilter, null).getContent();
Assert.assertEquals(1, nodes.size());
// Start sync again
helper.startSynchronization(syncConfigCustom);
logFilter = new SysSyncLogFilter();
logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
logs = syncLogService.find(logFilter, null).getContent();
Assert.assertEquals(1, logs.size());
log = logs.get(0);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
actionLogFilter = new SysSyncActionLogFilter();
actionLogFilter.setSynchronizationLogId(log.getId());
actions = syncActionLogService.find(actionLogFilter, null).getContent();
SysSyncActionLogDto linkActionLog = actions.stream().filter(action -> {
return SynchronizationActionType.LINK == action.getSyncAction();
}).findFirst().get();
// Must exists, because node is in the tree type One!
assertNotNull(linkActionLog);
assertEquals(1, linkActionLog.getOperationCount().intValue());
SysSchemaObjectClassDto schemaObjectDto = DtoUtils.getEmbedded(mappingDto, SysSystemMapping_.objectClass.getName(), SysSchemaObjectClassDto.class);
AccTreeAccountFilter treeAccountFilter = new AccTreeAccountFilter();
treeAccountFilter.setSystemId(schemaObjectDto.getSystem());
treeAccountFilter.setTreeNodeId(node.getId());
List<AccTreeAccountDto> treeAccounts = treeAccountService.find(treeAccountFilter, null).getContent();
assertEquals(1, treeAccounts.size());
// Delete log
syncLogService.delete(log);
}
Aggregations