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