Search in sources :

Example 36 with TechnicalException

use of com.github.noraui.exception.TechnicalException in project NoraUi by NoraUi.

the class StepUT method testFormatMessageNullPageElement.

@Test
public void testFormatMessageNullPageElement() {
    try {
        final DemoPage demoPage = (DemoPage) Page.getInstance(DEMO_PAGE_NAME);
        final PageElement pageElement = demoPage.getPageElementByKey("fake");
        Messages.format("Message %s in %s.", pageElement, demoPage.getApplication());
    } catch (final TechnicalException e) {
        Assert.assertEquals("TechnicalException found", "Technical problem in the code Messages.formatMessage(String templateMessage, String... args) in NoraUi.", e.getMessage());
    }
}
Also used : TechnicalException(com.github.noraui.exception.TechnicalException) DemoPage(com.github.noraui.application.page.demo.DemoPage) PageElement(com.github.noraui.application.page.Page.PageElement) Test(org.junit.Test)

Example 37 with TechnicalException

use of com.github.noraui.exception.TechnicalException 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)

Example 38 with TechnicalException

use of com.github.noraui.exception.TechnicalException in project NoraUi by NoraUi.

the class ExcelDataProvider method openOutputData.

/**
 * @throws TechnicalException
 *             is thrown if you have a technical error (format, configuration, datas, ...) in NoraUi.
 */
void openOutputData() throws TechnicalException {
    this.dataOutExtension = validExtension(dataOutPath);
    try (FileInputStream fileOut = new FileInputStream(dataOutPath + scenarioName + "." + dataOutExtension)) {
        initWorkbook(fileOut, dataOutExtension);
    } catch (final IOException e) {
        throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_DATA_IOEXCEPTION), e);
    }
    styleSuccess = workbook.createCellStyle();
    final Font fontSuccess = workbook.createFont();
    fontSuccess.setColor(HSSFColor.HSSFColorPredefined.GREEN.getIndex());
    styleSuccess.setFont(fontSuccess);
    styleFailed = workbook.createCellStyle();
    final Font fontFailed = workbook.createFont();
    fontFailed.setColor(HSSFColor.HSSFColorPredefined.RED.getIndex());
    styleFailed.setFont(fontFailed);
    styleWarning = workbook.createCellStyle();
    final Font fontWarning = workbook.createFont();
    fontWarning.setColor(HSSFColor.HSSFColorPredefined.ORANGE.getIndex());
    styleWarning.setFont(fontWarning);
}
Also used : TechnicalException(com.github.noraui.exception.TechnicalException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) Font(org.apache.poi.ss.usermodel.Font)

Example 39 with TechnicalException

use of com.github.noraui.exception.TechnicalException in project NoraUi by NoraUi.

the class SecurityUT method testCreateSha1CheckSumFile.

@Test
public void testCreateSha1CheckSumFile() {
    Security security = new Security();
    try {
        security.createSha1CheckSumFile(new File(System.getProperty("user.dir") + File.separator + "src" + File.separator + "main" + File.separator + "resources" + File.separator + "demoExcel.properties"));
        Assert.assertTrue(true);
    } catch (TechnicalException e) {
        Assert.assertFalse("Erreur car il y a une erreur de type TechnicalException", true);
    }
}
Also used : TechnicalException(com.github.noraui.exception.TechnicalException) File(java.io.File) Test(org.junit.Test)

Aggregations

TechnicalException (com.github.noraui.exception.TechnicalException)39 FailureException (com.github.noraui.exception.FailureException)13 Result (com.github.noraui.exception.Result)12 WebElement (org.openqa.selenium.WebElement)10 IOException (java.io.IOException)9 ParseException (java.text.ParseException)9 Test (org.junit.Test)8 PageElement (com.github.noraui.application.page.Page.PageElement)6 DemoPage (com.github.noraui.application.page.demo.DemoPage)6 ArrayList (java.util.ArrayList)5 Then (cucumber.api.java.en.Then)4 File (java.io.File)4 Path (java.nio.file.Path)4 Connection (java.sql.Connection)4 PreparedStatement (java.sql.PreparedStatement)4 ResultSet (java.sql.ResultSet)4 SQLException (java.sql.SQLException)4 GherkinStepCondition (com.github.noraui.gherkin.GherkinStepCondition)3 ModelList (com.github.noraui.model.ModelList)3 Conditioned (com.github.noraui.cucumber.annotation.Conditioned)2