Search in sources :

Example 6 with Then

use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.

the class IntegrationHandler method sameNameIntegrationValidation.

@Then("try to create new integration with the same name: {string} and state: {string}")
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(() -> {
        EndpointClient.getClient().target(integrationsEndpoint.getEndpointUrl()).request(MediaType.APPLICATION_JSON).header("X-Forwarded-User", "pista").header("X-Forwarded-Access-Token", "kral").header("SYNDESIS-XSRF-TOKEN", "awesome").post(Entity.entity(integration, MediaType.APPLICATION_JSON), JsonNode.class);
    }).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(io.cucumber.java.en.Then)

Example 7 with Then

use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.

the class MongoDBValidationSteps method verifyMongoDocuments.

@Then("verify that mongodb collection {string} has {int} document matching")
public void verifyMongoDocuments(String collectionName, int count, DataTable find) {
    Document findSpec = new Document(find.<String, Object>asMaps(String.class, String.class).get(0));
    Awaitility.await().atMost(Duration.ofSeconds(20)).pollDelay(Duration.ofSeconds(3)).pollInterval(Duration.ofSeconds(3)).untilAsserted(() -> {
        FindIterable<Document> documents = database.getCollection(collectionName).find(findSpec);
        List<Document> results = new ArrayList<>();
        documents.forEach((Consumer<? super Document>) results::add);
        Assertions.assertThat(results).describedAs("Didn't find the requested document %s in collection %s", findSpec, collectionName).hasSize(count);
    });
}
Also used : ArrayList(java.util.ArrayList) Document(org.bson.Document) Then(io.cucumber.java.en.Then)

Example 8 with Then

use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.

the class MqttValidationSteps method sendAndRecieveMessage.

@Then("verify that when message is sent to {string} topic it is redirected to {string} topic via integration")
public void sendAndRecieveMessage(String senderTopic, String receiverTopic) {
    // reset message received flag
    Receiver.RECEIVED_FLAG = 0;
    MqttClient receiverClient = null;
    try {
        portForward();
        // create receiver
        receiverClient = mqttUtils.createReceiver("receiver_1", receiverTopic);
        // send message via client
        mqttUtils.sendMessage("Hi from syndesis integration!", senderTopic);
        // give it some short time for delivery
        TestUtils.sleepIgnoreInterrupt(4000);
    } catch (MqttException e) {
        Assertions.fail("Mqtt Exception was thrown during message transfer", e);
    } finally {
        // close receiver
        mqttUtils.closeClient(receiverClient);
        // close mqtt port
        portClose();
    }
    // check flag
    Assertions.assertThat(Receiver.RECEIVED_FLAG).as("Message was not received!").isEqualTo(1);
}
Also used : MqttClient(org.eclipse.paho.client.mqttv3.MqttClient) MqttException(org.eclipse.paho.client.mqttv3.MqttException) Then(io.cucumber.java.en.Then)

Example 9 with Then

use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.

the class CommonSteps method waitForTodo.

@Then("wait for Todo to become ready")
public void waitForTodo() {
    log.info("Waiting for Todo to get ready");
    ExecutorService executorService = Executors.newFixedThreadPool(1);
    Runnable runnable = () -> OpenShiftUtils.getInstance().waiters().areExactlyNPodsReady(1, "syndesis.io/app", "todo").interval(TimeUnit.SECONDS, 20).timeout(TimeUnit.MINUTES, 12).waitFor();
    executorService.submit(runnable);
    executorService.shutdown();
    try {
        if (!executorService.awaitTermination(20, TimeUnit.MINUTES)) {
            executorService.shutdownNow();
            InfraFail.fail("Todo app wasn't initilized in time");
        }
    } catch (InterruptedException e) {
        InfraFail.fail("Waiting for Todo app was interrupted with exception: " + e.getMessage());
    }
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) Then(io.cucumber.java.en.Then)

Example 10 with Then

use of io.cucumber.java.en.Then in project syndesis-qe by syndesisio.

the class CommonValidationSteps method verifyIntegrationOnOffNTimes.

@Then("switch Inactive and Active state on integration {string} for {int} times and check pods")
public void verifyIntegrationOnOffNTimes(String integrationName, int switchNTimes) {
    final String integrationId = integrationsEndpoint.getIntegrationId(integrationName).get();
    for (int i = 0; i <= switchNTimes; i++) {
        final IntegrationDeploymentState newDepState;
        final Integration integration = integrationsEndpoint.get(integrationId);
        int integrationVersion = integration.getVersion();
        log.info("Getting integrationDeployment with deployment number: {}", integrationVersion);
        IntegrationDeployment currentDeployment = integrationsEndpoint.getCurrentIntegrationDeployment(integrationId, integrationVersion);
        if (currentDeployment.getCurrentState().equals(IntegrationDeploymentState.Published)) {
            newDepState = IntegrationDeploymentState.Unpublished;
            log.info("Unpublishing integration with integration version: {}", integrationVersion);
            integrationsEndpoint.deactivateIntegration(integrationId, integrationVersion);
        } else {
            newDepState = IntegrationDeploymentState.Published;
            log.info("Publishing integration: {}", integrationId);
            integrationsEndpoint.activateIntegration(integrationId);
        }
        if (newDepState.equals(IntegrationDeploymentState.Published)) {
            verifyPodCount(integrationName, 1);
        } else {
            verifyPodCount(integrationName, 0);
        }
    }
}
Also used : Integration(io.syndesis.common.model.integration.Integration) IntegrationDeploymentState(io.syndesis.common.model.integration.IntegrationDeploymentState) IntegrationDeployment(io.syndesis.common.model.integration.IntegrationDeployment) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint) IntegrationOverviewEndpoint(io.syndesis.qe.endpoint.IntegrationOverviewEndpoint) Then(io.cucumber.java.en.Then)

Aggregations

Then (io.cucumber.java.en.Then)124 SelenideElement (com.codeborne.selenide.SelenideElement)20 AttributeType (com.vaticle.typedb.core.concept.type.AttributeType)16 List (java.util.List)13 HashMap (java.util.HashMap)10 SyndesisRootPage (io.syndesis.qe.pages.SyndesisRootPage)9 Map (java.util.Map)9 ThingType (com.vaticle.typedb.core.concept.type.ThingType)8 DataTable (io.cucumber.datatable.DataTable)8 When (io.cucumber.java.en.When)8 Pod (io.fabric8.kubernetes.api.model.Pod)8 Quantity (io.fabric8.kubernetes.api.model.Quantity)8 ArrayList (java.util.ArrayList)8 Date (java.util.Date)8 TimeoutException (java.util.concurrent.TimeoutException)8 TestUtils (io.syndesis.qe.utils.TestUtils)7 HTTPResponse (io.syndesis.qe.utils.http.HTTPResponse)7 OpenShiftWaitUtils (io.syndesis.qe.wait.OpenShiftWaitUtils)7 Slf4j (lombok.extern.slf4j.Slf4j)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7