@And("^sets jms subscribe inputs source data$") public void setJmsSubscribeData(DataTable sourceMappingData) { for (Map<String, String> source : sourceMappingData.asMaps(String.class, String.class)) { for (String field : source.keySet()) { SelenideElement element = editPage.getJmsSubscribeComponent().checkAndGetFieldType(field); assertThat(element, notNullValue()); editPage.getJmsSubscribeComponent().setElementValue(source.get(field), element); } } }
@And("^sets jms request inputs source data$") public void setJmsRequestData(DataTable sourceMappingData) { for (Map<String, String> source : sourceMappingData.asMaps(String.class, String.class)) { for (String field : source.keySet()) { SelenideElement element = editPage.getJmsSubscribeComponent().checkAndGetFieldType(field); assertThat(element, notNullValue()); editPage.getJmsSubscribeComponent().setElementValue(source.get(field), element); } } }
@And("^sets jms publish inputs source data$") public void setJmsPublishData(DataTable sourceMappingData) { for (Map<String, String> source : sourceMappingData.asMaps(String.class, String.class)) { for (String field : source.keySet()) { SelenideElement element = editPage.getJmsPublishComponent().checkAndGetFieldType(field); assertThat(element, notNullValue()); editPage.getJmsPublishComponent().setElementValue(source.get(field), element); } } }
@And("^I search for \"([^\"]*)\" under Used Cars$") public void iSearchForUnderUsedCars(String carName) throws Throwable { /* TODO - Assignment - Move the below statements to a page class */ appiumDriver.findElement(By.xpath("//android.widget.TextView[@text='Cars']")).click(); appiumDriver.findElement(By.id("cnb_hp_choose_et")).click(); appiumDriver.findElement(By.id("cnb_search_text_et")).sendKeys(carName); List<WebElement> results = appiumDriver.findElements(By.id("text1")); for (WebElement result : results) { if (result.getText().contains(carName)) { result.click(); break; } } appiumDriver.findElement(By.id("cnb_search_button")).click(); }
@And("^Project \"([^\"]*)\" contains dependencies:$") public void configurationContainsDependencies(String projectName, List<List<String>> dependencies) throws Throwable { this.projectName = projectName; JsonObject reportForProject = report.getAsJsonObject(projectName); assertThat(reportForProject).describedAs("Report for " + projectName).isNotNull(); Stream<List<String>> entries = reportForProject .entrySet() .stream() .flatMap(configurationEntry -> StreamSupport .stream(configurationEntry.getValue().getAsJsonArray().spliterator(), false) .map(JsonObject.class::cast) .map(dependency -> asList( configurationEntry.getKey(), dependency.get("coordinates").getAsString() ))); assertThat(entries) .containsOnly(dependencies.toArray(new List[]{})); }
@And("^I set template with parameters$") public void iSetParameters() throws Throwable { Parameter parameter = new Parameter(); parameter.setKey("title"); parameter.setValue("Monsieur"); email.addParametersItem(parameter); parameter = new Parameter(); parameter.setKey("firstName"); parameter.setValue("Jérémie"); email.addParametersItem(parameter); parameter = new Parameter(); parameter.setKey("lastName"); parameter.setValue("Zanone"); email.addParametersItem(parameter); email.setTemplate(api.getTemplate(2l).getUrl()); }
@And("^I enter attribute in the file MetaData with the following parameters:$") public void enterAttributeInMetaData(Map<String, String> parameters) { navigationRunSteps.goToConfigurationTab(); navigationRunSteps.goToResourceTab(); uploadResourceRunSteps.expandNode(parameters.get("group")); uploadResourceRunSteps.expandNode(parameters.get("componentType")); uploadResourceRunSteps.clickNode(parameters.get("componentName")); handleResourceRunSteps.clickResource(parameters.get("fileName")); handleResourceRunSteps.clickTab("Meta Data"); handleResourceRunSteps.enterAttribute(parameters.get("attributeKey"), parameters.get("attributeValue")); handleResourceRunSteps.clickSaveButton("Meta Data"); if(parameters.get("override").equals("true")){ handleResourceRunSteps.clickOk(); } handleResourceRunSteps.waitForNotification("Saved"); }
@And("^I have created a tag$") public void iHaveCreatedATag() throws Throwable { tag = new Tag(); tag.setName("Advertising"); tag.setTemplates(Collections.singletonList(template.getUrl())); api.createTag(tag); tag = api.getTags().get(api.getTags().size() - 1); assertNotNull(tag); }
@And("^I choose to register$") public void iChooseToRegister() throws Throwable { appiumDriver.findElement(By.id("hamburger")).click(); Thread.sleep(5 * 1000); appiumDriver.findElement(By.id("hamLoginLink")).click(); }
@And("^I choose \"([^\"]*)\" as my city$") public void iChooseAsMyCity(String city) throws Throwable { new LandingPage(appiumDriver).skipToHomePage(); /* TODO - Assignment - Move the try catch logic to base page */ try { if (appiumDriver.findElement(By.xpath("//android.widget.Button[@text='Later']")).isDisplayed()) appiumDriver.findElement(By.xpath("//android.widget.Button[@text='Later']")).click(); } catch (Exception e) { //do nothing } new HomePage(appiumDriver).selectCity(city); }
@And("^I change template's body$") public void iChangeTemplateSBody() throws Throwable { body = "<span th:text=\\\" 'Hello ' + ${title} + ',\n" + "My name is ' + ${firstName} + ' ' + ${lastName} + '.\n'" + "'Do you want to come to ' + ${place} + ' the ' + ${date} + ' ?\n'" + "\\\"></span>"; template.setBody(body); assertEquals(body, template.getBody()); }
@And("^I get ID of last template") public void iGetIDOfLastTemplate() throws Throwable { int size = api.getTemplates().size(); String url = api.getTemplates().get(size - 1).getUrl(); int indexOfId = url.lastIndexOf('/'); id = Long.valueOf(Integer.parseInt(url.substring(indexOfId + 1, url.length()))); assertNotEquals(0, (long) id); }
@And("^I generate and start the webserver with the following parameters:$") public void generateAndStartWebserver(Map<String, String> parameters) { navigationRunSteps.goToOperationsTab(); navigationRunSteps.expandGroupInOperationsTab(parameters.get("group")); generateWebServerRunSteps.generateIndividualWebserver(parameters.get("webserverName"), parameters.get("group")); generateWebServerRunSteps.checkForSuccessfulGenerationOfAWebserver(); startWebServersOfGroup(parameters.get("webserverName"), parameters.get("group")); startWebServerRunSteps.checkIfWebServerStateIsStarted(parameters.get("webserverName"), parameters.get("group")); }
@And("^I generate and start the jvm with the following parameters:$") public void generateAndStartJvm(Map<String, String> parameters) { navigationRunSteps.goToOperationsTab(); navigationRunSteps.expandGroupInOperationsTab(parameters.get("group")); generateJvmRunSteps.generateIndividualJvm(parameters.get("jvmName"), parameters.get("group")); generateJvmRunSteps.checkForSuccessfulGenerationIndividualJvm(); startJvmOfGroup(parameters.get("jvmName"), parameters.get("group")); startJvmRunSteps.checkIfJvmStateIsStarted(parameters.get("jvmName"), parameters.get("group")); }
@And("^I go to the web-app file in resources under individual jvm with the following parameters:$") public void goToResourceWebappUnderJvm(Map<String, String> parameters) { navigationRunSteps.goToConfigurationTab(); navigationRunSteps.goToResourceTab(); uploadResourceRunSteps.expandNode(parameters.get("group")); uploadResourceRunSteps.expandNode("JVMs"); uploadResourceRunSteps.expandNode(parameters.get("jvmName")); uploadResourceRunSteps.clickNode(parameters.get("app")); handleResourceRunSteps.selectFile(parameters.get("file")); }
@And("^I enter attribute in the group file MetaData with the following parameters:$") public void enterAttributeInGroupMetaData(Map<String, String> parameters) { navigationRunSteps.goToConfigurationTab(); navigationRunSteps.goToResourceTab(); uploadResourceRunSteps.expandNode(parameters.get("group")); uploadResourceRunSteps.expandNode(parameters.get("componentType")); uploadResourceRunSteps.clickNode(parameters.get("componentType")); handleResourceRunSteps.clickResource(parameters.get("fileName")); handleResourceRunSteps.clickTab("Meta Data"); handleResourceRunSteps.enterAttribute(parameters.get("attributeKey"), parameters.get("attributeValue")); handleResourceRunSteps.clickSaveButton("Meta Data"); //click ok to override popup handleResourceRunSteps.clickOk(); handleResourceRunSteps.waitForNotification("Saved"); }
@And("^I attempt to deploy the jvm group resource \"(.*)\"$") public void deployJvmGroupFile(String file) { handleResourceRunSteps.selectFile(file); handleResourceRunSteps.rightClickFile(file); handleResourceRunSteps.clickDeploy(); handleResourceRunSteps.confirmOverride(file); }
@And("^I created (\\d+) new templates$") public void iHaveTemplates(int arg0) throws Throwable { int oldNbTemplate = api.getTemplates().size(); template = new Template(); template.setBody("<span th:text\"= 'Bonjour ' + ${username} + ',\n" + "Bienvenue sur notre plateforme d'échange'.\n'" + "\"></span>"); template.setName("TemplateBonjour"); api.createTemplate(template); template = new Template(); template.setBody("<span th:text=\" 'Bonsoir ' + ${title} + ',\n" + "My name is ' + ${firstName} + ' ' + ${lastName} + '.\n'" + "\"></span>"); template.setName("TemplateBonsoir"); api.createTemplate(template); template = new Template(); template.setBody("<span th:text=\" 'Toute l'équipe vous souhaite de bonnes fêtes de fin d'année',\n\"></span>"); template.setName("FinAnnée"); api.createTemplate(template); int newNbTemplate = api.getTemplates().size(); assertEquals(arg0, newNbTemplate - oldNbTemplate); }
@And("^I have created a template$") public void iHaveCreatedATemplate() throws Throwable { template = new Template(); template.setName("Caco-Calo"); template.setBody("<span th:text=\" 'Hello ' + ${title} + ',\n" + "My name is ' + ${firstName} + ' ' + ${lastName} + '.\n'" + "\"></span>"); api.createTemplate(template); template = api.getTemplate((long) api.getTemplates().size()); assertNotNull(template); }
@And("^I click the login button$") public void clickLoginButton() { jwalaUi.click(By.cssSelector("input[type=\"button\"]")); }
@And("^she selects \"([^\"]*)\" from \"([^\"]*)\" dropdown$") public void selectsFromDropdown(String option, String selectId) throws Throwable { SelenideElement selectElement = $(String.format("select[name=\"%s\"]", selectId)).shouldBe(visible); selectElement.selectOption(option); }
@And("^I expand \"(.*)\" node in data tree$") public void expandPropertyDataTree(String property) { jwalaUi.clickWhenReady(By.xpath("//span[contains(@class,'nodeKey') and contains(text(),'" + property + "') ]/preceding-sibling::span")); }
@And("^I get tags of last template") public void iGetTagsOfLastTemplate() throws Throwable { tags = template.getTags(); assertTrue(tags.isEmpty()); }
@And("^I choose the meta data file \"(.*)\"$") public void selectMetaDataFile(final String archiveFileName) { final Path mediaPath = Paths.get(jwalaUi.getProperties().getProperty("resource.template.dir") + "/" + archiveFileName); jwalaUi.sendKeys(By.name("metaDataFile"), mediaPath.normalize().toString()); }
@And("^I click \"([^\"]*)\" tab$") public void clickTab(String tab) { jwalaUi.clickTab(tab); }
@And("^I click the upload resource dialog ok button$") public void clickUploadResourceDlgOkBtn() { jwalaUi.click(By.xpath("//button[span[text()='Ok']]")); }
@And("^I click resource deploy All option$") public void clickDeployAll() { jwalaUi.click(By.xpath("//*[text()='all hosts']")); }
@And("^I have sent an email$") public void iHaveSentAnEmail() throws Throwable { newNbEmailsInAPI = api.getEmails().size(); assertEquals(1, newNbEmailsInAPI - lastNbEmailsInAPI); }
@And("^I click the ok button to override JVM Templates$") public void overrideJvmTemplates() { jwalaUi.isElementExists(By.xpath("//span[contains(text(),'Saving will overwrite all')]")); clickOk(); }
@And("^I get the number of templates$") public void iGetTheNumberOfTemplates() throws Throwable { numberOfTemplates = api.getTemplates().size(); }
@And("^I fill in the \"Group Name\" field with \"(.*)\"$") public void setGroupName(final String groupName) { jwalaUi.sendKeys(By.xpath("//input[@name='name']"), groupName); }
@And("^I choose the media archive file \"(.*)\"$") public void selectMediaArchiveFile(final String archiveFileName) { final Path mediaPath = Paths.get(jwalaUi.getProperties().getProperty("media.source.dir") + "/" + archiveFileName); jwalaUi.sendKeys(By.name("mediaArchiveFile"), mediaPath.normalize().toString()); }
@And("^I change my kingdom with the kingdom of my opponent$") public void iChangeMyKingdomWithTheKingdomOfMyOpponent() throws Throwable { int[] temp = game.getCurrentPlayer().getBoard().getKingdom(); game.getCurrentPlayer().getBoard().setKingdom(game.getOpponentPlayer().getBoard().getKingdom()); game.getOpponentPlayer().getBoard().setKingdom(temp); }
@And("^I have (\\d+) more card in my kingdom$") public void iHaveMoreCardInMyKingdom(int arg0) throws Throwable { assertEquals(game.getCurrentPlayer().getBoard().getKingdom().length, is (arg0)); }
@And("^I have (\\d+) more cards in my hand$") public void iHaveMoreCardsInMyHand(int arg0) throws Throwable { assertEquals(game.getCurrentPlayer().getBoard().getHand().length, is(arg0)); }
@And("^My opponent has (\\d+) cards in his hand$") public void myOpponentHasCardsInHisHand(int arg0) throws Throwable { assertEquals(game.getOpponentPlayer().getBoard().getHand().length, is(arg0)); }
@And("^Template's body has changed$") public void templateSBodyHasChanged() throws Throwable { assertEquals(body, template.getBody()); }
@And("^I click check-box for resourceFile \"(.*)\"$") public void selectResourceCheckBox(String resourceFile) { jwalaUi.clickWhenReady(By.xpath("//li/span[text()='" + resourceFile + "']/preceding-sibling::input[@type='checkbox']")); }
@And("^I see the group add dialog$") public void checkIfAddGroupDialogBoxIsDisplayed() { jwalaUi.waitUntilElementIsVisible(By.xpath("//span[text()='Add Group']")); }
@And("^I confirm overriding individual instances popup for resourceFile \"(.*)\"$") public void confirmOverride(String resource) { jwalaUi.isElementExists(By.xpath("//*[contains(text(),'Any previous customizations to an individual instance of \"" + resource + "\" will be overwritten.')]")); clickYes(); }