Search in sources :

Example 86 with Then

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

the class IntegrationSteps method waitForIntegrationState.

/*
     * State != starting state
     * State is state of integration. e.g. "Running", "Stopped"
     */
@Then("^wait until integration \"([^\"]*)\" gets into \"([^\"]*)\" state$")
public void waitForIntegrationState(String integrationName, String integrationStatus) {
    commonSteps.navigateTo("Integrations");
    SelenideElement integration = integrations.getIntegration(integrationName);
    TestUtils.sleepForJenkinsDelayIfHigher(10);
    if ("camelk".equalsIgnoreCase(TestConfiguration.syndesisRuntime())) {
        ResourceFactory.get(CamelK.class).waitForContextToBuild(integrationName);
        Selenide.refresh();
        log.info("Integration platform status: {}", OpenShiftUtils.binary().execute("get", "integrationplatforms", "-o yaml"));
    }
    assertThat(TestUtils.waitForEvent(status -> status.contains(integrationStatus), () -> integrations.getIntegrationItemStatus(integrationName), TimeUnit.MINUTES, 10, TimeUnit.SECONDS, 20)).isTrue();
}
Also used : SelenideElement(com.codeborne.selenide.SelenideElement) CamelK(io.syndesis.qe.resource.impl.CamelK) Then(io.cucumber.java.en.Then)

Example 87 with Then

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

the class OperatorValidationSteps method checkDbPvCapacity.

@Then("check that {string} persistent volume capacity is greater or equals to {string}")
public void checkDbPvCapacity(String pvc, String expected) {
    try {
        OpenShiftWaitUtils.waitFor(() -> OpenShiftUtils.getInstance().getPersistentVolumeClaim(pvc) != null);
        OpenShiftWaitUtils.waitFor(() -> OpenShiftUtils.getInstance().getPersistentVolumeClaim(pvc).getStatus().getPhase().equals("Bound"));
    } catch (TimeoutException | InterruptedException e) {
        fail("Unable to get " + pvc + " pvc: ", e);
    }
    final Quantity capacity = OpenShiftUtils.getInstance().getPersistentVolumeClaim(pvc).getStatus().getCapacity().get("storage");
    assertThat(capacity.getFormat()).isEqualTo("Gi");
    assertThat(Integer.parseInt(capacity.getAmount())).isGreaterThanOrEqualTo(Integer.parseInt(expected.replaceAll("[a-zA-Z]", "")));
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) TimeoutException(java.util.concurrent.TimeoutException) Then(io.cucumber.java.en.Then)

Example 88 with Then

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

the class OperatorValidationSteps method checkRepositories.

@Then("check repositories used in integration {string} build")
public void checkRepositories(String build, DataTable expectedRepositories) {
    String log = OpenShiftUtils.getInstance().getBuildLog(OpenShiftUtils.getInstance().builds().list().getItems().stream().filter(b -> b.getMetadata().getName().contains(build)).findFirst().get());
    Pattern regex = Pattern.compile(".*Downloading .*https:\\/\\/(.*)\\/org.*");
    Set<String> downloads = Arrays.stream(log.split("\\n")).filter(line -> line.contains("Downloading ") && line.contains("camel-lzf")).map(line -> {
        Matcher matcher = regex.matcher(line);
        if (matcher.find()) {
            return matcher.group(1);
        } else {
            fail("Unable to parse line: " + line);
            return "";
        }
    }).collect(Collectors.toSet());
    SoftAssertions asserts = new SoftAssertions();
    for (String repository : expectedRepositories.asList()) {
        String repo = StringUtils.substringAfter(repository, "https://");
        asserts.assertThat(downloads).contains(repo);
        downloads.remove(repo);
    }
    asserts.assertThat(downloads).as("The artifact shouldn't be downloaded from other repositories than defined").isEmpty();
    asserts.assertAll();
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) Arrays(java.util.Arrays) Enumeration(java.util.Enumeration) Date(java.util.Date) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Autowired(org.springframework.beans.factory.annotation.Autowired) TimeoutException(java.util.concurrent.TimeoutException) Random(java.util.Random) StringUtils(org.apache.commons.lang3.StringUtils) JSONObject(org.json.JSONObject) Matcher(java.util.regex.Matcher) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint) Map(java.util.Map) Addon(io.syndesis.qe.addon.Addon) ZipFile(java.util.zip.ZipFile) Syndesis(io.syndesis.qe.resource.impl.Syndesis) Path(java.nio.file.Path) ZipEntry(java.util.zip.ZipEntry) Affinity(io.fabric8.kubernetes.api.model.Affinity) AccountsDirectory(io.syndesis.qe.account.AccountsDirectory) Set(java.util.Set) DeploymentConfig(io.fabric8.openshift.api.model.DeploymentConfig) Jaeger(io.syndesis.qe.resource.impl.Jaeger) DoneablePersistentVolume(io.fabric8.kubernetes.api.model.DoneablePersistentVolume) Collectors(java.util.stream.Collectors) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Assertions.fail(org.assertj.core.api.Assertions.fail) S3BucketNameBuilder(io.syndesis.qe.utils.aws.S3BucketNameBuilder) ResourceFactory(io.syndesis.qe.resource.ResourceFactory) Optional(java.util.Optional) Lazy(org.springframework.context.annotation.Lazy) Pattern(java.util.regex.Pattern) Component(io.syndesis.qe.component.Component) OpenShiftWaitUtils(io.syndesis.qe.wait.OpenShiftWaitUtils) SoftAssertions(org.assertj.core.api.SoftAssertions) NodeSelectorTerm(io.fabric8.kubernetes.api.model.NodeSelectorTerm) Then(io.cucumber.java.en.Then) ComponentUtils(io.syndesis.qe.component.ComponentUtils) LocalPortForward(io.fabric8.kubernetes.client.LocalPortForward) HashMap(java.util.HashMap) Yaml(org.yaml.snakeyaml.Yaml) Given(io.cucumber.java.en.Given) DataTable(io.cucumber.datatable.DataTable) Node(io.fabric8.kubernetes.api.model.Node) OutputStream(java.io.OutputStream) PersistentVolumeFluent(io.fabric8.kubernetes.api.model.PersistentVolumeFluent) Endpoints(io.fabric8.kubernetes.api.model.Endpoints) Files(java.nio.file.Files) When(io.cucumber.java.en.When) S3Utils(io.syndesis.qe.utils.aws.S3Utils) FileOutputStream(java.io.FileOutputStream) Pod(io.fabric8.kubernetes.api.model.Pod) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) NodeSelector(io.fabric8.kubernetes.api.model.NodeSelector) Toleration(io.fabric8.kubernetes.api.model.Toleration) OpenShiftUtils(io.syndesis.qe.utils.OpenShiftUtils) FileInputStream(java.io.FileInputStream) Account(io.syndesis.qe.account.Account) File(java.io.File) NodeAffinity(io.fabric8.kubernetes.api.model.NodeAffinity) HTTPUtils(io.syndesis.qe.utils.http.HTTPUtils) TestUtils(io.syndesis.qe.utils.TestUtils) Paths(java.nio.file.Paths) SecretBuilder(io.fabric8.kubernetes.api.model.SecretBuilder) ExternalDatabase(io.syndesis.qe.resource.impl.ExternalDatabase) JSONArray(org.json.JSONArray) InputStream(java.io.InputStream) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) SoftAssertions(org.assertj.core.api.SoftAssertions) Then(io.cucumber.java.en.Then)

Example 89 with Then

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

the class ConditionalFlowSteps method validateConditionalFlowDropdown.

@Then("^validate conditional flow dropdown content$")
public void validateConditionalFlowDropdown(DataTable data) {
    openDropdownWithConditions();
    ElementsCollection dropdownElements = $$(EditFlowStepElements.FLOW_DROPDOWN_ITEM);
    int current = 0;
    for (List<String> row : data.cells()) {
        assertThat(dropdownElements.get(current).getText().replaceAll("\n", " ")).isEqualToIgnoringCase(row.get(0));
        current++;
    }
}
Also used : ElementsCollection(com.codeborne.selenide.ElementsCollection) Then(io.cucumber.java.en.Then)

Example 90 with Then

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

the class GMailSteps method checkMailsFromCredentials.

@Then("^check that email from credenitals \"([^\"]*)\" with subject \"([^\"]*)\" and text \"([^\"]*)\" exists")
public void checkMailsFromCredentials(String credentials, String subject, String text) {
    Account account = AccountsDirectory.getInstance().get(credentials);
    String username = account.getProperty("username");
    TestUtils.waitFor(() -> checkMailExists(username, subject, text), 1, 60, "Could not find specified mail");
}
Also used : Account(io.syndesis.qe.account.Account) GoogleAccount(io.syndesis.qe.utils.google.GoogleAccount) 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