Search in sources :

Example 1 with IndexOf

use of io.atlasmap.v2.IndexOf in project syndesis-qe by syndesisio.

the class UiComplexSteps method processMapperSteps.

private void processMapperSteps() {
    List<StepDefinition> mappers = steps.getStepDefinitions().stream().filter(s -> s.getStep().getStepKind().equals(StepKind.mapper)).collect(Collectors.toList());
    if (mappers.isEmpty()) {
        log.debug("There are no mappers in this integration, proceeding...");
    } else {
        // mapping can be done on steps that preceed mapper step and the single step, which follows the mapper step.
        log.info("Found mapper step, creating new atlas mapping.");
        for (int i = 0; i < mappers.size(); i++) {
            List<StepDefinition> precedingSteps = steps.getStepDefinitions().subList(0, steps.getStepDefinitions().indexOf(mappers.get(i))).stream().filter(s -> s.getConnectorDescriptor().isPresent()).collect(Collectors.toList());
            StepDefinition followingStep = steps.getStepDefinitions().get(steps.getStepDefinitions().indexOf(mappers.get(i)) + 1);
            if (mappers.get(i).getStep().getConfiguredProperties().containsKey("atlasmapping")) {
                // TODO(tplevko): think of some way to substitute placeholders for the step ID's
                reflectStepIdsInAtlasMapping(mappers.get(i), precedingSteps, followingStep);
            } else {
                // TODO(tplevko): fix for more than one preceding step.
                mappers.get(i).setStep(atlasGenerator.getAtlasMappingStep(mappers.get(i), precedingSteps, followingStep));
            }
        }
    }
}
Also used : ConnectorDescriptor(io.syndesis.common.model.action.ConnectorDescriptor) Arrays(java.util.Arrays) Action(io.syndesis.common.model.action.Action) Step(io.syndesis.common.model.integration.Step) Autowired(org.springframework.beans.factory.annotation.Autowired) MappingType(io.atlasmap.v2.MappingType) ConnectorsEndpoint(io.syndesis.qe.endpoints.ConnectorsEndpoint) DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) IntegrationsDeploymentEndpoint(io.syndesis.qe.endpoints.IntegrationsDeploymentEndpoint) Connection(io.syndesis.common.model.connection.Connection) Map(java.util.Map) Given(cucumber.api.java.en.Given) Assertions(org.assertj.core.api.Assertions) StepKind(io.syndesis.common.model.integration.StepKind) Integration(io.syndesis.common.model.integration.Integration) ConnectionsEndpoint(io.syndesis.qe.endpoints.ConnectionsEndpoint) Connector(io.syndesis.common.model.connection.Connector) AtlasMapperGenerator(io.syndesis.qe.bdd.datamapper.AtlasMapperGenerator) IOException(java.io.IOException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IntegrationOverview(io.syndesis.qe.model.IntegrationOverview) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) IntegrationsEndpoint(io.syndesis.qe.endpoints.IntegrationsEndpoint) TestUtils(io.syndesis.qe.utils.TestUtils) DataMapperDefinition(io.syndesis.qe.bdd.entities.DataMapperDefinition) StepsStorage(io.syndesis.qe.bdd.storage.StepsStorage) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) IntegrationOverviewEndpoint(io.syndesis.qe.endpoints.IntegrationOverviewEndpoint) DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) ConnectorsEndpoint(io.syndesis.qe.endpoints.ConnectorsEndpoint) IntegrationsDeploymentEndpoint(io.syndesis.qe.endpoints.IntegrationsDeploymentEndpoint) ConnectionsEndpoint(io.syndesis.qe.endpoints.ConnectionsEndpoint) IntegrationsEndpoint(io.syndesis.qe.endpoints.IntegrationsEndpoint) IntegrationOverviewEndpoint(io.syndesis.qe.endpoints.IntegrationOverviewEndpoint)

Example 2 with IndexOf

use of io.atlasmap.v2.IndexOf in project atlasmap by atlasmap.

the class DefaultAtlasFieldActionsServiceTest method testFindActionDetail.

@Test
public void testFindActionDetail() {
    ActionDetail actionDetail = fieldActionsService.findActionDetail("IndexOf", FieldType.STRING);
    assertNotNull(actionDetail);
    actionDetail = fieldActionsService.findActionDetail("Index", FieldType.STRING);
    assertNull(actionDetail);
    ActionDetail ad = new ActionDetail();
    ad.setName("IndexOf");
    ad.setSourceType(FieldType.INTEGER);
    fieldActionsService.listActionDetails().add(ad);
    actionDetail = fieldActionsService.findActionDetail("IndexOf", null);
    assertNotNull(actionDetail);
    actionDetail = fieldActionsService.findActionDetail("IndexOf", FieldType.STRING);
    assertNotNull(actionDetail);
    actionDetail = fieldActionsService.findActionDetail("IndexOf", FieldType.ANY);
    assertNotNull(actionDetail);
    actionDetail = fieldActionsService.findActionDetail("IndexOf", FieldType.NONE);
    assertNotNull(actionDetail);
    actionDetail = fieldActionsService.findActionDetail("IndexOf", FieldType.BOOLEAN);
    assertNotNull(actionDetail);
}
Also used : ActionDetail(io.atlasmap.v2.ActionDetail) Test(org.junit.Test)

Example 3 with IndexOf

use of io.atlasmap.v2.IndexOf in project atlasmap by atlasmap.

the class StringComplexFieldActionsTest method testIndexOf.

@Test
public void testIndexOf() {
    IndexOf action = new IndexOf();
    action.setString("");
    assertEquals(-1, StringComplexFieldActions.indexOf(action, null));
    assertEquals(0, StringComplexFieldActions.indexOf(action, ""));
    assertEquals(0, StringComplexFieldActions.indexOf(action, "foo"));
    action.setString("bar");
    assertEquals(-1, StringComplexFieldActions.indexOf(action, null));
    assertEquals(-1, StringComplexFieldActions.indexOf(action, ""));
    assertEquals(-1, StringComplexFieldActions.indexOf(action, "foo"));
    assertEquals(3, StringComplexFieldActions.indexOf(action, "foobar"));
    assertEquals(3, StringComplexFieldActions.indexOf(action, "foobarbar"));
}
Also used : IndexOf(io.atlasmap.v2.IndexOf) LastIndexOf(io.atlasmap.v2.LastIndexOf) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Given (cucumber.api.java.en.Given)1 ActionDetail (io.atlasmap.v2.ActionDetail)1 IndexOf (io.atlasmap.v2.IndexOf)1 LastIndexOf (io.atlasmap.v2.LastIndexOf)1 MappingType (io.atlasmap.v2.MappingType)1 Action (io.syndesis.common.model.action.Action)1 ConnectorDescriptor (io.syndesis.common.model.action.ConnectorDescriptor)1 Connection (io.syndesis.common.model.connection.Connection)1 Connector (io.syndesis.common.model.connection.Connector)1 Integration (io.syndesis.common.model.integration.Integration)1 Step (io.syndesis.common.model.integration.Step)1 StepKind (io.syndesis.common.model.integration.StepKind)1 AtlasMapperGenerator (io.syndesis.qe.bdd.datamapper.AtlasMapperGenerator)1 DataMapperDefinition (io.syndesis.qe.bdd.entities.DataMapperDefinition)1 DataMapperStepDefinition (io.syndesis.qe.bdd.entities.DataMapperStepDefinition)1 StepDefinition (io.syndesis.qe.bdd.entities.StepDefinition)1 StepsStorage (io.syndesis.qe.bdd.storage.StepsStorage)1 ConnectionsEndpoint (io.syndesis.qe.endpoints.ConnectionsEndpoint)1 ConnectorsEndpoint (io.syndesis.qe.endpoints.ConnectorsEndpoint)1