use of io.cucumber.java.en.Given in project syndesis-qe by syndesisio.
the class MongoDBValidationSteps method createCappedCollection.
@Given("create mongodb capped collection {string} with size {int} and max {int}")
public void createCappedCollection(String collectionName, int size, int max) {
database.getCollection(collectionName).drop();
CreateCollectionOptions options = new CreateCollectionOptions().capped(true).sizeInBytes(size).maxDocuments(max);
database.createCollection(collectionName, options);
}
use of io.cucumber.java.en.Given 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.");
}
}
}
use of io.cucumber.java.en.Given in project syndesis-qe by syndesisio.
the class ConnectionSteps method createConnectionsWithoutValidation.
/**
* TODO: This is temporary solution. Unify with createConnections in CommonSteps
*/
@Given("^creates connections without validation$")
public void createConnectionsWithoutValidation(DataTable connectionsData) {
Connections connectionsLayout = new Connections();
CommonSteps cs = new CommonSteps();
ConfigureConnectionSteps configureConnectionSteps = new ConfigureConnectionSteps();
NameConnectionSteps nameConnectionSteps = new NameConnectionSteps();
List<List<String>> dataTable = connectionsData.cells();
for (List<String> dataRow : dataTable) {
String connectionType = dataRow.get(0);
String connectionCredentialsName = dataRow.get(1);
String connectionName = dataRow.get(2);
String connectionDescription = dataRow.get(3);
cs.navigateTo("Connections");
cs.validatePage("Connections");
ElementsCollection connections = connectionsLayout.getAllConnections();
connections = connections.filter(exactText(connectionName));
if (connections.size() != 0) {
log.warn("Connection {} already exists!", connectionName);
} else {
cs.clickOnButton("Create Connection");
selectConnectionTypeSteps.selectConnectionType(connectionType);
configureConnectionSteps.fillConnectionDetails(connectionCredentialsName);
cs.scrollTo("top", "right");
cs.clickOnButton("Next");
nameConnectionSteps.setConnectionName(connectionName);
nameConnectionSteps.setConnectionDescription(connectionDescription);
cs.clickOnButton("Create");
}
}
}
use of io.cucumber.java.en.Given in project syndesis-qe by syndesisio.
the class ExtensionSteps method uploadExtensionFromSyndesisExtensionsDirUsingDragAndDrop.
@Given("^upload extension \"([^\"]*)\" from syndesis-extensions dir using drag and drop$")
public void uploadExtensionFromSyndesisExtensionsDirUsingDragAndDrop(String extensionFolderName) throws Throwable {
String defaultPath = "../syndesis-extensions/" + extensionFolderName + "/target/";
File[] files = new File(defaultPath).listFiles((dir, name) -> !name.contains("original") && name.endsWith(".jar"));
assertThat(files).hasSize(1).doesNotContainNull();
String techExtensionUrl = defaultPath + files[0].getName();
Path techExtensionJar = Paths.get(techExtensionUrl).toAbsolutePath();
assertThat(techExtensionJar.toFile()).exists();
DragAndDropFile.dragAndDropFile(new File(techExtensionJar.toUri()), $(By.className("dnd-file-chooser")).shouldBe(visible), By.className("extension-import-review__title"));
TestUtils.sleepForJenkinsDelayIfHigher(20);
}
use of io.cucumber.java.en.Given in project syndesis-qe by syndesisio.
the class GMailSteps method deleteMailsFromCreds.
@Given("^delete emails from credentials \"([^\"]*)\" with subject \"([^\"]*)\"$")
public void deleteMailsFromCreds(String creds, String subject) {
Account account = AccountsDirectory.getInstance().get(creds);
gmu.deleteMessages(account.getProperty("username"), subject);
}
Aggregations