Search in sources :

Example 11 with StepDefinition

use of io.syndesis.qe.bdd.entities.StepDefinition 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 12 with StepDefinition

use of io.syndesis.qe.bdd.entities.StepDefinition in project syndesis-qe by syndesisio.

the class AtlasMapperGenerator method generateSeparateMapping.

private Mapping generateSeparateMapping(DataMapperStepDefinition mappingDef, List<StepDefinition> precedingSteps, StepDefinition followingStep) {
    StepDefinition fromStep = precedingSteps.get(mappingDef.getFromStep() - 1);
    Mapping generatedMapping = new Mapping();
    generatedMapping.setId(UUID.randomUUID().toString());
    generatedMapping.setMappingType(MappingType.SEPARATE);
    generatedMapping.setDelimiter(mappingDef.getStrategy().name());
    List<Field> out = new ArrayList<>();
    for (int i = 0; i < mappingDef.getOutputFields().size(); i++) {
        String def = mappingDef.getOutputFields().get(i);
        Field outField = followingStep.getInspectionResponseFields().get().stream().filter(f -> f.getPath().matches(def)).findFirst().get();
        outField.setIndex(i);
        out.add(outField);
    }
    Field in = fromStep.getInspectionResponseFields().get().stream().filter(f -> f.getPath().matches(mappingDef.getInputFields().get(0))).findFirst().get();
    out.forEach(f -> f.setDocId(followingStep.getStep().getId().get()));
    in.setDocId(fromStep.getStep().getId().get());
    generatedMapping.getOutputField().addAll(out);
    generatedMapping.getInputField().add(in);
    return generatedMapping;
}
Also used : Field(io.atlasmap.v2.Field) JavaField(io.atlasmap.java.v2.JavaField) ArrayList(java.util.ArrayList) DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) AtlasmapEndpoint(io.syndesis.qe.endpoints.AtlasmapEndpoint)

Example 13 with StepDefinition

use of io.syndesis.qe.bdd.entities.StepDefinition in project syndesis-qe by syndesisio.

the class AtlasMapperGenerator method generateMapMapping.

private Mapping generateMapMapping(DataMapperStepDefinition mappingDef, List<StepDefinition> precedingSteps, StepDefinition followingStep) {
    StepDefinition fromStep = precedingSteps.get(mappingDef.getFromStep() - 1);
    Mapping generatedMapping = new Mapping();
    generatedMapping.setId(UUID.randomUUID().toString());
    generatedMapping.setMappingType(MappingType.MAP);
    Field in = fromStep.getInspectionResponseFields().get().stream().filter(f -> f.getPath().matches(mappingDef.getInputFields().get(0))).findFirst().get();
    Field out = followingStep.getInspectionResponseFields().get().stream().filter(f -> f.getPath().matches(mappingDef.getOutputFields().get(0))).findFirst().get();
    in.setDocId(fromStep.getStep().getId().get());
    out.setDocId(followingStep.getStep().getId().get());
    generatedMapping.getInputField().add(in);
    generatedMapping.getOutputField().add(out);
    return generatedMapping;
}
Also used : Field(io.atlasmap.v2.Field) JavaField(io.atlasmap.java.v2.JavaField) DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping)

Example 14 with StepDefinition

use of io.syndesis.qe.bdd.entities.StepDefinition in project syndesis-qe by syndesisio.

the class DataMapperStep method createMapperStep.

/**
 * Step used for import of mapping json files. The step definition must contain a json file name, located in folder:
 * "resources/mappings"
 *
 * @param templateName
 * @throws IOException
 */
@Given("^create mapper step using template: \"([^\"]*)\"")
public void createMapperStep(String templateName) throws IOException {
    final String mapping = new String(Files.readAllBytes(Paths.get("./target/test-classes/mappings/" + templateName + ".json")));
    final Step mapperStep = new Step.Builder().stepKind(StepKind.mapper).configuredProperties(TestUtils.map("atlasmapping", mapping)).build();
    steps.getStepDefinitions().add(new StepDefinition(mapperStep));
}
Also used : DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) Step(io.syndesis.common.model.integration.Step) Given(cucumber.api.java.en.Given)

Example 15 with StepDefinition

use of io.syndesis.qe.bdd.entities.StepDefinition in project syndesis-qe by syndesisio.

the class DbSteps method createFinishDbInvokeSqlStep.

@Then("^create finish DB invoke sql action step with query \"([^\"]*)\"")
public void createFinishDbInvokeSqlStep(String sqlQuery) {
    final Connection dbConnection = connectionsEndpoint.get(getDbConnectionId());
    final Connector dbConnector = connectorsEndpoint.get("sql");
    final Action dbAction = TestUtils.findConnectorAction(dbConnector, "sql-connector");
    final Map<String, String> properties = TestUtils.map("query", sqlQuery);
    final ConnectorDescriptor connectorDescriptor = getConnectorDescriptor(dbAction, properties, dbConnection.getId().get());
    final Step dbStep = new Step.Builder().stepKind(StepKind.endpoint).id(UUID.randomUUID().toString()).connection(dbConnection).action(generateStepAction(dbAction, connectorDescriptor)).configuredProperties(properties).build();
    steps.getStepDefinitions().add(new StepDefinition(dbStep, connectorDescriptor));
}
Also used : Connector(io.syndesis.common.model.connection.Connector) ConnectorDescriptor(io.syndesis.common.model.action.ConnectorDescriptor) Action(io.syndesis.common.model.action.Action) Connection(io.syndesis.common.model.connection.Connection) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) Step(io.syndesis.common.model.integration.Step) AbstractStep(io.syndesis.qe.bdd.AbstractStep) Then(cucumber.api.java.en.Then)

Aggregations

StepDefinition (io.syndesis.qe.bdd.entities.StepDefinition)23 Step (io.syndesis.common.model.integration.Step)17 Connection (io.syndesis.common.model.connection.Connection)13 Connector (io.syndesis.common.model.connection.Connector)13 Action (io.syndesis.common.model.action.Action)11 ConnectorDescriptor (io.syndesis.common.model.action.ConnectorDescriptor)11 Given (cucumber.api.java.en.Given)10 AbstractStep (io.syndesis.qe.bdd.AbstractStep)9 DataMapperStepDefinition (io.syndesis.qe.bdd.entities.DataMapperStepDefinition)9 And (cucumber.api.java.en.And)4 Then (cucumber.api.java.en.Then)4 JavaField (io.atlasmap.java.v2.JavaField)3 AtlasMapping (io.atlasmap.v2.AtlasMapping)3 BaseMapping (io.atlasmap.v2.BaseMapping)3 Field (io.atlasmap.v2.Field)3 Mapping (io.atlasmap.v2.Mapping)3 Integration (io.syndesis.common.model.integration.Integration)3 StepKind (io.syndesis.common.model.integration.StepKind)3 AtlasMapperGenerator (io.syndesis.qe.bdd.datamapper.AtlasMapperGenerator)3 DataMapperDefinition (io.syndesis.qe.bdd.entities.DataMapperDefinition)3