use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultConnectorManagerTest method testAutoProvisioningMappingOutsideWizard.
@Test
public void testAutoProvisioningMappingOutsideWizard() {
SysSystemDto systemDto = helper.createTestResourceSystem(true);
ConnectorType connectorType = connectorManager.findConnectorTypeBySystem(systemDto);
Assert.assertEquals(DefaultConnectorType.NAME, connectorType.getConnectorName());
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setSystemId(systemDto.getId());
SysSystemMappingDto sysSystemMappingDto = mappingService.find(mappingFilter, null).getContent().stream().findFirst().orElse(null);
Assert.assertNotNull(sysSystemMappingDto);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
connectorTypeDto.getMetadata().put(AbstractConnectorType.SCHEMA_ID, (sysSystemMappingDto).getObjectClass().toString());
// Delete a created mapping.
mappingService.delete(sysSystemMappingDto);
SysSystemMappingDto mappingDto = new SysSystemMappingDto();
mappingDto.setObjectClass(sysSystemMappingDto.getObjectClass());
mappingDto.setName("Mapping");
mappingDto.setEntityType(SystemEntityType.IDENTITY);
mappingDto.setOperationType(SystemOperationType.PROVISIONING);
mappingDto = mappingService.publish(new SystemMappingEvent(SystemMappingEvent.SystemMappingEventType.CREATE, mappingDto, ImmutableMap.of(SysSystemMappingService.ENABLE_AUTOMATIC_CREATION_OF_MAPPING, true))).getContent();
// Attributes had to be created.
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(mappingDto.getId());
List<SysSystemAttributeMappingDto> attributeMappingDtos = attributeMappingService.find(attributeMappingFilter, null).getContent();
Assert.assertEquals(7, attributeMappingDtos.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultConnectorManagerTest method testAutoSyncMappingOutsideWizard.
@Test
public void testAutoSyncMappingOutsideWizard() {
SysSystemDto systemDto = helper.createTestResourceSystem(true);
ConnectorType connectorType = connectorManager.findConnectorTypeBySystem(systemDto);
Assert.assertEquals(DefaultConnectorType.NAME, connectorType.getConnectorName());
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setSystemId(systemDto.getId());
SysSystemMappingDto sysSystemMappingDto = mappingService.find(mappingFilter, null).getContent().stream().findFirst().orElse(null);
Assert.assertNotNull(sysSystemMappingDto);
ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
connectorTypeDto.getMetadata().put(AbstractConnectorType.SCHEMA_ID, (sysSystemMappingDto).getObjectClass().toString());
// Delete a created mapping.
mappingService.delete(sysSystemMappingDto);
SysSystemMappingDto syncMapping = new SysSystemMappingDto();
syncMapping.setObjectClass(sysSystemMappingDto.getObjectClass());
syncMapping.setName("Mapping");
syncMapping.setEntityType(SystemEntityType.IDENTITY);
syncMapping.setOperationType(SystemOperationType.SYNCHRONIZATION);
syncMapping = mappingService.publish(new SystemMappingEvent(SystemMappingEvent.SystemMappingEventType.CREATE, syncMapping, ImmutableMap.of(SysSystemMappingService.ENABLE_AUTOMATIC_CREATION_OF_MAPPING, true))).getContent();
// Attributes had to be created.
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(syncMapping.getId());
List<SysSystemAttributeMappingDto> attributeMappingDtos = attributeMappingService.find(attributeMappingFilter, null).getContent();
Assert.assertEquals(7, attributeMappingDtos.size());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method doCreateSyncConfig.
@Test
@Transactional
public void doCreateSyncConfig() {
initData();
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(SystemEntityType.IDENTITY);
mappingFilter.setSystemId(system.getId());
mappingFilter.setOperationType(SystemOperationType.SYNCHRONIZATION);
List<SysSystemMappingDto> mappings = systemMappingService.find(mappingFilter, null).getContent();
Assert.assertEquals(1, mappings.size());
SysSystemMappingDto mapping = mappings.get(0);
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(mapping.getId());
List<SysSystemAttributeMappingDto> attributes = schemaAttributeMappingService.find(attributeMappingFilter, null).getContent();
SysSystemAttributeMappingDto nameAttribute = attributes.stream().filter(attribute -> {
return attribute.getName().equals(ATTRIBUTE_NAME);
}).findFirst().get();
SysSystemAttributeMappingDto modifiedAttribute = attributes.stream().filter(attribute -> {
return attribute.getName().equals(ATTRIBUTE_MODIFIED);
}).findFirst().get();
// Create default synchronization config
AbstractSysSyncConfigDto syncConfigCustom = new SysSyncIdentityConfigDto();
syncConfigCustom.setCustomFilter(true);
syncConfigCustom.setSystemMapping(mapping.getId());
syncConfigCustom.setCorrelationAttribute(nameAttribute.getId());
syncConfigCustom.setTokenAttribute(modifiedAttribute.getId());
syncConfigCustom.setFilterAttribute(modifiedAttribute.getId());
syncConfigCustom.setReconciliation(true);
syncConfigCustom.setName(SYNC_CONFIG_NAME);
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigService.save(syncConfigCustom);
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setSystemId(system.getId());
Assert.assertEquals(1, syncConfigService.find(configFilter, null).getTotalElements());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method doStartSyncE_StrategyWriteIfNull.
@Test
public void doStartSyncE_StrategyWriteIfNull() {
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));
// Find email attribute and change strategy on WRITE_IF_NULL
SysSystemMappingFilter mappingFilter = new SysSystemMappingFilter();
mappingFilter.setEntityType(SystemEntityType.IDENTITY);
SysSystemMappingDto systemMapping = systemMappingService.get(syncConfigCustom.getSystemMapping());
SysSystemDto system = systemService.get(schemaObjectClassService.get(systemMapping.getObjectClass()).getSystem());
mappingFilter.setSystemId(system.getId());
mappingFilter.setOperationType(SystemOperationType.SYNCHRONIZATION);
List<SysSystemMappingDto> mappings = systemMappingService.find(mappingFilter, null).getContent();
Assert.assertEquals(1, mappings.size());
SysSystemMappingDto mapping = mappings.get(0);
SysSystemAttributeMappingFilter attributeMappingFilter = new SysSystemAttributeMappingFilter();
attributeMappingFilter.setSystemMappingId(mapping.getId());
List<SysSystemAttributeMappingDto> attributes = schemaAttributeMappingService.find(attributeMappingFilter, null).getContent();
SysSystemAttributeMappingDto emailAttribute = attributes.stream().filter(attribute -> {
return attribute.getName().equalsIgnoreCase(ATTRIBUTE_EMAIL);
}).findFirst().get();
emailAttribute.setStrategyType(AttributeMappingStrategyType.WRITE_IF_NULL);
schemaAttributeMappingService.save(emailAttribute);
//
// Set email on identity ONE to null
IdmIdentityDto one = identityService.getByUsername("x" + IDENTITY_USERNAME_ONE);
one.setEmail(null);
identityService.save(one);
// Prepare resource data
this.getBean().deleteAllResourceData();
this.getBean().initResourceData();
this.getBean().changeResourceData();
// Set sync config
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.CREATE_ENTITY);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom.setReconciliation(true);
syncConfigService.save(syncConfigCustom);
// Check state before sync
Assert.assertEquals(null, identityService.getByUsername("x" + IDENTITY_USERNAME_ONE).getEmail());
Assert.assertEquals(IDENTITY_EMAIL_CORRECT, identityService.getByUsername("x" + IDENTITY_USERNAME_TWO).getEmail());
// Start synchronization
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 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(2, items.size());
// Check state after sync
Assert.assertEquals(IDENTITY_EMAIL_CORRECT_CHANGED, identityService.getByUsername("x" + IDENTITY_USERNAME_ONE).getEmail());
Assert.assertEquals(IDENTITY_EMAIL_CORRECT, identityService.getByUsername("x" + IDENTITY_USERNAME_TWO).getEmail());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter in project CzechIdMng by bcvsolutions.
the class ChangesOnSystemReportExecutor method getAttributesById.
/**
* Get defined attributes for report
*
* @param list of attribute Ids
* @return
*/
private List<SysSystemAttributeMappingDto> getAttributesById(List<UUID> attributeIds, SysSystemMappingDto mapping) {
if (CollectionUtils.isEmpty(attributeIds)) {
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemMappingId(mapping.getId());
filter.setDisabledAttribute(Boolean.FALSE);
//
return systemAttributeMappingService.find(filter, null).getContent();
}
//
return attributeIds.stream().map(systemAttributeMappingService::get).filter(Objects::nonNull).collect(Collectors.toList());
}
Aggregations