Search in sources :

Example 51 with ConnectorTypeDto

use of eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto in project CzechIdMng by bcvsolutions.

the class DefaultConnectorManagerTest method testAutoSyncMappingInWizard.

@Test
public void testAutoSyncMappingInWizard() {
    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);
    connectorTypeDto.getEmbedded().put(AbstractConnectorType.SYSTEM_DTO_KEY, systemDto);
    connectorTypeDto.setReopened(true);
    connectorTypeDto = connectorManager.load(connectorTypeDto);
    // Execute mapping step.
    connectorTypeDto.setReopened(false);
    connectorTypeDto.setWizardStepName(AbstractConnectorType.STEP_MAPPING);
    connectorTypeDto.getMetadata().put(AbstractConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
    connectorTypeDto.getMetadata().put(AbstractConnectorType.OPERATION_TYPE, SystemOperationType.SYNCHRONIZATION.name());
    connectorTypeDto.getMetadata().put(AbstractConnectorType.ENTITY_TYPE, SystemEntityType.IDENTITY.name());
    systemController.executeConnectorType(connectorTypeDto);
    ConnectorTypeDto connectorTypeDtoAfterMappingStep = connectorManager.convertTypeToDto(connectorType);
    connectorTypeDtoAfterMappingStep.getEmbedded().put(AbstractConnectorType.SYSTEM_DTO_KEY, systemDto);
    connectorTypeDtoAfterMappingStep.setReopened(true);
    connectorTypeDtoAfterMappingStep = connectorManager.load(connectorTypeDtoAfterMappingStep);
    // Sync mapping must exist.
    BaseDto mapping = connectorTypeDtoAfterMappingStep.getEmbedded().get(AbstractConnectorType.MAPPING_DTO_KEY);
    Assert.assertTrue(mapping instanceof SysSystemMappingDto);
    SysSystemMappingDto syncMapping = (SysSystemMappingDto) mapping;
    Assert.assertSame(SystemOperationType.SYNCHRONIZATION, syncMapping.getOperationType());
    // 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());
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) AbstractConnectorType(eu.bcvsolutions.idm.acc.connector.AbstractConnectorType) CsvConnectorType(eu.bcvsolutions.idm.acc.connector.CsvConnectorType) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) PostgresqlConnectorType(eu.bcvsolutions.idm.acc.connector.PostgresqlConnectorType) DefaultConnectorType(eu.bcvsolutions.idm.acc.connector.DefaultConnectorType) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

ConnectorTypeDto (eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto)51 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)43 Test (org.junit.Test)36 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)34 ConnectorType (eu.bcvsolutions.idm.acc.service.api.ConnectorType)33 MockAdUserConnectorType (eu.bcvsolutions.idm.acc.service.impl.mock.MockAdUserConnectorType)22 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)18 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)16 AdGroupConnectorType (eu.bcvsolutions.idm.acc.connector.AdGroupConnectorType)14 MockAdGroupConnectorType (eu.bcvsolutions.idm.acc.service.impl.mock.MockAdGroupConnectorType)14 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)13 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)11 AbstractConnectorType (eu.bcvsolutions.idm.acc.connector.AbstractConnectorType)8 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)8 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)8 CsvConnectorType (eu.bcvsolutions.idm.acc.connector.CsvConnectorType)7 DefaultConnectorType (eu.bcvsolutions.idm.acc.connector.DefaultConnectorType)7 PostgresqlConnectorType (eu.bcvsolutions.idm.acc.connector.PostgresqlConnectorType)7 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)7 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)7