Search in sources :

Example 1 with Logos

use of com.github.noraui.application.model.logogame.Logos in project NoraUi by NoraUi.

the class LogoGameSteps method checkThatAllBrandsIsNotProhibited.

/**
 * A check that all brands are not prohibited, because any minors can not play with alcohol and tobacco brands.
 *
 * @param jsonLogos
 *            Serialized Json representation of all logos (all brands)
 * @throws TechnicalException
 *             is throws if you have a technical error (format, configuration, datas, ...) in NoraUi.
 * @throws FailureException
 *             if the scenario encounters a functional error
 */
@Lorsque("Je vérifie que toutes les marques '(.*)' ne sont pas interdites")
@Given("I check that all brands '(.*)' are not prohibited")
public void checkThatAllBrandsIsNotProhibited(String jsonLogos) throws TechnicalException, FailureException {
    Logos logos = new Logos();
    logos.deserialize(jsonLogos);
    for (int i = 0; i < logos.size(); i++) {
        if (ProhibitedBrands.getAlcool().contains(logos.get(i).getBrand()) || ProhibitedBrands.getTabaco().contains(logos.get(i).getBrand())) {
            new Result.Failure<>(logos.get(i).getBrand(), Messages.format("Brand « %s » is prohibited.", logos.get(i).getBrand()), false, logos.get(i).getNid(), Context.getCallBack(Callbacks.RESTART_WEB_DRIVER));
        }
    }
}
Also used : Logos(com.github.noraui.application.model.logogame.Logos) Lorsque(cucumber.api.java.fr.Lorsque) Given(cucumber.api.java.en.Given)

Example 2 with Logos

use of com.github.noraui.application.model.logogame.Logos in project NoraUi by NoraUi.

the class LogoGameSteps method playWithMyInputFile.

@Alors("Je joue avec mon fichier d'entrée '(.*)'")
@Then("I play with my input file '(.*)'")
public void playWithMyInputFile(String jsonLogos) throws TechnicalException {
    Logos logos = new Logos();
    logos.deserialize(jsonLogos);
    for (int i = 0; i < logos.size(); i++) {
        Logo logo = logos.get(i);
        logo.setNid(i);
        try {
            WebElement element = getDriver().findElement(Utilities.getLocator(this.logoGamePage.brandElement, logo.getBrand(), logo.getBrand()));
            if (element != null) {
                updateText(this.logoGamePage.brandElement, logo.getBrand(), null, logo.getBrand(), logo.getBrand());
            }
        } catch (Exception e) {
            new Result.Warning<>(logo.getBrand(), Messages.format("Brand « %s » does not exist.", logo.getBrand()), true, logo.getNid());
        }
    }
}
Also used : Logos(com.github.noraui.application.model.logogame.Logos) WebElement(org.openqa.selenium.WebElement) FailureException(com.github.noraui.exception.FailureException) TechnicalException(com.github.noraui.exception.TechnicalException) Logo(com.github.noraui.application.model.logogame.Logo) Result(com.github.noraui.exception.Result) Alors(cucumber.api.java.fr.Alors) Then(cucumber.api.java.en.Then)

Aggregations

Logos (com.github.noraui.application.model.logogame.Logos)2 Logo (com.github.noraui.application.model.logogame.Logo)1 FailureException (com.github.noraui.exception.FailureException)1 Result (com.github.noraui.exception.Result)1 TechnicalException (com.github.noraui.exception.TechnicalException)1 Given (cucumber.api.java.en.Given)1 Then (cucumber.api.java.en.Then)1 Alors (cucumber.api.java.fr.Alors)1 Lorsque (cucumber.api.java.fr.Lorsque)1 WebElement (org.openqa.selenium.WebElement)1