use of io.syndesis.common.model.action.Action in project syndesis-qe by syndesisio.
the class DbSteps method createStartDbPeriodicProcedureStep.
@Then("^create start DB periodic stored procedure invocation action step named \"([^\"]*)\" and period \"([^\"]*)\" ms")
public void createStartDbPeriodicProcedureStep(String procedureName, Integer ms) {
final Connection dbConnection = connectionsEndpoint.get(getDbConnectionId());
final Connector dbConnector = connectorsEndpoint.get("sql");
final Action dbAction = TestUtils.findConnectorAction(dbConnector, "sql-stored-start-connector");
final Map<String, String> properties = TestUtils.map("procedureName", procedureName, "schedulerExpression", ms, "template", "add_lead(VARCHAR ${body[first_and_last_name]}, VARCHAR ${body[company]}, VARCHAR ${body[phone]}, VARCHAR ${body[email]}, " + "VARCHAR ${body[lead_source]}, VARCHAR ${body[lead_status]}, VARCHAR ${body[rating]})");
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));
}
use of io.syndesis.common.model.action.Action in project syndesis-qe by syndesisio.
the class DbSteps method createStartDbPeriodicSqlStep.
@Then("^create start DB periodic sql invocation action step with query \"([^\"]*)\" and period \"([^\"]*)\" ms")
public void createStartDbPeriodicSqlStep(String sqlQuery, Integer ms) {
final Connection dbConnection = connectionsEndpoint.get(getDbConnectionId());
final Connector dbConnector = connectorsEndpoint.get("sql");
final Action dbAction = TestUtils.findConnectorAction(dbConnector, "sql-start-connector");
final Map<String, String> properties = TestUtils.map("query", sqlQuery, "schedulerExpression", ms);
final ConnectorDescriptor connectorDescriptor = getConnectorDescriptor(dbAction, properties, dbConnection.getId().get());
// to be reported: period is not part of .json step (when checked via browser).
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));
}
use of io.syndesis.common.model.action.Action in project syndesis-qe by syndesisio.
the class S3Steps method createS3CopyStep.
@Given("^create S3 copy step with bucket: \"([^\"]*)\"")
public void createS3CopyStep(String bucketName) {
final Connector s3Connector = connectorsEndpoint.get("aws-s3");
final Connection s3Connection = connectionsEndpoint.get(S3BucketNameBuilder.getBucketName(bucketName));
final Action s3PollingAction = TestUtils.findConnectorAction(s3Connector, "aws-s3-copy-object-connector");
final ConnectorDescriptor connectorDescriptor = getConnectorDescriptor(s3PollingAction, new HashMap(), S3BucketNameBuilder.getBucketName(bucketName));
final Step s3Step = new Step.Builder().stepKind(StepKind.endpoint).connection(s3Connection).id(UUID.randomUUID().toString()).action(generateStepAction(s3PollingAction, connectorDescriptor)).build();
steps.getStepDefinitions().add(new StepDefinition(s3Step));
}
use of io.syndesis.common.model.action.Action in project syndesis-qe by syndesisio.
the class SalesforceSteps method createSfStepWithAction.
@Given("^create SF \"([^\"]*)\" action step on field: \"([^\"]*)\"$")
public void createSfStepWithAction(String action, String field) {
final Connector salesforceConnector = connectorsEndpoint.get("salesforce");
final Connection salesforceConnection = connectionsEndpoint.get(RestConstants.getInstance().getSALESFORCE_CONNECTION_ID());
final Action sfAction = TestUtils.findConnectorAction(salesforceConnector, action);
final Map<String, String> properties = TestUtils.map("sObjectName", field);
final ConnectorDescriptor connectorDescriptor = getConnectorDescriptor(sfAction, properties, RestConstants.getInstance().getSALESFORCE_CONNECTION_ID());
final Step salesforceStep = new Step.Builder().stepKind(StepKind.endpoint).id(UUID.randomUUID().toString()).connection(salesforceConnection).action(generateStepAction(sfAction, connectorDescriptor)).configuredProperties(properties).build();
steps.getStepDefinitions().add(new StepDefinition(salesforceStep, connectorDescriptor));
}
use of io.syndesis.common.model.action.Action in project syndesis-qe by syndesisio.
the class AbstractStep method generateStepAction.
// Small hack -> the Action doesn't provide setters for input/output data shape
public Action generateStepAction(Action action, ConnectorDescriptor connectorDescriptor) {
ObjectMapper mapper = new ObjectMapper().registerModules(new Jdk8Module());
Action ts = null;
try {
JSONObject json = new JSONObject(mapper.writeValueAsString(action));
JSONObject inputDataType = new JSONObject(mapper.writeValueAsString(connectorDescriptor.getInputDataShape().get()));
JSONObject outputDataType = new JSONObject(mapper.writeValueAsString(connectorDescriptor.getOutputDataShape().get()));
JSONArray propertyDefinitionSteps = new JSONArray(mapper.writeValueAsString(connectorDescriptor.getPropertyDefinitionSteps()));
json.getJSONObject("descriptor").put("inputDataShape", inputDataType);
json.getJSONObject("descriptor").put("outputDataShape", outputDataType);
json.getJSONObject("descriptor").put("propertyDefinitionSteps", propertyDefinitionSteps);
ts = Json.reader().forType(Action.class).readValue(json.toString());
} catch (IOException ex) {
log.error("Error: " + ex);
}
return ts;
}
Aggregations