use of io.syndesis.common.model.integration.Integration in project syndesis-qe by syndesisio.
the class RestTestHooks method afterTest.
@After
public void afterTest() {
stepStorage.flushStepDefinitions();
log.debug("Flushed steps from steps storage");
SampleDbConnectionManager.closeConnections();
if (TestConfiguration.isDeloreanEnvironment()) {
// delete all integrations and connections after the test. Only for Delorean since it doesn't support TEST_SUPPORT env
List<Integration> integrations = integrationsEndpoint.list();
for (Integration integration : integrations) {
integrationsEndpoint.delete(integration.getId().get());
}
List<Connection> connections = connectionsEndpoint.list();
for (Connection connection : connections) {
if (SyndesisDB.DEFAULT_PSQL_CONNECTION_ORIGINAL.equals(connection.getName()) || SyndesisDB.DEFAULT_PSQL_CONNECTION_BACKUP.equals(connection.getName()) || // for default connections (Webhook, Log, Flow, Timer, Api Provider etc.) We don't want to delete them
connection.getTags().isEmpty()) {
continue;
}
connectionsEndpoint.delete(connection.getId().get());
}
}
}
use of io.syndesis.common.model.integration.Integration in project syndesis-qe by syndesisio.
the class CommonValidationSteps method verifyWarningOnIntegration.
@Then("check that integration {word} contains warning {string}")
public void verifyWarningOnIntegration(String integrationName, String warning) {
IntegrationOverview overview = integrationOverviewEndpoint.getOverview(integrationsEndpoint.getIntegrationId(integrationName).get());
Assertions.assertThat(integrationOverviewEndpoint.getOverview(integrationsEndpoint.getIntegrationId(integrationName).get()).getBoard().getWarnings().getAsInt()).isGreaterThan(0);
Assertions.assertThat(overview.getBoard().getMessages().stream().filter(leveledMessage -> leveledMessage.getDetail().get().contains(warning)).findFirst()).isNotEmpty();
}
use of io.syndesis.common.model.integration.Integration in project syndesis by syndesisio.
the class ProjectGeneratorHelper method sanitize.
public static Integration sanitize(Integration integration, IntegrationResourceManager resourceManager) {
final List<Step> steps = new ArrayList<>(integration.getSteps());
if (steps.isEmpty()) {
return integration;
}
for (int i = 0; i < steps.size(); i++) {
final Step source = steps.get(i);
if (source.getConnection().isPresent()) {
final Connection connection = source.getConnection().get();
// If connector is not set, fetch it from data source and update connection
if (!connection.getConnector().isPresent()) {
Connector connector = resourceManager.loadConnector(connection.getConnectorId()).orElseThrow(() -> new IllegalArgumentException("Unable to fetch connector: " + connection.getConnectorId()));
// Add missing connector to connection.
Connection newConnection = new Connection.Builder().createFrom(connection).connector(connector).build();
// Replace with the new 'sanitized' step
steps.set(i, new Step.Builder().createFrom(source).connection(newConnection).build());
}
}
}
final Integration.Builder builder = new Integration.Builder().createFrom(integration);
// is fully implemented and schedule options are set on integration.
if (!integration.getScheduler().isPresent()) {
Map<String, String> properties = new HashMap<>(steps.get(0).getConfiguredProperties());
String type = properties.remove("schedulerType");
String expr = properties.remove("schedulerExpression");
if (StringUtils.isNotEmpty(expr)) {
if (StringUtils.isEmpty(type)) {
type = "timer";
}
builder.scheduler(new Scheduler.Builder().type(Scheduler.Type.valueOf(type)).expression(expr).build());
}
// Replace first step so underlying connector won't fail uri param
// validation if schedule options were set.
steps.set(0, new Step.Builder().createFrom(steps.get(0)).configuredProperties(properties).build());
}
return builder.steps(steps).build();
}
use of io.syndesis.common.model.integration.Integration in project syndesis by syndesisio.
the class ProjectGeneratorHelperTest method testSanitizeScheduler.
@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.getScheduler().isPresent()).isFalse();
Integration sanitized = ProjectGeneratorHelper.sanitize(source, resourceManager);
assertThat(sanitized.getScheduler().isPresent()).isTrue();
assertThat(sanitized.getScheduler().get()).hasFieldOrPropertyWithValue("type", Scheduler.Type.timer);
assertThat(sanitized.getScheduler().get()).hasFieldOrPropertyWithValue("expression", "1s");
assertThat(sanitized.getSteps().get(0).getStepKind()).isEqualTo(StepKind.endpoint);
assertThat(sanitized.getSteps().get(0).getConfiguredProperties()).doesNotContainKey("scheduler-type");
assertThat(sanitized.getSteps().get(0).getConfiguredProperties()).doesNotContainKey("scheduler-expression");
}
use of io.syndesis.common.model.integration.Integration in project syndesis by syndesisio.
the class ProjectGeneratorTest method testGenerateApplicationProperties.
@Test
public void testGenerateApplicationProperties() throws IOException {
// ******************
// OLD STYLE
// ******************
final ConnectorAction oldAction = new ConnectorAction.Builder().id(KeyGenerator.createKey()).descriptor(new ConnectorDescriptor.Builder().connectorId("old").camelConnectorPrefix("old").build()).build();
final Connector oldConnector = new Connector.Builder().id("old").addAction(oldAction).putProperty("username", new ConfigurationProperty.Builder().componentProperty(false).secret(true).build()).putProperty("password", new ConfigurationProperty.Builder().componentProperty(false).secret(true).build()).putProperty("token", new ConfigurationProperty.Builder().componentProperty(true).secret(true).build()).build();
// ******************
// NEW STYLE
// ******************
final ConnectorAction newAction = new ConnectorAction.Builder().id(KeyGenerator.createKey()).descriptor(new ConnectorDescriptor.Builder().connectorId("new").componentScheme("http4").build()).build();
final Connector newConnector = new Connector.Builder().id("new").addAction(oldAction).putProperty("username", new ConfigurationProperty.Builder().componentProperty(false).secret(true).build()).putProperty("password", new ConfigurationProperty.Builder().componentProperty(false).secret(true).build()).putProperty("token", new ConfigurationProperty.Builder().componentProperty(true).secret(true).build()).build();
// ******************
// Integration
// ******************
Step s1 = new Step.Builder().stepKind(StepKind.endpoint).connection(new Connection.Builder().id(KeyGenerator.createKey()).connector(oldConnector).build()).putConfiguredProperty("username", "my-username-1").putConfiguredProperty("password", "my-password-1").putConfiguredProperty("token", "my-token-1").action(oldAction).build();
Step s2 = new Step.Builder().stepKind(StepKind.endpoint).connection(new Connection.Builder().id(KeyGenerator.createKey()).connector(newConnector).build()).putConfiguredProperty("username", "my-username-2").putConfiguredProperty("password", "my-password-2").putConfiguredProperty("token", "my-token-2").action(newAction).build();
TestResourceManager resourceManager = new TestResourceManager();
ProjectGeneratorConfiguration configuration = new ProjectGeneratorConfiguration();
ProjectGenerator generator = new ProjectGenerator(configuration, resourceManager, getMavenProperties());
Integration integration = resourceManager.newIntegration(s1, s2);
Properties properties = generator.generateApplicationProperties(integration);
assertThat(properties.size()).isEqualTo(6);
assertThat(properties.getProperty("old.configurations.old-1.token")).isEqualTo("my-token-1");
assertThat(properties.getProperty("old-1.username")).isEqualTo("my-username-1");
assertThat(properties.getProperty("old-1.password")).isEqualTo("my-password-1");
assertThat(properties.getProperty("http4-2.token")).isEqualTo("my-token-2");
assertThat(properties.getProperty("http4-2.username")).isEqualTo("my-username-2");
assertThat(properties.getProperty("http4-2.password")).isEqualTo("my-password-2");
}
Aggregations