Search in sources :

Example 46 with ConnectorTypeDto

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

the class CsvConnectorTypeTest method testReopenSystemInWizard.

@Test
public void testReopenSystemInWizard() {
    ConnectorTypeDto mockCsvConnectorTypeDto = new ConnectorTypeDto();
    mockCsvConnectorTypeDto.setReopened(false);
    mockCsvConnectorTypeDto.setId(CsvConnectorType.NAME);
    mockCsvConnectorTypeDto.setConnectorName(csvConnectorType.getConnectorName());
    ConnectorTypeDto csvConnectorTypeDto = connectorManager.load(mockCsvConnectorTypeDto);
    assertNotNull(csvConnectorTypeDto);
    csvConnectorTypeDto.getMetadata().put(CsvConnectorType.FILE_PATH, CSV_TEST_FILE);
    csvConnectorTypeDto.setWizardStepName(CsvConnectorType.STEP_ONE_CREATE_SYSTEM);
    // Execute the first step.
    ConnectorTypeDto stepExecutedResult = connectorManager.execute(csvConnectorTypeDto);
    // The system had to be created.
    BaseDto system = stepExecutedResult.getEmbedded().get(CsvConnectorType.SYSTEM_DTO_KEY);
    assertTrue(system instanceof SysSystemDto);
    SysSystemDto systemDto = systemService.get(system.getId());
    assertNotNull(systemDto);
    SysSchemaAttributeFilter schemaAttributeFilter = new SysSchemaAttributeFilter();
    schemaAttributeFilter.setSystemId(systemDto.getId());
    schemaAttributeFilter.setName("username");
    SysSchemaAttributeDto usernameAttributeDto = schemaAttributeService.find(schemaAttributeFilter, null).getContent().stream().findFirst().orElse(null);
    assertNotNull(usernameAttributeDto);
    // Set username attribute as primary attribute for second wizard step.
    stepExecutedResult.getMetadata().put(CsvConnectorType.PRIMARY_SCHEMA_ATTRIBUTE, usernameAttributeDto.getId().toString());
    // Execute the second step.
    csvConnectorTypeDto.setWizardStepName(CsvConnectorType.STEP_TWO_SELECT_PK);
    csvConnectorTypeDto.getMetadata().put(CsvConnectorType.SYSTEM_DTO_KEY, systemDto.getId().toString());
    connectorManager.execute(csvConnectorTypeDto);
    // Load wizard data for existed system;
    ConnectorType connectorTypeBySystem = connectorManager.findConnectorTypeBySystem(systemDto);
    ConnectorTypeDto reopenSystem = new ConnectorTypeDto();
    reopenSystem.setReopened(true);
    reopenSystem.setId(connectorTypeBySystem.getId());
    reopenSystem.getEmbedded().put(CsvConnectorType.SYSTEM_DTO_KEY, systemDto);
    reopenSystem = connectorManager.load(reopenSystem);
    assertNotNull(reopenSystem);
    assertEquals(systemDto.getName(), reopenSystem.getMetadata().get(CsvConnectorType.SYSTEM_NAME));
    assertEquals(";", reopenSystem.getMetadata().get(CsvConnectorType.SEPARATOR));
    assertEquals(usernameAttributeDto.getId().toString(), reopenSystem.getMetadata().get(CsvConnectorType.PRIMARY_SCHEMA_ATTRIBUTE));
    // Delete created system.
    systemService.delete(systemDto);
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) CsvConnectorType(eu.bcvsolutions.idm.acc.connector.CsvConnectorType) ConnectorType(eu.bcvsolutions.idm.acc.service.api.ConnectorType) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) 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 47 with ConnectorTypeDto

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

the class CsvConnectorTypeTest method testCsvFirstStep.

@Test
public void testCsvFirstStep() {
    ConnectorTypeDto mockCsvConnectorTypeDto = new ConnectorTypeDto();
    mockCsvConnectorTypeDto.setReopened(false);
    mockCsvConnectorTypeDto.setId(CsvConnectorType.NAME);
    mockCsvConnectorTypeDto.setConnectorName(csvConnectorType.getConnectorName());
    ConnectorTypeDto csvConnectorTypeDto = connectorManager.load(mockCsvConnectorTypeDto);
    assertNotNull(csvConnectorTypeDto);
    csvConnectorTypeDto.getMetadata().put(CsvConnectorType.FILE_PATH, CSV_TEST_FILE);
    csvConnectorTypeDto.setWizardStepName(CsvConnectorType.STEP_ONE_CREATE_SYSTEM);
    // Execute the first step.
    ConnectorTypeDto stepExecutedResult = connectorManager.execute(csvConnectorTypeDto);
    // The system had to be created.
    BaseDto system = stepExecutedResult.getEmbedded().get(CsvConnectorType.SYSTEM_DTO_KEY);
    assertTrue(system instanceof SysSystemDto);
    SysSystemDto systemDto = systemService.get(system.getId());
    assertNotNull(systemDto);
    // Load connector properties from created system.
    IcConnectorInstance connectorInstance = systemService.getConnectorInstance(systemDto);
    assertEquals("eu.bcvsolutions.idm.connectors.csv.CSVConnConnector", connectorInstance.getConnectorKey().getConnectorName());
    IcConnectorConfiguration connectorConfiguration = systemService.getConnectorConfiguration(systemDto);
    IcConfigurationProperties configurationProperties = connectorConfiguration.getConfigurationProperties();
    // Check source path of CSV.
    IcConfigurationProperty sourcePathProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_SOURCE_PATH.equals(property.getName())).findFirst().orElse(null);
    assertNotNull(sourcePathProperty);
    assertEquals(CSV_TEST_FILE.replace('/', '\\'), ((String) sourcePathProperty.getValue()).replace('/', '\\'));
    // Check separator.
    IcConfigurationProperty separatorProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_SOURCE_PATH.equals(property.getName())).findFirst().orElse(null);
    assertNotNull(separatorProperty);
    // Check include headers.
    IcConfigurationProperty includeHeadersProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_INCLUDES_HEADERS.equals(property.getName())).findFirst().orElse(null);
    assertNotNull(includeHeadersProperty);
    // Headers have to be always included in CSV file.
    assertEquals(true, includeHeadersProperty.getValue());
    // Check uid attribute (in first step has value "...random...").
    IcConfigurationProperty uidProperty = configurationProperties.getProperties().stream().filter(property -> CsvConnectorType.CONNECTOR_UID.equals(property.getName())).findFirst().orElse(null);
    assertNotNull(uidProperty);
    // UID attribute have to be filled, but will be selected in the next wizard step -> is use temporary value "...random...".
    assertEquals("...random...", uidProperty.getValue());
    // Delete created system.
    systemService.delete(systemDto);
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) IcConfigurationProperty(eu.bcvsolutions.idm.ic.api.IcConfigurationProperty) IcConnectorInstance(eu.bcvsolutions.idm.ic.api.IcConnectorInstance) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) IcConfigurationProperties(eu.bcvsolutions.idm.ic.api.IcConfigurationProperties) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 48 with ConnectorTypeDto

use of eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto 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 49 with ConnectorTypeDto

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

the class DefaultConnectorManagerTest method testSupportsConnectorTypes.

@Test
public void testSupportsConnectorTypes() {
    String defaultTableConnectorName = "net.tirasa.connid.bundles.db.table.DatabaseTableConnector";
    Resources<ConnectorTypeDto> supportedTypes = systemController.getSupportedTypes();
    // Find connector without connector type (it is default table connector
    // = table connector has tree connector types and one default connector type).
    DefaultConnectorType mockDefaultConnectorType = new DefaultConnectorType();
    ConnectorTypeDto defaultConnectorTypeDto = supportedTypes.getContent().stream().filter(connectorTypeDto -> defaultTableConnectorName.equals(connectorTypeDto.getId())).findFirst().orElse(null);
    assertNotNull(defaultConnectorTypeDto);
    assertEquals(defaultConnectorTypeDto.getIconKey(), mockDefaultConnectorType.getIconKey());
    // Find PostgreSQL connector (table connector has tree connector types and one default connector type).
    ConnectorTypeDto postgresqlConnectorTypeDto = supportedTypes.getContent().stream().filter(connectorTypeDto -> PostgresqlConnectorType.NAME.equals(connectorTypeDto.getId())).findFirst().orElse(null);
    assertNotNull(postgresqlConnectorTypeDto);
    // Find CSV connector type
    ConnectorTypeDto csvConnectorTypeDto = supportedTypes.getContent().stream().filter(connectorTypeDto -> CsvConnectorType.NAME.equals(connectorTypeDto.getId())).findFirst().orElse(null);
    assertNotNull(csvConnectorTypeDto);
}
Also used : ConnectorTypeDto(eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto) DefaultConnectorType(eu.bcvsolutions.idm.acc.connector.DefaultConnectorType) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 50 with ConnectorTypeDto

use of eu.bcvsolutions.idm.acc.dto.ConnectorTypeDto 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)

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