Search in sources :

Example 56 with ConnectorType

use of eu.bcvsolutions.idm.acc.service.api.ConnectorType in project CzechIdMng by bcvsolutions.

the class DefaultConnectorManagerTest method testFinishStep.

@Test
public void testFinishStep() {
    SysSystemDto systemDto = helper.createTestResourceSystem(true);
    ConnectorType connectorType = connectorManager.findConnectorTypeBySystem(systemDto);
    Assert.assertEquals(DefaultConnectorType.NAME, connectorType.getConnectorName());
    ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
    connectorTypeDto.getEmbedded().put(AbstractConnectorType.SYSTEM_DTO_KEY, systemDto);
    connectorTypeDto.setReopened(true);
    connectorTypeDto = connectorManager.load(connectorTypeDto);
    // One mapping already exists.
    BaseDto mapping = connectorTypeDto.getEmbedded().get(AbstractConnectorType.MAPPING_DTO_KEY);
    Assert.assertTrue(mapping instanceof SysSystemMappingDto);
    // Execute finish step.
    String roleName = getHelper().createName();
    connectorTypeDto.setReopened(false);
    connectorTypeDto.getMetadata().put(AbstractConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
    connectorTypeDto.getMetadata().put(AbstractConnectorType.MAPPING_ID, mapping.getId().toString());
    connectorTypeDto.setWizardStepName(AbstractConnectorType.STEP_FINISH);
    connectorTypeDto.getMetadata().put(AbstractConnectorType.NEW_ROLE_WITH_SYSTEM_CODE, roleName);
    connectorTypeDto.getMetadata().put(AbstractConnectorType.CREATES_ROLE_WITH_SYSTEM, Boolean.TRUE.toString());
    systemController.executeConnectorType(connectorTypeDto);
    // A new role-system was to be created.
    SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
    roleSystemFilter.setSystemId(systemDto.getId());
    List<SysRoleSystemDto> roleSystemDtos = roleSystemService.find(roleSystemFilter, null).getContent();
    Assert.assertEquals(1, roleSystemDtos.size());
    IdmRoleDto roleDto = (IdmRoleDto) roleSystemDtos.get(0).getEmbedded().get(SysRoleSystem_.role.getName());
    Assert.assertEquals(roleName, roleDto.getBaseCode());
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) SysRoleSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) 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) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) 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)

Example 57 with ConnectorType

use of eu.bcvsolutions.idm.acc.service.api.ConnectorType in project CzechIdMng by bcvsolutions.

the class DefaultConnectorManagerTest method testMappingStep.

@Test
public void testMappingStep() {
    SysSystemDto systemDto = helper.createTestResourceSystem(true);
    ConnectorType connectorType = connectorManager.findConnectorTypeBySystem(systemDto);
    Assert.assertEquals(DefaultConnectorType.NAME, connectorType.getConnectorName());
    ConnectorTypeDto connectorTypeDto = connectorManager.convertTypeToDto(connectorType);
    connectorTypeDto.getEmbedded().put(AbstractConnectorType.SYSTEM_DTO_KEY, systemDto);
    connectorTypeDto.setReopened(true);
    connectorTypeDto = connectorManager.load(connectorTypeDto);
    // One mapping already exists.
    BaseDto mapping = connectorTypeDto.getEmbedded().get(AbstractConnectorType.MAPPING_DTO_KEY);
    Assert.assertTrue(mapping instanceof SysSystemMappingDto);
    // Only one mapping exists now.
    String moreMappings = connectorTypeDto.getMetadata().get(AbstractConnectorType.ALERT_MORE_MAPPINGS);
    Assert.assertNull(moreMappings);
    // Execute mapping step.
    connectorTypeDto.setReopened(false);
    connectorTypeDto.setWizardStepName(AbstractConnectorType.STEP_MAPPING);
    connectorTypeDto.getMetadata().put(AbstractConnectorType.SCHEMA_ID, ((SysSystemMappingDto) mapping).getObjectClass().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);
    // Two mappings have to exists now.
    moreMappings = connectorTypeDtoAfterMappingStep.getMetadata().get(AbstractConnectorType.ALERT_MORE_MAPPINGS);
    Assert.assertEquals(Boolean.TRUE.toString(), moreMappings);
}
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) 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)

Example 58 with ConnectorType

use of eu.bcvsolutions.idm.acc.service.api.ConnectorType 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

ConnectorType (eu.bcvsolutions.idm.acc.service.api.ConnectorType)58 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)56 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)45 Test (org.junit.Test)45 ConnectorTypeDto (eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto)41 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)25 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)24 MockAdUserConnectorType (eu.bcvsolutions.idm.acc.service.impl.mock.MockAdUserConnectorType)22 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)19 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)19 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)18 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)17 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)16 SysRoleSystemDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto)16 SysRoleSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter)16 MockCrossDomainAdUserConnectorType (eu.bcvsolutions.idm.acc.service.impl.mock.MockCrossDomainAdUserConnectorType)16 UUID (java.util.UUID)16 ProvisioningAttributeDto (eu.bcvsolutions.idm.acc.dto.ProvisioningAttributeDto)15 AdGroupConnectorType (eu.bcvsolutions.idm.acc.connector.AdGroupConnectorType)14 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)14