Search in sources :

Example 11 with And

use of io.cucumber.java.en.And in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class KafkaConnectorSteps method kc_config_contains.

@And("the kctr has config containing:")
public void kc_config_contains(DataTable table) {
    KafkaConnector res = kctr();
    assertThat(res).isNotNull();
    assertThatDataTable(table, ctx::resolvePlaceholders).matches(res.getSpec().getConfig());
}
Also used : KafkaConnector(io.strimzi.api.kafka.model.KafkaConnector) And(io.cucumber.java.en.And)

Example 12 with And

use of io.cucumber.java.en.And in project NoraUi by NoraUi.

the class TimeSteps method changeDate.

/**
 * @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));
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) LocalDate(java.time.LocalDate) FailureException(com.github.noraui.exception.FailureException) Result(com.github.noraui.exception.Result) And(io.cucumber.java.en.And) Et(io.cucumber.java.fr.Et)

Example 13 with And

use of io.cucumber.java.en.And in project NoraUi by NoraUi.

the class MailSteps method validActivationEmail.

/**
 * 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));
    }
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) Message(javax.mail.Message) Store(javax.mail.Store) Flags(javax.mail.Flags) Properties(java.util.Properties) Folder(javax.mail.Folder) SearchTerm(javax.mail.search.SearchTerm) SubjectTerm(javax.mail.search.SubjectTerm) MessagingException(javax.mail.MessagingException) HttpServiceException(com.github.noraui.exception.HttpServiceException) FailureException(com.github.noraui.exception.FailureException) IOException(java.io.IOException) TechnicalException(com.github.noraui.exception.TechnicalException) Result(com.github.noraui.exception.Result) AndTerm(javax.mail.search.AndTerm) FlagTerm(javax.mail.search.FlagTerm) FromTerm(javax.mail.search.FromTerm) Session(javax.mail.Session) Experimental(com.github.noraui.cucumber.annotation.Experimental) Conditioned(com.github.noraui.cucumber.annotation.Conditioned) And(io.cucumber.java.en.And) RetryOnFailure(com.github.noraui.cucumber.annotation.RetryOnFailure) Et(io.cucumber.java.fr.Et)

Example 14 with And

use of io.cucumber.java.en.And in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class KameletBindingSecretSteps method klb_secret_contains.

@SuppressWarnings({ "unchecked", "rawtypes" })
@And("the klb secret contains:")
public void klb_secret_contains(DataTable table) throws IOException {
    Secret secret = secret();
    assertThat(secret).isNotNull();
    String enc = secret.getData().get("application.properties");
    String dec = new String(Base64.getDecoder().decode(enc));
    Properties props = new Properties();
    try (InputStream is = new ByteArrayInputStream(dec.getBytes(StandardCharsets.UTF_8))) {
        props.load(is);
    }
    assertThatDataTable(table, ctx::resolvePlaceholders).matches((Map) props);
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Properties(java.util.Properties) And(io.cucumber.java.en.And)

Example 15 with And

use of io.cucumber.java.en.And in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class KameletBindingSecretSteps method klb_has_a_path_matching_value.

@And("the klb secret has an entry at path {string} with value {string}")
public void klb_has_a_path_matching_value(String path, String value) {
    Secret secret = secret();
    assertThat(secret).isNotNull();
    assertThatJson(JacksonUtil.asJsonNode(secret)).inPath(path).isString().isEqualTo(value);
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) And(io.cucumber.java.en.And)

Aggregations

And (io.cucumber.java.en.And)33 KafkaConnect (io.strimzi.api.kafka.model.KafkaConnect)8 KafkaConnector (io.strimzi.api.kafka.model.KafkaConnector)8 KameletBinding (org.bf2.cos.fleetshard.operator.camel.model.KameletBinding)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 Secret (io.fabric8.kubernetes.api.model.Secret)6 DataTable (io.cucumber.datatable.DataTable)3 Then (io.cucumber.java.en.Then)3 When (io.cucumber.java.en.When)3 Serialization (io.fabric8.kubernetes.client.utils.Serialization)3 Consumer (java.util.function.Consumer)3 Collectors (java.util.stream.Collectors)3 JsonAssertions.assertThatJson (net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 CucumberAssertions.assertThatDataTable (org.bf2.cos.fleetshard.it.cucumber.assertions.CucumberAssertions.assertThatDataTable)3 StepsSupport (org.bf2.cos.fleetshard.it.cucumber.support.StepsSupport)3 JacksonUtil (org.bf2.cos.fleetshard.support.json.JacksonUtil)3 FailureException (com.github.noraui.exception.FailureException)2 Result (com.github.noraui.exception.Result)2 Et (io.cucumber.java.fr.Et)2