Search in sources :

Example 81 with When

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

the class ApicurioSteps method setParametersTypes.

/**
 * Table parameters:
 * Type of dropdown                            --> type | of | as | required
 * Value of dropdown                           --> Array | String | Integer | ...
 * Page where dropdown is located              --> path | operations | datatypes
 * Section where dropdown is located           --> query | header | response | request body
 * Boolean if dropdown is in Responses section --> true it is , false otherwise
 * Number of response                          --> 100 | 200 | 404 | ...
 */
@When("set parameters types")
public void setParametersTypes(DataTable table) {
    for (List<String> dataRow : table.cells()) {
        String buttonId = ApicurioUtils.getButtonId(dataRow.get(0));
        SelenideElement page = ApicurioUtils.getPageElement(dataRow.get(2));
        By section = By.cssSelector("responses-section");
        if (Boolean.parseBoolean(dataRow.get(4))) {
            ApicurioUtils.selectResponse(dataRow.get(5));
        } else {
            ApicurioUtils.openCollapsedSection(page, section);
        }
        ApicurioUtils.setDropDownValue(buttonId, dataRow.get(1), page.$(section));
    }
}
Also used : SelenideElement(com.codeborne.selenide.SelenideElement) By(org.openqa.selenium.By) When(io.cucumber.java.en.When)

Example 82 with When

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

the class ApicurioSteps method setDescriptionPathParameter.

/**
 * @param page can only have values "path" and "operations"
 */
@When("^set description \"([^\"]*)\" for path parameter \"([^\"]*)\" on \"([^\"]*)\" page")
public void setDescriptionPathParameter(String description, String parameter, String page) {
    SelenideElement root = ApicurioUtils.getPageElement(page);
    ApicurioUtils.openPathDescription(parameter, root);
    ApicurioUtils.setValueInTextArea(description, root.$(PathElements.PARAMETERS_SECTION));
}
Also used : SelenideElement(com.codeborne.selenide.SelenideElement) When(io.cucumber.java.en.When)

Example 83 with When

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

the class ApicurioSteps method setPathParameterTypeForPathParameter.

/**
 * @param page can only have values "path" and "operations"
 */
@When("^set path parameter type \"([^\"]*)\" for path parameter \"([^\"]*)\" on \"([^\"]*)\" page")
public void setPathParameterTypeForPathParameter(String type, String parameter, String page) {
    SelenideElement root = ApicurioUtils.getPageElement(page);
    ApicurioUtils.openPathTypes(parameter, root);
    SelenideElement parameterElement = root.$(PathElements.PARAMETERS_SECTION).$$(PathElements.PATH_PARAMETERS_ROW).filter(text(parameter)).first();
    ApicurioUtils.setDropDownValue(ApicurioUtils.Buttons.PROPERTY_TYPE.getButtonId(), type, parameterElement);
}
Also used : SelenideElement(com.codeborne.selenide.SelenideElement) When(io.cucumber.java.en.When)

Example 84 with When

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

the class UpgradeSteps method getUpgradeVersions.

@When("^prepare upgrade$")
public void getUpgradeVersions() {
    Syndesis syndesis = ResourceFactory.get(PreviousSyndesis.class);
    // If it is a prod build, we can use released images from registry.redhat.io
    if (TestUtils.isProdBuild()) {
        // If it is a prod build and the version is null, it means it was started by test-runner, so skip it as for prod upgrade there is a
        // separate job
        assumeThat(TestConfiguration.upgradePreviousVersion()).isNotNull();
        String majorMinorMavenVersion = getMajorMinor(TestConfiguration.upgradePreviousVersion());
        String major = StringUtils.substringBefore(majorMinorMavenVersion, ".");
        // From 1.10 we need to make 1.7, so parse the decimal part to integer and subtract 3
        int minor = Integer.parseInt(StringUtils.substringAfter(majorMinorMavenVersion, ".")) - 3;
        // Parse the previous tag from maven artifacts
        syndesis.setOperatorImage(RELEASED_OPERATOR_IMAGE + ":" + major + "." + minor);
        TestConfiguration.get().overrideProperty(TestConfiguration.SYNDESIS_UPGRADE_CURRENT_VERSION, TestConfiguration.syndesisVersion());
    // Previous version needs to be specified manually via system properties
    } else {
        assumeThat(TestConfiguration.syndesisInstallVersion()).as("Upgrade tests need to have " + TestConfiguration.SYNDESIS_INSTALL_VERSION + " property set!").isNotNull();
        // List all the tags from docker hub
        List<String> tags = new ArrayList<>();
        int page = 0;
        boolean nextPage = false;
        do {
            String tagUrl = String.format(DOCKER_HUB_SYNDESIS_TAGS_URL, ++page);
            JSONObject response = new JSONObject(HTTPUtils.doGetRequest(tagUrl).getBody());
            response.getJSONArray("tags").forEach(tag -> tags.add(((JSONObject) tag).getString("name")));
            nextPage = response.getBoolean("has_additional");
        } while (nextPage);
        Collections.sort(tags);
        String previousTag = getPreviousVersion(getMajorMinor(TestConfiguration.syndesisInstallVersion()), tags);
        if (!previousTag.isEmpty()) {
            TestConfiguration.get().overrideProperty(TestConfiguration.SYNDESIS_UPGRADE_PREVIOUS_VERSION, previousTag);
            syndesis.setOperatorImage(UPSTREAM_OPERATOR_IMAGE + ":" + previousTag);
        } else {
            fail("Unable to find previous version for " + TestConfiguration.syndesisInstallVersion());
        }
        TestConfiguration.get().overrideProperty(TestConfiguration.SYNDESIS_UPGRADE_CURRENT_VERSION, TestConfiguration.syndesisInstallVersion());
    }
    // We want to deploy "previous" version first
    syndesis.setCrdUrl(getClass().getClassLoader().getResource("upgrade/syndesis-crd-previous.yaml").toString());
    log.info("Upgrade properties:");
    log.info("  Previous version: " + TestConfiguration.upgradePreviousVersion());
    log.info("  Current version:  " + TestConfiguration.upgradeCurrentVersion());
}
Also used : JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) Syndesis(io.syndesis.qe.resource.impl.Syndesis) PreviousSyndesis(io.syndesis.qe.resource.impl.PreviousSyndesis) IntegrationsEndpoint(io.syndesis.qe.endpoint.IntegrationsEndpoint) When(io.cucumber.java.en.When)

Example 85 with When

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

the class UpgradeSteps method deploySyndesis.

@When("deploy previous Syndesis CR {string}")
public void deploySyndesis(String crFile) {
    Syndesis syndesis = ResourceFactory.get(PreviousSyndesis.class);
    syndesis.setCrUrl(getClass().getClassLoader().getResource("upgrade/" + crFile).toString());
    ResourceFactory.create(PreviousSyndesis.class);
}
Also used : Syndesis(io.syndesis.qe.resource.impl.Syndesis) PreviousSyndesis(io.syndesis.qe.resource.impl.PreviousSyndesis) When(io.cucumber.java.en.When)

Aggregations

When (io.cucumber.java.en.When)111 SelenideElement (com.codeborne.selenide.SelenideElement)23 Map (java.util.Map)10 File (java.io.File)8 AttributeType (com.vaticle.typedb.core.concept.type.AttributeType)7 ModalDialogPage (io.syndesis.qe.pages.ModalDialogPage)7 Attribute (com.vaticle.typedb.core.concept.thing.Attribute)6 Account (io.syndesis.qe.account.Account)6 Form (io.syndesis.qe.fragments.common.form.Form)6 Syndesis (io.syndesis.qe.resource.impl.Syndesis)6 TimeoutException (java.util.concurrent.TimeoutException)6 RoleType (com.vaticle.typedb.core.concept.type.RoleType)5 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 Slf4j (lombok.extern.slf4j.Slf4j)5 ElementsCollection (com.codeborne.selenide.ElementsCollection)4 DataTable (io.cucumber.datatable.DataTable)4 IntegrationsEndpoint (io.syndesis.qe.endpoint.IntegrationsEndpoint)4 SyndesisRootPage (io.syndesis.qe.pages.SyndesisRootPage)4 List (java.util.List)4