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();
}
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);
});
}
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);
}
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());
}
}
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);
}
}
}
Aggregations