@Then("^I use those accounts to login successfully and unsuccessfully$") public void loginWithDifferentUserAccounts() { for (String [] userAccount : userAccounts) { jwalaUi.loadPath("/login"); jwalaUi.sendKeys(By.id("userName"), userAccount[0]); jwalaUi.sendKeys(By.id("password"), userAccount[1]); jwalaUi.click(By.cssSelector("input[type=\"button\"]")); if (userAccount[2].equalsIgnoreCase("mainPage")) { jwalaUi.waitUntilElementIsVisible(By.className("banner-logout")); } else if (userAccount[2].equalsIgnoreCase("loginErrorMessage")) { jwalaUi.waitUntilElementIsVisible(By.className("login-error-msg")); } else { fail("Unexpected result = " + userAccount[2]); } } }
@Then("^I can see upcoming publications$") public void iCanSeeUpcomingPublications() throws Throwable { final List<Publication> expectedPublications = testDataRepo.getPublications(UPCOMING); final List<UpcomingPublicationOverivewWidget> actualPublicationEntries = publicationsOverviewPage.getUpcomingPublicationsWidgets(); assertThat("Should display correct quantity of upcoming publications.", actualPublicationEntries, hasSize(expectedPublications.size()) ); for (int i = 0; i < expectedPublications.size(); i++) { assertThat("Should display upcoming publication.", actualPublicationEntries.get(i), matchesUpcomingPublication(expectedPublications.get(i)) ); } }
@Then("^the rolled up point on \"([^\"]*)\" (\\d+) \"([^\"]*)\" will be purged$") public void theRolledUpPointOnWillBePurged(String timestampState, long timestampDiff, String timestampUnit) throws Throwable { String sql = "" + " SELECT * FROM point_" + rollUp.getTargetGranularity() + " WHERE \"metric_id\" = ? " + " AND \"timestamp\" = ? " + " AND \"aggregation\" = ? "; Timestamp timestamp = resolveTimestamp(timestampState, timestampDiff, timestampUnit); try (Connection connection = pugTSDB.getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) { statement.setInt(1, metric.getId()); statement.setTimestamp(2, timestamp); statement.setString(3, aggregation.getName()); ResultSet resultSet = statement.executeQuery(); assertFalse(resultSet.next()); } }
/** * Check JHipsterSampleApp portal page. * * @throws FailureException * if the scenario encounters a functional error. */ @Then("The JHIPSTERSAMPLEAPP portal is displayed") public void checkJHipsterSampleAppPage() throws FailureException { try { Context.waitUntil(ExpectedConditions.presenceOfElementLocated(Utilities.getLocator(jHipsterSampleAppPage.signInMessage))); if (!jHipsterSampleAppPage.isDisplayed()) { logInToJHipsterSampleAppWithNoraRobot(); } if (!jHipsterSampleAppPage.checkPage()) { new Result.Failure<>(jHipsterSampleAppPage.getApplication(), Messages.FAIL_MESSAGE_UNKNOWN_CREDENTIALS, true, jHipsterSampleAppPage.getCallBack()); } } catch (Exception e) { new Result.Failure<>(jHipsterSampleAppPage.getApplication(), Messages.FAIL_MESSAGE_UNKNOWN_CREDENTIALS, true, jHipsterSampleAppPage.getCallBack()); } Auth.setConnected(true); }
@Then("^the rolled up point on \"([^\"]*)\" (\\d+) \"([^\"]*)\" wont be purged$") public void theRolledUpPointOnWontBePurged(String timestampState, long timestampDiff, String timestampUnit) throws Throwable { String sql = "" + " SELECT * FROM point_" + rollUp.getTargetGranularity() + " WHERE \"metric_id\" = ? " + " AND \"timestamp\" = ? " + " AND \"aggregation\" = ? "; Timestamp timestamp = resolveTimestamp(timestampState, timestampDiff, timestampUnit); try (Connection connection = pugTSDB.getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(sql)) { statement.setInt(1, metric.getId()); statement.setTimestamp(2, timestamp); statement.setString(3, aggregation.getName()); ResultSet resultSet = statement.executeQuery(); assertTrue(resultSet.next()); } }
@Then("^The following dependencies are excluded from \"([^\"]*) ([^\"]*)\":$") public void theFollowingDependenciesAreExcludedFrom(String configuration, String from, List<String> exclusions) throws Throwable { JsonObject reportForProject = report.getAsJsonObject(projectName); assertThat(reportForProject).describedAs("Report for " + projectName).isNotNull(); for (JsonElement dependency : reportForProject.getAsJsonArray(configuration)) { JsonObject dependencyObject = dependency.getAsJsonObject(); if (from.equals(dependencyObject.get("coordinates").getAsString())) { assertThat(dependencyObject.getAsJsonArray("excludes")) .extracting(JsonObject.class::cast) .extracting(it -> { String group = it.get("group").getAsString(); JsonElement module = it.get("module"); if (module.isJsonNull()) { return group; } return group + ":" + module.getAsString(); }) .containsAll(exclusions); break; } } }
@Then("^I should not see headers:$") public void iShouldNotSeeHeaders(DataTable headersTable) throws Throwable { List<String> headers = headersTable.asList(String.class); for (String header : headers) { assertNull("Header should not be displayed", sitePage.findElementWithText(header)); } }
/** * Loop on steps execution for a specific number of times. * * @param actual * actual value for global condition. * @param expected * expected value for global condition. * @param times * Number of loops. * @param steps * List of steps run in a loop. */ @Lorsque("Si '(.*)' vérifie '(.*)', je fais '(.*)' fois:") @Then("If '(.*)' matches '(.*)', I do '(.*)' times:") public void loop(String actual, String expected, int times, List<GherkinConditionedLoopedStep> steps) { try { if (new GherkinStepCondition("loopKey", expected, actual).checkCondition()) { for (int i = 0; i < times; i++) { runAllStepsInLoop(steps); } } } catch (TechnicalException e) { throw new AssertError(Messages.getMessage(TechnicalException.TECHNICAL_SUBSTEP_ERROR_MESSAGE) + e.getMessage()); } }
@Then("^I should see the page not found error page$") public void iShouldSeeThePageNotFoundErrorPage() throws Throwable { // Ideally we would check the HTTP response code is 404 as well but it's not // currently possible to do this with the Selinium Web Driver. // See https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/141 iShouldSeePageTitled("Page not found"); }
@Then("^I receive a list of suggestions, with \"([^\"]*)\"$") public void i_receive_a_list_of_suggestions_with(String arg1) throws Throwable { driver.get(baseUrl+"/"); SeleniumUtils.entrarComoUsuario(driver); SeleniumUtils.EsperaCargaPagina(driver, "id", "crear", 10); SeleniumUtils.textoPresentePagina(driver, arg1); }
@Then("^the original hexes at the coordinates are removed$") public void the_original_hexes_at_the_coordinates_are_removed() throws Throwable { // Write code here that turns the phrase above into concrete actions //check lvl >1 Hex hex = gameBoard.getHexFromCoordinate(new Coordinate(100,100)); int level = hex.getLevel(); if(level == 1){ fail("Level not incremented"); } }
@Then("^the new tile is saved at those coordinates$") public void the_new_tile_is_saved_at_those_coordinates() throws Throwable { ArrayList<Tile> placedTiles = gameBoard.getPlacedTiles(); Tile tile = placedTiles.get(2); ArrayList<Coordinate> coords = tile.getCoords(); if(!(coords.get(0).getX() == 100 && coords.get(0).getY() == 100 && coords.get(1).getX()==101 && coords.get(1).getY()==100 && coords.get(2).getX()==101 && coords.get(2).getY()== 101)){ fail("Tile not saved at new coordinates"); } }
@Then("^flow rules should not be cleared up") public void checkFlowRules() { FlowRules result = CLIENT .target(DefaultParameters.FLOODLIGHT_ENDPOINT) .path(ACL_RULES_PATH) .request() .get(FlowRules.class); assertTrue("Floodlight should send flow rules", result != null && result.getFlows() != null); String expectedCookie = String.valueOf(Long.parseLong(COOKIE.substring(2), 16)); assertThat(result.getFlows(), hasItem(hasProperty("cookie", is(expectedCookie)))); dockerClient.close(); }
@Then("^the table should contain (\\d+) items$") public void theTableShouldContainItems(final int count) throws Throwable { notLoadingAnymore(); eventually(() -> { final List<WebElement> rows = webDriver.findElement(By.tagName("table")) .findElement(By.tagName("tbody")) .findElements(By.tagName("tr")); assertEquals(count, rows.size()); return null; }); }
@Then("^I can see the password error messages$") public void iCanSeeThePasswordErrorMessages() throws Throwable { assertThat("Password error is displayed", dashboardPage.getPasswordErrorMessages(), hasItems( equalTo("Password must be at least 12 characters long"), equalTo("Password may not be the same as previous 5 passwords"), equalTo("Password must not contain user name, first name or last name"), containsString("Password should contain at least one capitalized letter"), containsString("Password should contain at least one lower case letter"), containsString("Password should contain at least one digit") ) ); }
@Then("^now amount of switches is (\\d+)\\.$") public void the_switch_appears_in_the_topology_engine(int switches) throws Exception { List<SwitchInfoData> switchList = SwitchesUtils.dumpSwitches(); List<SwitchInfoData> activeSwitches = switchList.stream() .filter(sw -> sw.getState() == SwitchState.ACTIVATED) .collect(Collectors.toList()); assertThat("Switch should disappear from neo4j", activeSwitches.size(), is(switches)); }
@Then("^I should see headers:$") public void iShouldSeeHeaders(DataTable headersTable) throws Throwable { List<String> headers = headersTable.asList(String.class); for (String header : headers) { assertNotNull("Header should be displayed: " + header, sitePage.findElementWithText(header)); } }
@Then("^she separates \"([^\"]*)\" into \"(\\w+)\" as \"(\\w+)\" and \"(\\w+)\" as \"(\\w+)\" using \"(\\w+)\" separator$") public void separatePresentFielsIntoTwo(String input, String output1, String first_pos, String output2, String second_pos, String separator) { SelenideElement inputElement; SelenideElement selectElement; //inputElement = mapper.getElementByAlias("FirstSource").shouldBe(visible); //mapper.fillInput(inputElement, input); selectElement = mapper.getElementByAlias("ActionSelect").shouldBe(visible); mapper.selectOption(selectElement, "Separate"); selectElement = mapper.getElementByAlias("SeparatorSelect").shouldBe(visible); mapper.selectOption(selectElement, separator); // NOTE: THIS STEP SHOULD HAVE BEEN DONE AUTOMATICALLY BY SELECTING "Separate" action mapper.clickButton("Add Target"); inputElement = mapper.getElementByAlias("FirstTarget").shouldBe(visible); mapper.fillInputAndConfirm(inputElement, output1); inputElement = mapper.getElementByAlias("FirstTargetPosition").shouldBe(visible); mapper.fillInput(inputElement, first_pos); inputElement = mapper.getElementByAlias("SecondTarget").shouldBe(visible); mapper.fillInputAndConfirm(inputElement, output2); inputElement = mapper.getElementByAlias("SecondTargetPosition").shouldBe(visible); mapper.fillInput(inputElement, second_pos); }
@Then("^the response should contain a \"([^\"]*)\"$") public void the_response_should_contain_a(String memberName) throws Throwable { String[] path = memberName.split("[.]"); Object member = ReflectionUtils.getByPath(result, Arrays.asList(path)); assertNotNull(member); }
/** * @param first parameter to be combined. * @param first_pos position of the first parameter in the final string * @param second parameter to be combined. * @param sec_pos position of the second parameter in the final string. * @param combined above two into this parameter. * @param separator used to estethically join first and second parameter. */ // And she combines "FirstName" as "2" with "LastName" as "1" to "first_and_last_name" using "Space" separator @Then("^she combines \"(\\w+)\" as \"(\\w+)\" with \"(\\w+)\" as \"(\\w+)\" to \"(\\w+)\" using \"(\\w+)\" separator$") public void combinePresentFielsWithAnother(String first, String first_pos, String second, String sec_pos, String combined, String separator) { SelenideElement inputElement; SelenideElement selectElement; // Then she fills "FirstCombine" selector-input with "FirstName" value inputElement = mapper.getElementByAlias("FirstSource").shouldBe(visible); mapper.fillInput(inputElement, first); // And she selects "Combine" from "ActionSelect" selector-dropdown selectElement = mapper.getElementByAlias("ActionSelect").shouldBe(visible); mapper.selectOption(selectElement, "Combine"); // And she selects "Space" from "SeparatorSelect" selector-dropdown selectElement = mapper.getElementByAlias("SeparatorSelect").shouldBe(visible); mapper.selectOption(selectElement, separator); // And clicks on the "Add Source" link mapper.clickButton("Add Source"); // Then she fills "SecondCombine" selector-input with "LastName" value inputElement = mapper.getElementByAlias("SecondSource").shouldBe(visible); mapper.fillInputAndConfirm(inputElement, second); // And she fills "FirstCombinePosition" selector-input with "2" value inputElement = mapper.getElementByAlias("FirstSourcePosition").shouldBe(visible); mapper.fillInput(inputElement, first_pos); // And she fills "SecondCombinePosition" selector-input with "1" value inputElement = mapper.getElementByAlias("SecondSourcePosition").shouldBe(visible); mapper.fillInput(inputElement, sec_pos); // Then she fills "TargetCombine" selector-input with "first_and_last_name" value // inputElement = mapper.getElementByAlias("FirstTarget").shouldBe(visible); // mapper.fillInputAndConfirm(inputElement, combined); }
@Then("^status of flow (.*) could be read$") public void checkFlowStatus(final String flowId) throws Exception { String flowName = FlowUtils.getFlowName(flowId); FlowIdStatusPayload payload = getFlowState(flowName, expectedFlowStatus); assertNotNull(payload); assertEquals(flowName, payload.getId()); assertEquals(expectedFlowStatus, payload.getStatus()); }
@Then("^flows dump contains (\\d+) flows$") public void checkDumpFlows(final int flowCount) { List<FlowPayload> flows = FlowUtils.getFlowDump(); assertNotNull(flows); flows.forEach(flow -> System.out.println(flow.getId())); assertEquals(flowCount, flows.size()); }
@Then("^validate SF on delete to DB created new task with lead ID as task name") public void validateLead() { final long start = System.currentTimeMillis(); // We wait for exactly 1 record to appear in DB. final boolean contactCreated = TestUtils.waitForEvent(leadCount -> leadCount == 1, () -> dbUtils.getNumberOfRecordsInTable(RestConstants.getInstance().getTODO_APP_NAME()), TimeUnit.MINUTES, 2, TimeUnit.SECONDS, 5); Assertions.assertThat(contactCreated).as("Lead record has appeard in db").isEqualTo(true); log.info("Lead record appeared in DB. It took {}s to create contact.", TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - start)); // Now we verify, the created lead contains the correct personal information. Assertions.assertThat(getLeadTaskFromDb(leadId).toLowerCase()).isNotEmpty(); }
@Then("^wait for Syndesis to become ready") public void waitForSyndeisis() { try { OpenShiftWaitUtils.waitFor(OpenShiftWaitUtils.isAPodReady("component", "syndesis-rest")); } catch (InterruptedException | TimeoutException e) { log.error("Wait for syndesis-rest failed ", e); } }
@Then("^no tags are saved$") public void noTagsAreSaved() throws Throwable { try (Connection connection = pugTSDB.getDataSource().getConnection(); Statement statement = connection.createStatement()) { ResultSet resultSet = statement.executeQuery("SELECT * FROM tag"); assertFalse(resultSet.next()); } }
@Then("^I should see publication in search results$") public void iShouldSeePublicationInSearchResults() throws Throwable { String expectedTitle = testDataRepo.getCurrentPublication().getTitle(); List<String> actualResults = searchPage.getSearchResultWidgets() .stream() .map(SearchResultWidget::getTitle) .collect(toList()); assertThat("Publication is in the results", actualResults, hasItem(expectedTitle)); }
@Then("^the CodeSystem should save$") public void the_CodeSystem_should_save() throws Throwable { try { conceptDao.storeNewCodeSystemVersion( cs,null); // fail(); } catch (InvalidRequestException e) { assertEquals("CodeSystem contains circular reference around code parent", e.getMessage()); } }
/** * Check Customer page. * * @throws FailureException * if the scenario encounters a functional error. */ @Then("The JHIPSTERSAMPLEAPP customer page is displayed") public void checkJHipsterSampleAppCustomerPage() throws FailureException { if (!customerPage.checkPage()) { new Result.Failure<>(customerPage.getApplication(), String.format(Messages.FAIL_MESSAGE_UNABLE_TO_OPEN_PAGE, customerPage.getPageKey()), true, customerPage.getCallBack()); } }
@Then("^I see the thread dump page$") public void verifyThreadDumpPage() { jwalaUi.switchToOtherTab(origWindowHandle); jwalaUi.waitUntilElementIsVisible(By.xpath("//pre[contains(text(), 'thread dump Java HotSpot(TM) 64-Bit Server VM')]")); if (origWindowHandle != null) { jwalaUi.getWebDriver().close(); jwalaUi.getWebDriver().switchTo().window(origWindowHandle); } }
@Then("^policy evaluation response includes subject attribute (.*) with the value (.*)$") public void policyEvaluationReturns(final String attributeName, final String attributeValue) throws Throwable { Assert.assertEquals(this.policyEvaluationResponse.getStatusCode(), HttpStatus.OK); Set<Attribute> subjectAttributes = new HashSet<Attribute>( this.policyEvaluationResponse.getBody().getSubjectAttributes()); Assert.assertTrue( subjectAttributes.contains(new Attribute(DEFAULT_ATTRIBUTE_ISSUER, attributeName, attributeValue)), String.format("Subject Attributes expected to include attribute = (%s, %s, %s)", DEFAULT_ATTRIBUTE_ISSUER, attributeName, attributeValue)); }
@Then("^message \"([^\"]*)\" is displayed$") public void message_is_displayed(String expectedOutput) throws Throwable { // Cucumber on outo olento expectedOutput = expectedOutput.replace("\\n", "\n"); boolean found = false; for (String print : io.getPrints()) { if (print.contains(expectedOutput)) { found = true; } } assertTrue(found); }
@Then("^settings item \"(\\w+)\" must have alert with text \"(\\w+)\"$") public void assertSettingsAlertText(String itemTitle, String alertText) { OAuthSettingsComponent settings = settingsPage.getOauthSettingsComponent(); assertThat(settings.getAlertText(itemTitle), containsString(alertText)); }
@Then("^his first name is '(.*)'$") public void his_first_name_is(String firstName) throws Throwable { actions.andExpect(jsonPath("$.firstName").value(firstName)); }
@Then("^Result should be (.+)$") public void result_should_be(String expected) throws Throwable { Assert.assertEquals(expected, URL_concat); }
@Then("^I select \"([^\"]*)\" text on element having (id|name|class|xpath|css) \"([^\"]*)\"$") public void selectTextOnElement(String text, String type, String element){ new Select(getWebElement(type, element)).selectByVisibleText(text); }
@Then("^The card korrigan is added to my kingdom, its power is activate$") public void theCardKorriganIsAddedToMyKingdomItsPowerIsActivate() throws Throwable { game.getCurrentPlayer().getBoard().getKingdom()[1]++; cardKorrigan.activatePower(game); }
@Then("^go to \"([^\"]*)\"$") public void goTo(String uri) throws Throwable { goToURL(uri); }
@Then("^CucumberSetup was post constructed") public void postconstructed() { verify(mockBean).postConstruct(); }
@Then("^user is logged in$") public void user_is_logged_in() throws Throwable { pageHasContent("Ohtu Application main page"); }
@Then("^I take screenshot") public void screenshot() { final String name = String.format(SCREENSHOT_FORMAT, new Date()); ScreenshotHook.createScreenshot(name); }