io.cucumber.java.en.And Java Examples

The following examples show how to use io.cucumber.java.en.And. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RESTSteps.java    From NoraUi with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Save result of REST API in memory if all 'expected' parameters equals 'actual' parameters in conditions.
 * 
 * @param method
 *            GET or POST
 * @param pageKey
 *            is the key of page (example: GOOGLE_HOME)
 * @param uri
 *            end of the url
 * @param targetKey
 *            Target key to save retrieved value.
 * @param conditions
 *            List of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
 * @throws TechnicalException
 *             is thrown if you have a technical error (format, configuration, datas, ...) in NoraUi.
 *             Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_EMPTY_DATA} message (no screenshot)
 * @throws FailureException
 *             if the scenario encounters a functional error
 */
@Conditioned
@Et("Je sauvegarde la valeur de cette API REST {string} {string} {string} dans {string} du contexte(\\?)")
@And("I save the value of REST API {string} {string} {string} in {string} context key(\\?)")
public void saveValue(String method, String pageKey, String uri, String targetKey, List<GherkinStepCondition> conditions) throws TechnicalException, FailureException {
    log.debug("saveValue of REST API with method [{}].", method);
    log.debug("saveValue of REST API with pageKey [{}].", pageKey);
    log.debug("saveValue of REST API with uri [{}].", uri);
    log.debug("saveValue of REST API in targetKey [{}].", targetKey);
    String json = null;
    try {
        json = httpService.get(Context.getUrlByPagekey(pageKey), uri);
    } catch (HttpServiceException e) {
        log.error(Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_CALL_API_REST), e);
        new Result.Failure<>(Context.getApplicationByPagekey(pageKey), Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_CALL_API_REST), false,
                Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
    }
    Context.saveValue(targetKey, json);
    Context.getCurrentScenario().write(PREFIX_SAVE + targetKey + "=" + json);
}
 
Example #2
Source File: AthenaQuerySteps.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@And("the administrator can analyze the data with Athena queries")
public void the_administrator_can_analyze_the_data_with_athena_queries() throws InterruptedException {
  String loadPartitionsQuery = String.format("MSCK REPAIR TABLE `%s`.`%s`;",
      ssmParameterCachingClient.getAsString("glue/database"),
      ssmParameterCachingClient.getAsString("glue/table/applications")
  );

  String createdAppQuery = "SELECT detail.eventname,\n" +
      "         detail.dynamodb.keys.applicationid.s AS applicationid,\n" +
      "         detail.dynamodb.keys.userid.s AS userid,\n" +
      "         detail.dynamodb.newimage.author.s AS author,\n" +
      "         detail.dynamodb.newimage.description.s AS description\n" +
      String.format("FROM \"%s\".\"%s\"\n",
          ssmParameterCachingClient.getAsString("glue/database"),
          ssmParameterCachingClient.getAsString("glue/table/applications")) +
      String.format("WHERE detail.dynamodb.keys.applicationid.s='%s' limit 10", TestEnv.getApplicationId());

  List<Row> rows = Collections.emptyList();
  int attempts = 0;
  while (rows.size() < 2 && attempts < 10) {
    log.info("Waiting for Firehose to flush it's buffer into S3...");
    Thread.sleep(30000);
    runAthenaQuery(loadPartitionsQuery);
    rows = runAthenaQuery(createdAppQuery);
    attempts++;
  }

  assertThat(rows).hasSizeGreaterThan(1); // Results always have 1 row of headers
  assertThat(rows.get(1).data().get(0).varCharValue()).isEqualTo("INSERT");
  assertThat(rows.get(1).data().get(1).varCharValue()).isEqualTo(TestEnv.getApplication().getApplicationId());
  assertThat(rows.get(1).data().get(3).varCharValue()).isEqualTo(TestEnv.getApplication().getAuthor());
  assertThat(rows.get(1).data().get(4).varCharValue()).isEqualTo(TestEnv.getApplication().getDescription());
}
 
Example #3
Source File: BrowserSteps.java    From NoraUi with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Restart WebDriver with a {@link Context#clear()}.
 */
@Et("Je redémarre le web driver")
@And("I restart the web driver")
public void restartWebDriver() {
    Context.clear();
    Auth.setConnected(false);
}
 
Example #4
Source File: ScreenSteps.java    From NoraUi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Conditioned
@Et("Je défile vers {string}(\\?)")
@And("I scroll to {string}(\\?)")
public void scrollIntoView(PageElement pageElement, List<GherkinStepCondition> conditions) {
    log.debug("I scroll to [{}]", pageElement);
    screenService.scrollIntoView(Wait.until(ExpectedConditions.presenceOfElementLocated(Utilities.getLocator(pageElement))));
}
 
Example #5
Source File: ScreenSteps.java    From NoraUi with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Take a screenshot and add to result.
 *
 * @param conditions
 *            list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
 */
@Conditioned
@Et("Je prends une capture d'écran(\\?)")
@And("I take a screenshot(\\?)")
public void takeScreenshot(List<GherkinStepCondition> conditions) {
    log.debug("I take a screenshot for [{}] scenario.", Context.getCurrentScenario());
    screenService.takeScreenshot(Context.getCurrentScenario());
}
 
Example #6
Source File: MailSteps.java    From NoraUi with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Valid activation email.
 *
 * @param mailHost
 *            example: imap.gmail.com
 * @param mailUser
 *            login of mail box
 * @param mailPassword
 *            password of mail box
 * @param senderMail
 *            sender of mail box
 * @param subjectMail
 *            subject of mail box
 * @param firstCssQuery
 *            the first matching element
 * @param conditions
 *            list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
 * @throws TechnicalException
 *             is throws if you have a technical error (format, configuration, datas, ...) in NoraUi.
 *             Exception with message and with screenshot and with exception if functional error but no screenshot and no exception if technical error.
 * @throws FailureException
 *             if the scenario encounters a functional error
 */
@Experimental(name = "validActivationEmail")
@RetryOnFailure(attempts = 3, delay = 60)
@Conditioned
@Et("Je valide le mail d'activation {string}(\\?)")
@And("I valid activation email {string}(\\?)")
public void validActivationEmail(String mailHost, String mailUser, String mailPassword, String senderMail, String subjectMail, String firstCssQuery, List<GherkinStepCondition> conditions)
        throws FailureException, TechnicalException {
    try {
        final Properties props = System.getProperties();
        props.setProperty("mail.store.protocol", "imap");
        final Session session = Session.getDefaultInstance(props, null);
        final Store store = session.getStore("imaps");
        store.connect(mailHost, mailUser, mailPassword);
        final Folder inbox = store.getFolder("Inbox");
        inbox.open(Folder.READ_ONLY);
        final SearchTerm filterA = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
        final SearchTerm filterB = new FromTerm(new InternetAddress(senderMail));
        final SearchTerm filterC = new SubjectTerm(subjectMail);
        final SearchTerm[] filters = { filterA, filterB, filterC };
        final SearchTerm searchTerm = new AndTerm(filters);
        final Message[] messages = inbox.search(searchTerm);
        for (final Message message : messages) {
            validateActivationLink(subjectMail, firstCssQuery, message);
        }
    } catch (final Exception e) {
        new Result.Failure<>("", Messages.format(Messages.getMessage(Messages.FAIL_MESSAGE_MAIL_ACTIVATION), subjectMail), false, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
    }
}
 
Example #7
Source File: MathsSteps.java    From NoraUi with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @since 4.2.3
 * @param targetKey
 *            is target key for the context.
 * @param params
 *            contains format ("Integer" by default)
 *            and the list of possible operator (plus, minus, multiplies, divides)
 * @throws FailureException
 *             if the scenario encounters a functional error
 */
@Et("Je change la valeur et je sauvegarde dans la clé {string} du contexte:")
@And("I change value and I save in {string} context key:")
public void changeValue(String targetKey, Map<String, String> params) throws FailureException {
    try {
        String after = "";
        String format = params.getOrDefault(FORMAT, DEFAULT_FORMAT);
        String plus = params.getOrDefault("plus", "0");
        String minus = params.getOrDefault("minus", "0");
        String multiplies = params.getOrDefault("multiplies", "1");
        String divides = params.getOrDefault("divides", "1");
        switch (format) {
            case DEFAULT_FORMAT:
                int value = Integer.parseInt(Context.getValue(targetKey));
                value += Integer.parseInt(plus);
                value -= Integer.parseInt(minus);
                value = value * Integer.parseInt(multiplies);
                value = value / Integer.parseInt(divides);
                after = String.valueOf(value);
                break;
            default:
                new Result.Failure<>("", Messages.getMessage(Messages.FAIL_MESSAGE_FORMAT), false, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
                break;
        }
        Context.saveValue(targetKey, after);
        Context.getCurrentScenario().write(PREFIX_SAVE + targetKey + "=" + after);
    } catch (Exception e) {
        new Result.Failure<>(e, Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_CHANGE_VALUE), false, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
    }
}
 
Example #8
Source File: TimeSteps.java    From NoraUi with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @param targetKey
 *            is target key for the context.
 * @param params
 *            contains formatter ("yyyy-MM-dd" by default), zone ("Europe/London" by default)
 *            and the list of possible add (plusNanos, plusSeconds, plusMinutes, plusHours, plusDays, plusWeeks, plusMonths)
 *            and the list of possible sub (minusNanos, minusSeconds, minusMinutes, minusHours, minusDays, minusWeeks, minusMonths).
 * @throws FailureException
 *             if the scenario encounters a functional error
 */
@Et("Je change la date et je sauvegarde dans la clé {string} du contexte:")
@And("I change date and I save in {string} context key:")
public void changeDate(String targetKey, Map<String, String> params) throws FailureException {
    try {
        final String value = Context.getValue(targetKey);
        String formatter = params.getOrDefault(FORMATTER, DEFAULT_DATE_FORMAT);
        String zone = params.getOrDefault("zone", DEFAULT_ZONE_ID);
        String plusNanos = params.getOrDefault("plusNanos", "0");
        String plusSeconds = params.getOrDefault("plusSeconds", "0");
        String plusMinutes = params.getOrDefault("plusMinutes", "0");
        String plusHours = params.getOrDefault("plusHours", "0");
        String plusDays = params.getOrDefault("plusDays", "0");
        String plusWeeks = params.getOrDefault("plusWeeks", "0");
        String plusMonths = params.getOrDefault("plusMonths", "0");
        String minusNanos = params.getOrDefault("minusNanos", "0");
        String minusSeconds = params.getOrDefault("minusSeconds", "0");
        String minusMinutes = params.getOrDefault("minusMinutes", "0");
        String minusHours = params.getOrDefault("minusHours", "0");
        String minusDays = params.getOrDefault("minusDays", "0");
        String minusWeeks = params.getOrDefault("minusWeeks", "0");
        String minusMonths = params.getOrDefault("minusMonths", "0");
        LocalDate localDate = LocalDate.parse(value, DateTimeFormatter.ofPattern(formatter));
        ZonedDateTime dateTime = localDate.atStartOfDay(ZoneId.of(zone));
        dateTime = dateTime.plusNanos(Integer.parseInt(plusNanos)).plusSeconds(Integer.parseInt(plusSeconds)).plusMinutes(Integer.parseInt(plusMinutes)).plusHours(Integer.parseInt(plusHours))
                .plusDays(Integer.parseInt(plusDays)).plusWeeks(Integer.parseInt(plusWeeks)).plusMonths(Integer.parseInt(plusMonths)).minusNanos(Integer.parseInt(minusNanos))
                .minusSeconds(Integer.parseInt(minusSeconds)).minusMinutes(Integer.parseInt(minusMinutes)).minusHours(Integer.parseInt(minusHours)).minusDays(Integer.parseInt(minusDays))
                .minusWeeks(Integer.parseInt(minusWeeks)).minusMonths(Integer.parseInt(minusMonths));
        String after = dateTime.format(DateTimeFormatter.ofPattern(formatter));
        Context.saveValue(targetKey, after);
        Context.getCurrentScenario().write(PREFIX_SAVE + targetKey + "=" + after);
    } catch (Exception e) {
        new Result.Failure<>("", Messages.getMessage(Messages.FAIL_MESSAGE_DATE_FORMATTER), false, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
    }
}
 
Example #9
Source File: TimeSteps.java    From NoraUi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Et("J\'initialise une date avec aujourd\'hui moins {int} en jours ouvrés et je sauvegarde dans la clé {string} du contexte:")
@And("I initialize a date with today minus {int} in business days and I save in {string} context key:")
public void initializeBusinessDayWithMinus(int offsetDay, String targetKey, Map<String, String> params) throws FailureException {
    try {
        String formatter = params.getOrDefault(FORMATTER, DEFAULT_DATE_FORMAT);
        String zone = params.getOrDefault("zone", DEFAULT_ZONE_ID);
        String date = timeService.getDayMinusXBusinessDay(offsetDay, zone, formatter);
        Context.saveValue(targetKey, date);
        Context.getCurrentScenario().write(PREFIX_SAVE + targetKey + "=" + date);
    } catch (Exception e) {
        new Result.Failure<>("", Messages.getMessage(Messages.FAIL_MESSAGE_DATE_FORMATTER), false, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
    }
}
 
Example #10
Source File: TimeSteps.java    From NoraUi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Et("J\'initialise une date avec aujourd\'hui plus {int} en jour ouvrés et je sauvegarde dans la clé {string} du contexte:")
@And("I initialize a date with today plus {int} in business day and I save in {string} context key:")
public void initializeBusinessDayWithAdd(int offsetDay, String targetKey, Map<String, String> params) throws FailureException {
    try {
        String formatter = params.getOrDefault(FORMATTER, DEFAULT_DATE_FORMAT);
        String zone = params.getOrDefault("zone", DEFAULT_ZONE_ID);
        String date = timeService.getDayPlusXBusinessDay(offsetDay, zone, formatter);
        Context.saveValue(targetKey, date);
        Context.getCurrentScenario().write(PREFIX_SAVE + targetKey + "=" + date);
    } catch (Exception e) {
        new Result.Failure<>("", Messages.getMessage(Messages.FAIL_MESSAGE_DATE_FORMATTER), false, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
    }
}
 
Example #11
Source File: TimeSteps.java    From NoraUi with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * @param targetKey
 *            is target key for the context.
 * @param params
 *            contains formatter ("yyyy-MM-dd" by default), zone ("Europe/London" by default)
 * @throws FailureException
 *             if the scenario encounters a functional error
 */
@Et("J\'initialise une date et je sauvegarde dans la clé {string} du contexte:")
@And("I initialize a date and I save in {string} context key:")
public void initDateInContext(String targetKey, Map<String, String> params) throws FailureException {
    try {
        String formatter = params.getOrDefault(FORMATTER, DEFAULT_DATE_FORMAT);
        String zone = params.getOrDefault("zone", DEFAULT_ZONE_ID);
        String date = ZonedDateTime.now(ZoneId.of(zone)).format(DateTimeFormatter.ofPattern(formatter));
        Context.saveValue(targetKey, date);
        Context.getCurrentScenario().write(PREFIX_SAVE + targetKey + "=" + date);
    } catch (Exception e) {
        new Result.Failure<>("", Messages.getMessage(Messages.FAIL_MESSAGE_DATE_FORMATTER), false, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
    }
}
 
Example #12
Source File: OrderStepdefs.java    From exchange-core with Apache License 2.0 5 votes vote down vote up
@And("A client {user} orders:")
public void aCurrentOrdersOfAClientA(long clientId, List<List<String>> table) throws ExecutionException, InterruptedException {

    //| id | price | size | filled | reservePrice | side |

    SingleUserReportResult profile = container.getUserProfile(clientId);

    //skip a header if it presents
    Map<String, Integer> fieldNameByIndex = new HashMap<>();

    //read a header
    int i = 0;
    for (String field : table.get(0)) {
        fieldNameByIndex.put(field, i++);
    }

    //remove header
    table = table.subList(1, table.size());

    Map<Long, Order> orders = profile.fetchIndexedOrders();

    for (List<String> record : table) {
        long orderId = Long.parseLong(record.get(fieldNameByIndex.get("id")));
        Order order = orders.get(orderId);
        assertNotNull(order);

        checkField(fieldNameByIndex, record, "price", order.getPrice());
        checkField(fieldNameByIndex, record, "size", order.getSize());
        checkField(fieldNameByIndex, record, "filled", order.getFilled());
        checkField(fieldNameByIndex, record, "reservePrice", order.getReserveBidPrice());

        if (fieldNameByIndex.containsKey("side")) {
            OrderAction action = OrderAction.valueOf(record.get(fieldNameByIndex.get("side")));
            assertEquals("Unexpected action", action, order.getAction());
        }

    }
}
 
Example #13
Source File: OrderStepdefs.java    From exchange-core with Apache License 2.0 5 votes vote down vote up
@And("A balance of a client {user}:")
public void aCurrentBalanceOfAClientA(long clientId, List<List<String>> balance) throws ExecutionException, InterruptedException {
    SingleUserReportResult profile = container.getUserProfile(clientId);
    for (List<String> record : balance) {
        assertThat("Unexpected balance of: " + record.get(0), profile.getAccounts().get(TestConstants.getCurrency(record.get(0))), is(Long.parseLong(record.get(1))));
    }
}
 
Example #14
Source File: ListApplicationsSteps.java    From realworld-serverless-application with Apache License 2.0 5 votes vote down vote up
@And("the application should no longer be listed")
public void the_application_should_no_longer_be_listed() {
  Preconditions.checkState(TestEnv.getApplication() != null, "Step assumes an application has been created before");

  ApplicationSummary applicationSummary = new ApplicationSummary()
        .applicationId(TestEnv.getApplication().getApplicationId())
        .description(TestEnv.getApplication().getDescription())
        .creationTime(TestEnv.getApplication().getCreationTime());

  ListApplicationsResult listApplicationsResult = appRepo.listApplications(new ListApplicationsRequest());

  assertThat(listApplicationsResult.getApplicationList().getApplications())
        .doesNotContain(applicationSummary);
}
 
Example #15
Source File: OpenApiSteps.java    From yaks with Apache License 2.0 4 votes vote down vote up
@And("^(?:V|v)erify operation response: (.+)$")
public void verifyResponseByName(String response) {
    receiveResponse(operation, response);
}
 
Example #16
Source File: OrderStepdefs.java    From exchange-core with Apache License 2.0 4 votes vote down vote up
@And("A client {user} does not have active orders")
public void aClientBDoesNotHaveActiveOrders(long clientId) throws ExecutionException, InterruptedException {
    SingleUserReportResult profile = container.getUserProfile(clientId);
    assertEquals(0, profile.fetchIndexedOrders().size());
}
 
Example #17
Source File: ScreenSteps.java    From NoraUi with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Take a screenshot and compare to screen all ready to disc.
 *
 * @since 4.2.4
 * @param screenName
 *            name of screenshot file.
 * @param conditions
 *            list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
 * @throws IOException
 *             if file or directory is wrong.
 * @throws FailureException
 */
@Conditioned
@Et("Je compare une capture d\'écran avec {string} et affirmer un échec si la différence est {inequality} {float}(\\?)")
@And("I compare a screenshot with {string} and assert a failure if difference is {inequality} {float}(\\?)")
public void compareScreenshot(String screenName, Inequality inequality, double percentReference, List<GherkinStepCondition> conditions) throws IOException, FailureException {
    log.info("I compare a screenshot with [{}] and assert a failure if difference is [{}] [{}].", screenName, inequality.getValue(), percentReference);
    screenService.saveScreenshot("tmp");
    double percent = screenService.getDifferencePercent("tmp", screenName);
    log.info("percent difference is [{}].", percent);
    switch (inequality) {
        case SUPERIOR:
            if (percent > percentReference) {
                new Result.Failure<>("", Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT), true, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
            }
            break;
        case INFERIOR:
            if (percent < percentReference) {
                new Result.Failure<>("", Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT), true, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
            }
            break;
        case SUPERIOR_OR_EQUALS:
            if (percent >= percentReference) {
                new Result.Failure<>("", Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT), true, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
            }
            break;
        case INFERIOR_OR_EQUALS:
            if (percent <= percentReference) {
                new Result.Failure<>("", Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT), true, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
            }
            break;
        case EQUALS:
            if (percent == percentReference) {
                new Result.Failure<>("", Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT), true, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
            }
            break;
        case NOT_EQUALS:
            if (percent != percentReference) {
                new Result.Failure<>("", Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT), true, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
            }
            break;
    }
}
 
Example #18
Source File: ListApplicationsSteps.java    From realworld-serverless-application with Apache License 2.0 4 votes vote down vote up
@And("the listed applications should be in alphabetical order")
public void the_listed_applications_should_be_in_alphabetical_order() {
  Preconditions.checkState(TestEnv.getApplicationList() != null, "Step assumes listApplications has been called");
  assertThat(TestEnv.getApplicationList().getApplications())
        .isSortedAccordingTo(Comparator.comparing(ApplicationSummary::getApplicationId));
}
 
Example #19
Source File: ApiKeysStepsDefinitions.java    From apm-agent-java with Apache License 2.0 4 votes vote down vote up
@And("an api key is not set in the config")
public void apiKeyNotSetInConfig() {
    // this is the default, thus there is nothing to do but to assert for it just in case
    assertThat(configuration.getApiKey())
        .isNull();
}
 
Example #20
Source File: OrderStepdefs.java    From exchange-core with Apache License 2.0 4 votes vote down vote up
@And("No trade events")
public void noTradeEvents() {
    assertEquals(0, matcherEvents.size());
}
 
Example #21
Source File: BookCheckOutStepDefs.java    From demo with MIT License 4 votes vote down vote up
@And("^a book, \"([^\"]*)\" is available for borrowing$")
public void aBookIsAvailableForBorrowing(String title) {
    libraryUtils.registerBook(title);
    myBook = libraryUtils.searchForBookByTitle(title);
}
 
Example #22
Source File: HelloStepDefs.java    From mutual-tls-ssl with Apache License 2.0 4 votes vote down vote up
@And("I display the time it took to get the message")
public void iDisplayTheTimeItTookToGetTheMessage() {
    LOGGER.info("Executed request within {} milliseconds", testScenario.getExecutionTimeInMilliSeconds());
}
 
Example #23
Source File: CommonSteps.java    From NoraUi with GNU Affero General Public License v3.0 3 votes vote down vote up
/**
 * Save field in memory if all 'expected' parameters equals 'actual' parameters in conditions.
 *
 * @param pageElement
 *            The concerned page of field AND name of the field to save in memory. (sample: $demo.DemoPage-button)
 * @param conditions
 *            list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
 * @throws TechnicalException
 *             is throws if you have a technical error (format, configuration, datas, ...) in NoraUi.
 *             Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT} or {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_UNABLE_TO_RETRIEVE_VALUE}
 *             message (with screenshot, with exception)
 * @throws FailureException
 *             if the scenario encounters a functional error
 */
@Conditioned
@Et("Je sauvegarde la valeur de {page-element}(\\?)")
@And("I save the value of {page-element}(\\?)")
public void saveElementValue(PageElement pageElement, List<GherkinStepCondition> conditions) throws TechnicalException, FailureException {
    saveElementValue(pageElement);
}
 
Example #24
Source File: ScreenSteps.java    From NoraUi with GNU Affero General Public License v3.0 3 votes vote down vote up
/**
 * I start video capture and add to DOWNLOAD_FILES_FOLDER folder.
 *
 * @param conditions
 *            list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
 * @throws IOException
 *             if file or directory is wrong.
 */
@Conditioned
@Et("Je stop la capture vidéo(\\?)")
@And("I stop video capture(\\?)")
public void stopVideoCapture(List<GherkinStepCondition> conditions) throws IOException {
    log.debug("I stop video capture.");
    screenService.stopVideoCapture();
}
 
Example #25
Source File: ScreenSteps.java    From NoraUi with GNU Affero General Public License v3.0 3 votes vote down vote up
/**
 * I start video capture and add to DOWNLOAD_FILES_FOLDER folder.
 *
 * @param screenName
 *            name of video file.
 * @param conditions
 *            list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
 * @throws IOException
 *             if file or directory is wrong.
 * @throws AWTException
 *             if configuration video file is wrong.
 */
@Conditioned
@Et("Je commence la capture vidéo dans {string}(\\?)")
@And("I start video capture in {string}(\\?)")
public void startVideoCapture(String screenName, List<GherkinStepCondition> conditions) throws IOException, AWTException {
    log.debug("I start video capture in [{}].", screenName);
    screenService.startVideoCapture(screenName);
}
 
Example #26
Source File: ScreenSteps.java    From NoraUi with GNU Affero General Public License v3.0 3 votes vote down vote up
/**
 * Save a screenshot of one element only and add to DOWNLOAD_FILES_FOLDER folder.
 * 
 * @param pageElement
 *            The concerned page of field AND key of PageElement concerned (sample: $demo.DemoPage-button)
 * @param screenName
 *            name of screenshot file.
 * @param conditions
 *            list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}). * list of 'expected' values condition and 'actual' values
 *            ({@link com.github.noraui.gherkin.GherkinStepCondition}).
 * @throws IOException
 *             if file or directory is wrong.
 * @throws FailureException
 *             if the scenario encounters a functional error
 * @throws TechnicalException
 *             is thrown if you have a technical error (format, configuration, datas, ...) in NoraUi.
 *             Exception with {@value com.github.noraui.utils.Messages#FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT} message (with screenshot, no exception)
 */
@Conditioned
@Et("Je sauvegarde une capture d'écran de {page-element} dans {string}(\\?)")
@And("I save a screenshot of {page-element} in {string}(\\?)")
public void saveWebElementInScreenshot(PageElement pageElement, String screenName, List<GherkinStepCondition> conditions) throws IOException, FailureException, TechnicalException {
    log.debug("I save a screenshot of [{}-{}] in [{}.jpg]", pageElement.getPage(), pageElement.getKey(), screenName);
    try {
        screenService.saveScreenshot(screenName, Wait.until(ExpectedConditions.presenceOfElementLocated(Utilities.getLocator(pageElement))));
    } catch (Exception e) {
        new Result.Failure<>(e.getMessage(), Messages.getMessage(Messages.FAIL_MESSAGE_UNABLE_TO_FIND_ELEMENT), true, pageElement.getPage().getCallBack());
    }
}
 
Example #27
Source File: ScreenSteps.java    From NoraUi with GNU Affero General Public License v3.0 3 votes vote down vote up
/**
 * Save a screenshot and add to DOWNLOAD_FILES_FOLDER folder.
 *
 * @param screenName
 *            name of screenshot file.
 * @param conditions
 *            list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
 * @throws IOException
 *             if file or directory is wrong.
 */
@Conditioned
@Et("Je sauvegarde une capture d\'écran dans {string}(\\?)")
@And("I save a screenshot in {string}(\\?)")
public void saveScreenshot(String screenName, List<GherkinStepCondition> conditions) throws IOException {
    log.debug("I save a screenshot in [{}].", screenName);
    screenService.saveScreenshot(screenName);
}
 
Example #28
Source File: ContextSteps.java    From NoraUi with GNU Affero General Public License v3.0 3 votes vote down vote up
/**
 * Check that value (or value in context) equals to value (or value in context).
 * 
 * @param srcValueOrKey
 *            is source value (or value in context).
 * @param compareValueOrKey
 *            is value compared (or value in context).
 * @param conditions
 *            list of 'expected' values condition and 'actual' values
 *            ({@link com.github.noraui.gherkin.GherkinStepCondition}).
 * @throws FailureException
 *             if the scenario encounters a functional error
 * @throws TechnicalException
 *             is throws if you have a technical error (format, configuration, datas, ...) in NoraUi.
 */
@Conditioned
@Et("Je vérifie que {string} est égal à {string}(\\?)")
@And("I check that {string} equals to {string}(\\?)")
public void checkThatValueInContextEqualsTo(String srcValueOrKey, String compareValueOrKey, List<GherkinStepCondition> conditions) throws FailureException, TechnicalException {
    final String src = Context.getValue(srcValueOrKey) != null ? Context.getValue(srcValueOrKey) : srcValueOrKey;
    final String compare = Context.getValue(compareValueOrKey) != null ? Context.getValue(compareValueOrKey) : compareValueOrKey;
    if (!src.equals(compare)) {
        log.error("The value « {} » not equals « {} »", src, compare);
        new Result.Failure<>("", Messages.format(Messages.getMessage(Messages.FAIL_MESSAGE_CONTEXT_NOT_EQUALS), src, compare), false, Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
    }
}
 
Example #29
Source File: ContextSteps.java    From NoraUi with GNU Affero General Public License v3.0 3 votes vote down vote up
/**
 * Check that value (or value in context) equals ignore case to value (or value in context).
 * 
 * @param srcValueOrKey
 *            is source value (or value in context).
 * @param compareValueOrKey
 *            is value compared (or value in context).
 * @param conditions
 *            list of 'expected' values condition and 'actual' values
 *            ({@link com.github.noraui.gherkin.GherkinStepCondition}).
 * @throws FailureException
 *             if the scenario encounters a functional error
 * @throws TechnicalException
 *             is throws if you have a technical error (format, configuration, datas, ...) in NoraUi.
 */
@Conditioned
@Et("Je vérifie que {string} est égal à {string} en ignorant la case(\\?)")
@And("I check that {string} equals ignore case to {string}(\\?)")
public void checkThatValueInContextEqualsIgnoreCaseTo(String srcValueOrKey, String compareValueOrKey, List<GherkinStepCondition> conditions) throws FailureException, TechnicalException {
    final String src = Context.getValue(srcValueOrKey) != null ? Context.getValue(srcValueOrKey) : srcValueOrKey;
    final String compare = Context.getValue(compareValueOrKey) != null ? Context.getValue(compareValueOrKey) : compareValueOrKey;
    if (!src.equalsIgnoreCase(compare)) {
        log.error("The value « {} » not equals ignore case « {} »", src, compare);
        new Result.Failure<>("", Messages.format(Messages.getMessage(Messages.FAIL_MESSAGE_CONTEXT_NOT_EQUALS_IGNORE_CASE), src, compare), false,
                Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
    }
}
 
Example #30
Source File: ExpectSteps.java    From NoraUi with GNU Affero General Public License v3.0 3 votes vote down vote up
/**
 * Checks if an html element contains expected value.
 *
 * @param pageElement
 *            The concerned page of field AND key of PageElement concerned (sample: $demo.DemoPage-button)
 * @param textOrKey
 *            Is the new data (text or text in context (after a save))
 * @param conditions
 *            list of 'expected' values condition and 'actual' values ({@link com.github.noraui.gherkin.GherkinStepCondition}).
 * @throws TechnicalException
 *             is throws if you have a technical error (format, configuration, datas, ...) in NoraUi.
 *             Exception with message and with screenshot and with exception if functional error but no screenshot and no exception if technical error.
 * @throws FailureException
 *             if the scenario encounters a functional error
 */
@Conditioned
@Et("Je m'attends à avoir {page-element} avec le texte {string}(\\?)")
@And("I expect to have {page-element} with the text {string}(\\?)")
public void expectText(PageElement pageElement, String textOrKey, List<GherkinStepCondition> conditions) throws FailureException, TechnicalException {
    expectText(pageElement, textOrKey);
}