use of io.syndesis.common.model.integration.Step in project syndesis-qe by syndesisio.
the class TwSteps method createTwitterStep.
@Given("^create TW mention step with \"([^\"]*)\" action")
public void createTwitterStep(String twitterAction) {
final Connector twitterConnector = connectorsEndpoint.get("twitter");
final Connection twitterConnection = connectionsEndpoint.get(RestConstants.getInstance().getTWITTER_CONNECTION_ID());
final Action twAction = TestUtils.findConnectorAction(twitterConnector, twitterAction);
final ConnectorDescriptor connectorDescriptor = getConnectorDescriptor(twAction, new HashMap<>(), RestConstants.getInstance().getTWITTER_CONNECTION_ID());
final Step twitterStep = new Step.Builder().stepKind(StepKind.endpoint).connection(twitterConnection).id(UUID.randomUUID().toString()).action(generateStepAction(twAction, connectorDescriptor)).build();
steps.getStepDefinitions().add(new StepDefinition(twitterStep, connectorDescriptor));
}
use of io.syndesis.common.model.integration.Step in project syndesis-qe by syndesisio.
the class UiComplexSteps method dbToDbIntegrationWithPeriodMs.
@Given("^db to db \"([^\"]*)\" integration with period (\\d+) ms$")
public void dbToDbIntegrationWithPeriodMs(String integrationName, int ms) throws IOException {
final Connection dbConnection = connectionsEndpoint.get(getDbConnectionId());
final Connector dbConnector = connectorsEndpoint.get("sql");
final String sqlStartQuery = "SELECT * FROM CONTACT";
final String sqlFinishQuery = "INSERT INTO TODO(task, completed) VALUES (:#TASK, 2)";
final String datamapperTemplate = "db-db.json";
// 1. @Then("^create start DB periodic sql invocation action step with query \"([^\"]*)\" and period \"([^\"]*)\" ms")
final Action dbAction1 = TestUtils.findConnectorAction(dbConnector, "sql-start-connector");
final Map<String, String> properties1 = TestUtils.map("query", sqlStartQuery, "schedulerPeriod", ms);
final ConnectorDescriptor connectorDescriptor1 = getConnectorDescriptor(dbAction1, properties1, dbConnection.getId().get());
// to be reported: period is not part of .json step (when checked via browser).
final Step dbStep1 = new Step.Builder().stepKind(StepKind.endpoint).id(UUID.randomUUID().toString()).connection(dbConnection).action(dbAction1).configuredProperties(properties1).build();
steps.getStepDefinitions().add(new StepDefinition(dbStep1, connectorDescriptor1));
// 2.A @And("start mapper definition with name: \"([^\"]*)\"")
String mapperName = "mapping 1";
final Step mapperStep = new Step.Builder().stepKind(StepKind.mapper).name(mapperName).build();
steps.getStepDefinitions().add(new StepDefinition(mapperStep, new DataMapperDefinition()));
// 2.B @Then("MAP using Step (\\d+) and field \"([^\"]*)\" to \"([^\"]*)\"")
int fromStep = 1;
String fromField = "first_name";
String toField = "TASK";
DataMapperStepDefinition newDmStep = new DataMapperStepDefinition();
newDmStep.setFromStep(fromStep);
newDmStep.setInputFields(Arrays.asList(fromField));
newDmStep.setOutputFields(Arrays.asList(toField));
newDmStep.setMappingType(MappingType.MAP);
newDmStep.setStrategy(null);
steps.getLastStepDefinition().getDataMapperDefinition().get().getDataMapperStepDefinition().add(newDmStep);
// 3. @Then("^create finish DB invoke sql action step with query \"([^\"]*)\"")
final Action dbAction2 = TestUtils.findConnectorAction(dbConnector, "sql-connector");
final Map<String, String> properties2 = TestUtils.map("query", sqlFinishQuery);
final ConnectorDescriptor connectorDescriptor2 = getConnectorDescriptor(dbAction2, properties2, dbConnection.getId().get());
final Step dbStep2 = new Step.Builder().stepKind(StepKind.endpoint).id(UUID.randomUUID().toString()).connection(dbConnection).action(dbAction2).configuredProperties(properties2).build();
steps.getStepDefinitions().add(new StepDefinition(dbStep2, connectorDescriptor2));
// 4. @When("^create integration with name: \"([^\"]*)\"")
processMapperSteps();
Integration integration = new Integration.Builder().steps(steps.getSteps()).name(integrationName).description("Awkward UI integration.").build();
log.info("Creating integration {}", integration.getName());
String integrationId = integrationsEndpoint.create(integration).getId().get();
log.info("Publish integration with ID: {}", integrationId);
publishIntegration(integrationId);
log.debug("Flushing used steps");
steps.flushStepDefinitions();
// 5. @Then("^wait for integration with name: \"([^\"]*)\" to become active")
final List<Integration> integrations = integrationsEndpoint.list().stream().filter(item -> item.getName().equals(integrationName)).collect(Collectors.toList());
final long start = System.currentTimeMillis();
// wait for activation
log.info("Waiting until integration \"{}\" becomes active. This may take a while...", integrationName);
integrationOverviewEndpoint = new IntegrationOverviewEndpoint(integrationId);
final IntegrationOverview integrationOverview = integrationOverviewEndpoint.getOverview();
final boolean activated = TestUtils.waitForPublishing(integrationOverviewEndpoint, integrationOverview, TimeUnit.MINUTES, 10);
Assertions.assertThat(activated).isEqualTo(true);
log.info("Integration pod has been started. It took {}s to build the integration.", TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - start));
}
use of io.syndesis.common.model.integration.Step in project syndesis-qe by syndesisio.
the class UtilitySteps method changeDatashapeTo.
@Given("change {string} datashape of previous step to {string} type with specification {string}")
public void changeDatashapeTo(String direction, String type, String specification) {
Step lastStep = super.getSteps().getLastStepDefinition().getStep();
Step withDatashape = new Step.Builder().createFrom(lastStep).action(super.withCustomDatashape(lastStep.getAction().get(), super.getConnectorDescriptor(lastStep.getAction().get(), lastStep.getConfiguredProperties(), lastStep.getConnection().get().getId().get()), direction, DataShapeKinds.valueOf(type), specification)).build();
StepsStorage steps = super.getSteps();
steps.getStepDefinitions().remove(steps.getStepDefinitions().size() - 1);
steps.getStepDefinitions().add(new StepDefinition(withDatashape));
}
use of io.syndesis.common.model.integration.Step in project syndesis-qe by syndesisio.
the class IntegrationHandler method processMapperSteps.
/**
* This should be updated for more than two steps, when it will work correctly in near future.
*/
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 (StepDefinition mapper : mappers) {
List<StepDefinition> precedingSteps = steps.getStepDefinitions().subList(0, steps.getStepDefinitions().indexOf(mapper));
StepDefinition followingStep = steps.getStepDefinitions().get(steps.getStepDefinitions().indexOf(mapper) + 1);
if (!mapper.getStep().getConfiguredProperties().containsKey("atlasmapping")) {
// TODO(tplevko): fix for more than one preceding step.
amg.setSteps(mapper, precedingSteps, followingStep);
mapper.setStep(amg.getAtlasMappingStep());
}
}
}
}
use of io.syndesis.common.model.integration.Step in project syndesis-qe by syndesisio.
the class IntermediateSteps method addAggregateStep.
@When("add an aggregate step")
public void addAggregateStep() {
Step previousStepWithDatashapes = null;
for (int i = super.getSteps().getSteps().size() - 1; i >= 0; i--) {
Step s = super.getSteps().getSteps().get(i);
if (s.getAction().isPresent() && s.getAction().get().getInputDataShape().isPresent() && s.getAction().get().getOutputDataShape().isPresent()) {
previousStepWithDatashapes = super.getSteps().getSteps().get(i);
break;
}
}
if (previousStepWithDatashapes == null) {
fail("Unable to find previous step with both datashapes set");
}
StepDescriptor sd = stepDescriptorEndpoint.getStepDescriptor("aggregate", previousStepWithDatashapes.getAction().get().getInputDataShape().get(), previousStepWithDatashapes.getAction().get().getOutputDataShape().get());
super.addProperty(StepProperty.KIND, StepKind.aggregate);
super.addProperty(StepProperty.ACTION, super.generateStepAction(previousStepWithDatashapes.getAction().get(), sd));
super.addProperty(StepProperty.STEP_NAME, "Aggregate");
super.createStep();
}
Aggregations