Search in sources :

Example 1 with GoogleAccount

use of io.syndesis.qe.utils.google.GoogleAccount in project syndesis-qe by syndesisio.

the class CommonSteps method createConnections.

@Given("^created connections$")
public void createConnections(DataTable connectionsData) {
    Connections connectionsPage = new Connections();
    ConfigureConnectionSteps configureConnectionSteps = new ConfigureConnectionSteps();
    NameConnectionSteps nameConnectionSteps = new NameConnectionSteps();
    List<List<String>> dataTable = connectionsData.cells();
    for (List<String> dataRow : dataTable) {
        String connectionType = validateConnectorName(dataRow.get(0));
        String connectionCredentialsName = dataRow.get(1);
        String connectionName = dataRow.get(2);
        String connectionDescription = dataRow.get(3);
        if ("Gmail".equalsIgnoreCase(connectionType) || "Google Calendar".equalsIgnoreCase(connectionType)) {
            Account a = AccountsDirectory.getInstance().get(connectionCredentialsName);
            GoogleAccount googleAccount = googleAccounts.getGoogleAccountForTestAccount(connectionCredentialsName);
            a.getProperties().put("accessToken", googleAccount.getCredential().getAccessToken());
        }
        navigateTo("Connections");
        validatePage("Connections");
        ElementsCollection connections = connectionsPage.getAllConnections();
        connections = connections.filter(exactText(connectionName));
        try {
            if (connections.size() != 0) {
                log.warn("Connection {} already exists!", connectionName);
                continue;
            }
        } catch (org.openqa.selenium.StaleElementReferenceException e) {
            // this may happen if page was "reloaded" before connections.size was processed, give it second try
            connections = connectionsPage.getAllConnections();
            connections = connections.filter(exactText(connectionName));
            if (connections.size() != 0) {
                log.warn("Connection {} already exists!", connectionName);
                continue;
            }
        }
        clickOnLink("Create Connection");
        log.info("Sleeping so jenkins has more time to load all connectors");
        TestUtils.sleepIgnoreInterrupt(TestConfiguration.getJenkinsDelay() * 1000);
        selectConnectionTypeSteps.selectConnectionType(connectionType);
        configureConnectionSteps.fillConnectionDetails(connectionCredentialsName);
        // do nothing if connection does not require any credentials
        if (!("no credentials".equalsIgnoreCase(connectionCredentialsName) || "no validation".equalsIgnoreCase(connectionDescription))) {
            clickOnButton("Validate");
            TestUtils.waitFor(() -> $$(Alert.ALL.getBy()).size() > 0, 2, 20, "Any notification appears!");
            if (getAllAlerts(connectionType + " does not support validation", "info").size() > 0) {
                log.warn("Connection type " + connectionType + " doesn't support validation. The test suite assumes that set credentials are correct.");
            } else {
                successNotificationIsPresentWithError(connectionType + " has been successfully validated", "success");
            }
            scrollTo("top", "right");
            clickOnButton("Next");
        } else if ("no validation".equalsIgnoreCase(connectionDescription)) {
            scrollTo("top", "right");
            clickOnButton("Next");
        }
        nameConnectionSteps.setConnectionName(connectionName);
        nameConnectionSteps.setConnectionDescription(connectionDescription);
        clickOnButton("Save");
        try {
            TestUtils.sleepForJenkinsDelayIfHigher(2);
            OpenShiftWaitUtils.waitFor(() -> !syndesisRootPage.getCurrentUrl().contains("connections/create"), 2, 20);
        } catch (TimeoutException | InterruptedException e) {
            clickOnButton("Save");
            TestUtils.waitFor(() -> !syndesisRootPage.getCurrentUrl().contains("connections/create"), 2, 20, "Unable to create a connection - create button does nothing.");
        }
    }
}
Also used : Connections(io.syndesis.qe.pages.connections.Connections) GoogleAccount(io.syndesis.qe.utils.google.GoogleAccount) Account(io.syndesis.qe.account.Account) GoogleAccount(io.syndesis.qe.utils.google.GoogleAccount) ConfigureConnectionSteps(io.syndesis.qe.steps.connections.wizard.phases.ConfigureConnectionSteps) NameConnectionSteps(io.syndesis.qe.steps.connections.wizard.phases.NameConnectionSteps) ElementsCollection(com.codeborne.selenide.ElementsCollection) List(java.util.List) ArrayList(java.util.ArrayList) TimeoutException(java.util.concurrent.TimeoutException) Given(io.cucumber.java.en.Given)

Aggregations

ElementsCollection (com.codeborne.selenide.ElementsCollection)1 Given (io.cucumber.java.en.Given)1 Account (io.syndesis.qe.account.Account)1 Connections (io.syndesis.qe.pages.connections.Connections)1 ConfigureConnectionSteps (io.syndesis.qe.steps.connections.wizard.phases.ConfigureConnectionSteps)1 NameConnectionSteps (io.syndesis.qe.steps.connections.wizard.phases.NameConnectionSteps)1 GoogleAccount (io.syndesis.qe.utils.google.GoogleAccount)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TimeoutException (java.util.concurrent.TimeoutException)1