Search in sources :

Example 1 with Integration

use of io.syndesis.common.model.integration.Integration 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 (int i = 0; i < mappers.size(); i++) {
            List<StepDefinition> precedingSteps = steps.getStepDefinitions().subList(0, steps.getStepDefinitions().indexOf(mappers.get(i))).stream().filter(s -> s.getConnectorDescriptor().isPresent()).collect(Collectors.toList());
            StepDefinition followingStep = steps.getStepDefinitions().get(steps.getStepDefinitions().indexOf(mappers.get(i)) + 1);
            if (mappers.get(i).getStep().getConfiguredProperties().containsKey("atlasmapping")) {
                // TODO(tplevko): think of some way to substitute placeholders for the step ID's
                reflectStepIdsInAtlasMapping(mappers.get(i), precedingSteps, followingStep);
            } else {
                // TODO(tplevko): fix for more than one preceding step.
                mappers.get(i).setStep(atlasGenerator.getAtlasMappingStep(mappers.get(i), precedingSteps, followingStep));
            }
        }
    }
}
Also used : Autowired(org.springframework.beans.factory.annotation.Autowired) AtlasMapperGenerator(io.syndesis.qe.bdd.datamapper.AtlasMapperGenerator) Collectors(java.util.stream.Collectors) IntegrationsDeploymentEndpoint(io.syndesis.qe.endpoints.IntegrationsDeploymentEndpoint) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) IntegrationsEndpoint(io.syndesis.qe.endpoints.IntegrationsEndpoint) StepsStorage(io.syndesis.qe.bdd.storage.StepsStorage) Assertions(org.assertj.core.api.Assertions) BadRequestException(javax.ws.rs.BadRequestException) StepKind(io.syndesis.common.model.integration.StepKind) Integration(io.syndesis.common.model.integration.Integration) Then(cucumber.api.java.en.Then) When(cucumber.api.java.en.When) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) IntegrationsDeploymentEndpoint(io.syndesis.qe.endpoints.IntegrationsDeploymentEndpoint) IntegrationsEndpoint(io.syndesis.qe.endpoints.IntegrationsEndpoint)

Example 2 with Integration

use of io.syndesis.common.model.integration.Integration in project syndesis-qe by syndesisio.

the class IntegrationHandler method sameNameIntegrationValidation.

@Then("^try to create new integration with the same name: \"([^\"]*)\" and state: \"([^\"]*)\"$")
public void sameNameIntegrationValidation(String integrationName, String desiredState) {
    final Integration integration = new Integration.Builder().steps(steps.getSteps()).name(integrationName).description("Awkward integration.").build();
    log.info("Creating integration {}", integration.getName());
    Assertions.assertThatExceptionOfType(BadRequestException.class).isThrownBy(() -> {
        integrationsEndpoint.create(integration);
    }).withMessageContaining("HTTP 400 Bad Request").withNoCause();
    log.debug("Flushing used steps");
    steps.flushStepDefinitions();
}
Also used : Integration(io.syndesis.common.model.integration.Integration) BadRequestException(javax.ws.rs.BadRequestException) Then(cucumber.api.java.en.Then)

Example 3 with Integration

use of io.syndesis.common.model.integration.Integration in project syndesis-qe by syndesisio.

the class IntegrationActivityListComponent method getIdByIntegrationName.

private String getIdByIntegrationName(String integrationName) {
    List<Integration> integrations = integrationsEndpoint.list();
    Integration integr = integrations.stream().filter(integration -> integrationName.equals(integration.getName())).findAny().orElse(null);
    return integr.getId().get();
}
Also used : Integration(io.syndesis.common.model.integration.Integration)

Example 4 with Integration

use of io.syndesis.common.model.integration.Integration in project syndesis-qe by syndesisio.

the class UiComplexSteps method processMapperSteps.

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 (int i = 0; i < mappers.size(); i++) {
            List<StepDefinition> precedingSteps = steps.getStepDefinitions().subList(0, steps.getStepDefinitions().indexOf(mappers.get(i))).stream().filter(s -> s.getConnectorDescriptor().isPresent()).collect(Collectors.toList());
            StepDefinition followingStep = steps.getStepDefinitions().get(steps.getStepDefinitions().indexOf(mappers.get(i)) + 1);
            if (mappers.get(i).getStep().getConfiguredProperties().containsKey("atlasmapping")) {
                // TODO(tplevko): think of some way to substitute placeholders for the step ID's
                reflectStepIdsInAtlasMapping(mappers.get(i), precedingSteps, followingStep);
            } else {
                // TODO(tplevko): fix for more than one preceding step.
                mappers.get(i).setStep(atlasGenerator.getAtlasMappingStep(mappers.get(i), precedingSteps, followingStep));
            }
        }
    }
}
Also used : ConnectorDescriptor(io.syndesis.common.model.action.ConnectorDescriptor) Arrays(java.util.Arrays) Action(io.syndesis.common.model.action.Action) Step(io.syndesis.common.model.integration.Step) Autowired(org.springframework.beans.factory.annotation.Autowired) MappingType(io.atlasmap.v2.MappingType) ConnectorsEndpoint(io.syndesis.qe.endpoints.ConnectorsEndpoint) DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) IntegrationsDeploymentEndpoint(io.syndesis.qe.endpoints.IntegrationsDeploymentEndpoint) Connection(io.syndesis.common.model.connection.Connection) Map(java.util.Map) Given(cucumber.api.java.en.Given) Assertions(org.assertj.core.api.Assertions) StepKind(io.syndesis.common.model.integration.StepKind) Integration(io.syndesis.common.model.integration.Integration) ConnectionsEndpoint(io.syndesis.qe.endpoints.ConnectionsEndpoint) Connector(io.syndesis.common.model.connection.Connector) AtlasMapperGenerator(io.syndesis.qe.bdd.datamapper.AtlasMapperGenerator) IOException(java.io.IOException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IntegrationOverview(io.syndesis.qe.model.IntegrationOverview) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) IntegrationsEndpoint(io.syndesis.qe.endpoints.IntegrationsEndpoint) TestUtils(io.syndesis.qe.utils.TestUtils) DataMapperDefinition(io.syndesis.qe.bdd.entities.DataMapperDefinition) StepsStorage(io.syndesis.qe.bdd.storage.StepsStorage) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) IntegrationOverviewEndpoint(io.syndesis.qe.endpoints.IntegrationOverviewEndpoint) DataMapperStepDefinition(io.syndesis.qe.bdd.entities.DataMapperStepDefinition) StepDefinition(io.syndesis.qe.bdd.entities.StepDefinition) ConnectorsEndpoint(io.syndesis.qe.endpoints.ConnectorsEndpoint) IntegrationsDeploymentEndpoint(io.syndesis.qe.endpoints.IntegrationsDeploymentEndpoint) ConnectionsEndpoint(io.syndesis.qe.endpoints.ConnectionsEndpoint) IntegrationsEndpoint(io.syndesis.qe.endpoints.IntegrationsEndpoint) IntegrationOverviewEndpoint(io.syndesis.qe.endpoints.IntegrationOverviewEndpoint)

Example 5 with Integration

use of io.syndesis.common.model.integration.Integration in project syndesis-qe by syndesisio.

the class CommonValidationSteps method waitForIntegrationToBeActive.

@Then("^wait for integration with name: \"([^\"]*)\" to become active")
public void waitForIntegrationToBeActive(String integrationName) {
    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);
    String integrationId = integrationsEndpoint.getIntegrationId(integrationName).get();
    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));
}
Also used : Autowired(org.springframework.beans.factory.annotation.Autowired) Pod(io.fabric8.kubernetes.api.model.Pod) OpenShiftUtils(io.syndesis.qe.utils.OpenShiftUtils) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) IntegrationOverview(io.syndesis.qe.model.IntegrationOverview) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) IntegrationsEndpoint(io.syndesis.qe.endpoints.IntegrationsEndpoint) TestUtils(io.syndesis.qe.utils.TestUtils) Assertions(org.assertj.core.api.Assertions) Build(io.fabric8.openshift.api.model.Build) Integration(io.syndesis.common.model.integration.Integration) Then(cucumber.api.java.en.Then) IntegrationOverviewEndpoint(io.syndesis.qe.endpoints.IntegrationOverviewEndpoint) OpenShiftWaitUtils(io.syndesis.qe.wait.OpenShiftWaitUtils) Integration(io.syndesis.common.model.integration.Integration) IntegrationOverviewEndpoint(io.syndesis.qe.endpoints.IntegrationOverviewEndpoint) IntegrationOverview(io.syndesis.qe.model.IntegrationOverview) Then(cucumber.api.java.en.Then)

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