java类cucumber.api.java.en.Then的实例源码

BatchLoginRunSteps.java 文件源码 项目:jwala 阅读 19 收藏 0 点赞 0 评论 0
@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]);
        }
    }
}
PublicationSteps.java 文件源码 项目:hippo 阅读 18 收藏 0 点赞 0 评论 0
@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))
        );
    }
}
RollUpPurgeSteps.java 文件源码 项目:pugtsdb 阅读 45 收藏 0 点赞 0 评论 0
@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());
    }
}
JHipsterSampleAppSteps.java 文件源码 项目:noraui-academy 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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);
}
RollUpPurgeSteps.java 文件源码 项目:pugtsdb 阅读 20 收藏 0 点赞 0 评论 0
@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());
    }
}
GradleStepdefs.java 文件源码 项目:gradle-maven-sync-plugin 阅读 21 收藏 0 点赞 0 评论 0
@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;
    }
  }
}
SiteSteps.java 文件源码 项目:hippo 阅读 20 收藏 0 点赞 0 评论 0
@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));
    }
}
CommonSteps.java 文件源码 项目:NoraUi 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
SiteSteps.java 文件源码 项目:hippo 阅读 23 收藏 0 点赞 0 评论 0
@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");
}
AllTest.java 文件源码 项目:participationSystem3b 阅读 16 收藏 0 点赞 0 评论 0
@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);
}
GridStepDefs.java 文件源码 项目:TigerIsland 阅读 17 收藏 0 点赞 0 评论 0
@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");
    }

}
GridStepDefs.java 文件源码 项目:TigerIsland 阅读 15 收藏 0 点赞 0 评论 0
@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");

    }

}
ClearTablesTest.java 文件源码 项目:open-kilda 阅读 15 收藏 0 点赞 0 评论 0
@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();
}
SeleniumSteps.java 文件源码 项目:testee.fi-examples 阅读 17 收藏 0 点赞 0 评论 0
@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;
    });
}
LoginSteps.java 文件源码 项目:hippo 阅读 18 收藏 0 点赞 0 评论 0
@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")
        )
    );
}
TopologyEventsBasicTest.java 文件源码 项目:open-kilda 阅读 17 收藏 0 点赞 0 评论 0
@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));
}
SiteSteps.java 文件源码 项目:hippo 阅读 19 收藏 0 点赞 0 评论 0
@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));
    }
}
DataMapperSteps.java 文件源码 项目:syndesis-qe 阅读 23 收藏 0 点赞 0 评论 0
@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);

}
AWSCucumberStepdefs.java 文件源码 项目:ibm-cos-sdk-java 阅读 18 收藏 0 点赞 0 评论 0
@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);
}
DataMapperSteps.java 文件源码 项目:syndesis-qe 阅读 18 收藏 0 点赞 0 评论 0
/**
     * @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);
    }
NorthboundRunTest.java 文件源码 项目:open-kilda 阅读 21 收藏 0 点赞 0 评论 0
@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());
}
NorthboundRunTest.java 文件源码 项目:open-kilda 阅读 25 收藏 0 点赞 0 评论 0
@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());
}
SfDbValidationSteps.java 文件源码 项目:syndesis-qe 阅读 19 收藏 0 点赞 0 评论 0
@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();
}
CommonSteps.java 文件源码 项目:syndesis-qe 阅读 23 收藏 0 点赞 0 评论 0
@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);
    }
}
UpsertionSteps.java 文件源码 项目:pugtsdb 阅读 20 收藏 0 点赞 0 评论 0
@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());
    }
}
SearchSteps.java 文件源码 项目:hippo 阅读 19 收藏 0 点赞 0 评论 0
@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));
}
JPAStepsDef.java 文件源码 项目:careconnect-reference-implementation 阅读 21 收藏 0 点赞 0 评论 0
@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());
    }
}
CustomerSteps.java 文件源码 项目:noraui-academy 阅读 16 收藏 0 点赞 0 评论 0
/**
 * 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());
    }
}
ThreadDumpRunSteps.java 文件源码 项目:jwala 阅读 16 收藏 0 点赞 0 评论 0
@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);
    }
}
PolicyEvaluationStepsDefinitions.java 文件源码 项目:keti 阅读 18 收藏 0 点赞 0 评论 0
@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));
}


问题


面经


文章

微信
公众号

扫码关注公众号