Search in sources :

Example 36 with Integration

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());
        }
    }
}
Also used : Integration(io.syndesis.common.model.integration.Integration) Connection(io.syndesis.common.model.connection.Connection) After(io.cucumber.java.After)

Example 37 with Integration

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();
}
Also used : Then(io.cucumber.java.en.Then) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Autowired(org.springframework.beans.factory.annotation.Autowired) IntegrationOverview(io.syndesis.qe.endpoint.model.IntegrationOverview) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) Assertions(org.assertj.core.api.Assertions) Build(io.fabric8.openshift.api.model.Build) Integration(io.syndesis.common.model.integration.Integration) NoSuchElementException(java.util.NoSuchElementException) IntegrationDeployment(io.syndesis.common.model.integration.IntegrationDeployment) IntegrationOverviewEndpoint(io.syndesis.qe.endpoint.IntegrationOverviewEndpoint) InfraFail(io.syndesis.qe.test.InfraFail) When(io.cucumber.java.en.When) Pod(io.fabric8.kubernetes.api.model.Pod) OpenShiftUtils(io.syndesis.qe.utils.OpenShiftUtils) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) TestUtils(io.syndesis.qe.utils.TestUtils) IntegrationDeploymentState(io.syndesis.common.model.integration.IntegrationDeploymentState) OpenShiftWaitUtils(io.syndesis.qe.wait.OpenShiftWaitUtils) IntegrationOverview(io.syndesis.qe.endpoint.model.IntegrationOverview) Then(io.cucumber.java.en.Then)

Example 38 with Integration

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();
}
Also used : Connector(io.syndesis.common.model.connection.Connector) Integration(io.syndesis.common.model.integration.Integration) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Connection(io.syndesis.common.model.connection.Connection) Step(io.syndesis.common.model.integration.Step)

Example 39 with Integration

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");
}
Also used : Integration(io.syndesis.common.model.integration.Integration) Connection(io.syndesis.common.model.connection.Connection) Step(io.syndesis.common.model.integration.Step) Test(org.junit.Test)

Example 40 with Integration

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");
}
Also used : ConfigurationProperty(io.syndesis.common.model.connection.ConfigurationProperty) Connector(io.syndesis.common.model.connection.Connector) Integration(io.syndesis.common.model.integration.Integration) Connection(io.syndesis.common.model.connection.Connection) Step(io.syndesis.common.model.integration.Step) IntegrationProjectGenerator(io.syndesis.integration.api.IntegrationProjectGenerator) MavenProperties(io.syndesis.common.util.MavenProperties) Properties(java.util.Properties) ConnectorDescriptor(io.syndesis.common.model.action.ConnectorDescriptor) ConnectorAction(io.syndesis.common.model.action.ConnectorAction) Test(org.junit.Test)

Aggregations

Integration (io.syndesis.common.model.integration.Integration)57 Test (org.junit.Test)19 Step (io.syndesis.common.model.integration.Step)17 List (java.util.List)16 Connection (io.syndesis.common.model.connection.Connection)15 Connector (io.syndesis.common.model.connection.Connector)11 DataManager (io.syndesis.server.dao.manager.DataManager)11 IOException (java.io.IOException)11 Set (java.util.Set)10 InputStream (java.io.InputStream)9 ArrayList (java.util.ArrayList)9 Collectors (java.util.stream.Collectors)9 IntegrationDeployment (io.syndesis.common.model.integration.IntegrationDeployment)8 IntegrationDeploymentState (io.syndesis.common.model.integration.IntegrationDeploymentState)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8 IntegrationProjectGenerator (io.syndesis.integration.api.IntegrationProjectGenerator)7 Map (java.util.Map)7 Action (io.syndesis.common.model.action.Action)6 ConnectorAction (io.syndesis.common.model.action.ConnectorAction)6 StepKind (io.syndesis.common.model.integration.StepKind)6