@Test public void testSanitizeConnectors() { TestResourceManager resourceManager = new TestResourceManager(); resourceManager.put(TestConstants.TIMER_CONNECTOR.getId().get(), TestConstants.TIMER_CONNECTOR); Integration source = resourceManager.newIntegration( new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id("timer-connection") .connectorId(TestConstants.TIMER_CONNECTOR.getId().get()) .build()) .putConfiguredProperty("period", "5000") .action(TestConstants.PERIODIC_TIMER_ACTION) .build() ); final Optional<Connection> unsanitizedConnection = source.getFlows().get(0).getSteps().get(0).getConnection(); assertThat(unsanitizedConnection.isPresent()).isTrue(); assertThat(unsanitizedConnection.get().getConnector().isPresent()).isFalse(); Integration sanitized = ProjectGeneratorHelper.sanitize(source, resourceManager); final Optional<Connection> sanitizedConnection = sanitized.getFlows().get(0).getSteps().get(0).getConnection(); assertThat(sanitizedConnection.isPresent()).isTrue(); assertThat(sanitizedConnection.get().getConnector().isPresent()).isTrue(); assertThat(sanitizedConnection.get().getConnector().get()).isEqualTo(TestConstants.TIMER_CONNECTOR); }
TestIntegrationBulder withFlowStepsUsingConnections(final Connection... connections) { return (TestIntegrationBulder) addFlow( new Flow.Builder().addAllSteps(Arrays.stream(connections).map(c -> new Step.Builder().connection(c).build()).collect(Collectors.toList())).build()); }
protected final Step newEndpointStep(String connectorId, String actionId, Consumer<Connection.Builder> connectionConsumer, Consumer<Step.Builder> stepConsumer) { Connector connector = resourceManager.mandatoryLoadConnector(connectorId); ConnectorAction action = resourceManager.mandatoryLookupAction(connector, actionId); Connection.Builder connectionBuilder = new Connection.Builder().connector(connector); connectionConsumer.accept(connectionBuilder); Step.Builder stepBuilder = new Step.Builder().stepKind(StepKind.endpoint).action(action).connection(connectionBuilder.build()); stepConsumer.accept(stepBuilder); return stepBuilder.build(); }
new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id("timer-connection") .connector(TestConstants.TIMER_CONNECTOR) new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id("http-connection") .connector(TestConstants.HTTP_CONNECTOR)
.id(KeyGenerator.createKey()) .action(modifiedStartAction) .connection(template.getConnection()) .stepKind(StepKind.endpoint) .putConfiguredProperty("name", operationId) .id(KeyGenerator.createKey()) .action(modifiedEndAction) .connection(template.getConnection()) .stepKind(StepKind.endpoint) .putConfiguredProperty("httpResponseCode", "501")
.connection(new Connection.Builder() .id(KeyGenerator.createKey()) .connector(oldConnector) Step s2 = new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id(KeyGenerator.createKey()) .connector(newConnector)
.addStep(new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .putConfiguredProperty("accessKey", "my-accessKey") .putConfiguredProperty("secretKey", "my-secretKey")
.build()) .build()) .connection(new Connection.Builder() .connector(new Connector.Builder() .build()) .build()) .build()) .connection(new Connection.Builder() .connector(new Connector.Builder() .componentScheme("file").build()) .build()) .build()) .connection(new Connection.Builder() .connector(new Connector.Builder() .build())
.connection(modSqlConnection) .build();
.build()) .build()) .connection(new Connection.Builder() .connector( new Connector.Builder()
.connection(modSqlConnection) .build();
.stepKind(StepKind.endpoint) .action(TWITTER_MENTION_ACTION) .connection( new Connection.Builder() .connector(TWITTER_CONNECTOR)
@Test public void testSanitizeScheduler() { TestResourceManager resourceManager = new TestResourceManager(); Integration source = resourceManager.newIntegration( new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id("timer-connection") .connector(TestConstants.HTTP_CONNECTOR) .build()) .putConfiguredProperty("schedulerType", "timer") .putConfiguredProperty("schedulerExpression", "1s") .action(TestConstants.HTTP_GET_ACTION) .build() ); assertThat(source.getFlows().get(0).getScheduler().isPresent()).isFalse(); Integration sanitized = ProjectGeneratorHelper.sanitize(source, resourceManager); final Flow sanitizedFlow = sanitized.getFlows().get(0); assertThat(sanitizedFlow.getScheduler().isPresent()).isTrue(); assertThat(sanitizedFlow.getScheduler().get()).hasFieldOrPropertyWithValue("type", Scheduler.Type.timer); assertThat(sanitizedFlow.getScheduler().get()).hasFieldOrPropertyWithValue("expression", "1s"); assertThat(sanitizedFlow.getSteps().get(0).getStepKind()).isEqualTo(StepKind.endpoint); assertThat(sanitizedFlow.getSteps().get(0).getConfiguredProperties()).doesNotContainKey("scheduler-type"); assertThat(sanitizedFlow.getSteps().get(0).getConfiguredProperties()).doesNotContainKey("scheduler-expression"); }
@Test public void testSanitizeDefaultScheduler() { TestResourceManager resourceManager = new TestResourceManager(); Integration source = resourceManager.newIntegration( new Step.Builder() .stepKind(StepKind.endpoint) .connection(new Connection.Builder() .id("timer-connection") .connector(TestConstants.HTTP_CONNECTOR) .build()) .putConfiguredProperty("schedulerExpression", "1s") .action(TestConstants.HTTP_GET_ACTION) .build() ); assertThat(source.getFlows().get(0).getScheduler().isPresent()).isFalse(); Integration sanitized = ProjectGeneratorHelper.sanitize(source, resourceManager); final Flow sanitizedFlow = sanitized.getFlows().get(0); assertThat(sanitizedFlow.getScheduler().isPresent()).isTrue(); assertThat(sanitizedFlow.getScheduler().get()).hasFieldOrPropertyWithValue("type", Scheduler.Type.timer); assertThat(sanitizedFlow.getScheduler().get()).hasFieldOrPropertyWithValue("expression", "1s"); assertThat(sanitizedFlow.getSteps().get(0).getStepKind()).isEqualTo(StepKind.endpoint); assertThat(sanitizedFlow.getSteps().get(0).getConfiguredProperties()).doesNotContainKey("scheduler-type"); assertThat(sanitizedFlow.getSteps().get(0).getConfiguredProperties()).doesNotContainKey("scheduler-expression"); }
protected Step newSqlEndpointStep(String actionId, Consumer<Step.Builder> stepConsumer, Consumer<ConnectorDescriptor.Builder> descriptorConsumer) { final Connector connector = getResourceManager().mandatoryLoadConnector("sql"); final ConnectorAction action = getResourceManager().mandatoryLookupAction(connector, actionId); final ConnectorDescriptor.Builder descriptorBuilder = new ConnectorDescriptor.Builder().createFrom(action.getDescriptor()); descriptorConsumer.accept(descriptorBuilder); final Step.Builder builder = new Step.Builder() .stepKind(StepKind.endpoint) .action(new ConnectorAction.Builder().createFrom(action).descriptor(descriptorBuilder.build()).build()) .connection(new io.syndesis.common.model.connection.Connection.Builder() .connector(connector) .putConfiguredProperty("user", db.properties.getProperty("sql-connector.user")) .putConfiguredProperty("password", db.properties.getProperty("sql-connector.password")) .putConfiguredProperty("url", db.properties.getProperty("sql-connector.url")) .build()); stepConsumer.accept(builder); return builder.build(); } }
private Step newSqlStep(Connection connection) { ConnectorAction action = new ConnectorAction.Builder() .actionType("connector") .id(SQL_CONNECTOR_ACTION_ID) .name("Invoke SQL") .pattern(Pattern.To) .addTag("dynamic") .build(); return new Step.Builder() .connection(connection) .id("SomeLongId") .action(action) .build(); }
protected Step newSqlEndpointStep(String actionId, Consumer<Step.Builder> consumer) { final Connector connector = getResourceManager().mandatoryLoadConnector("sql"); final ConnectorAction action = getResourceManager().mandatoryLookupAction(connector, actionId); final Step.Builder builder = new Step.Builder() .stepKind(StepKind.endpoint) .action(action) .connection(new io.syndesis.common.model.connection.Connection.Builder() .connector(connector) .putConfiguredProperty("user", db.properties.getProperty("sql-connector.user")) .putConfiguredProperty("password", db.properties.getProperty("sql-connector.password")) .putConfiguredProperty("url", db.properties.getProperty("sql-connector.url")) .build()); consumer.accept(builder); return builder.build(); }