Search in sources :

Example 11 with TechnicalException

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

the class Security method createSha1.

public String createSha1(File file) throws TechnicalException {
    try (InputStream fis = new FileInputStream(file)) {
        MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
        int n = 0;
        byte[] buffer = new byte[8192];
        while (n != -1) {
            n = fis.read(buffer);
            if (n > 0) {
                sha1.update(buffer, 0, n);
            }
        }
        return new HexBinaryAdapter().marshal(sha1.digest());
    } catch (NoSuchAlgorithmException | IOException e) {
        throw new TechnicalException(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE_CHECKSUM_IO_EXCEPTION), e);
    }
}
Also used : TechnicalException(com.github.noraui.exception.TechnicalException) HexBinaryAdapter(javax.xml.bind.annotation.adapters.HexBinaryAdapter) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) MessageDigest(java.security.MessageDigest) FileInputStream(java.io.FileInputStream)

Example 12 with TechnicalException

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

the class StepUT method testFormatMessageNullMessage.

@Test
public void testFormatMessageNullMessage() {
    try {
        final DemoPage demoPage = (DemoPage) Page.getInstance(DEMO_PAGE_NAME);
        final PageElement pageElement = demoPage.getPageElementByKey("-input");
        Messages.format(null, pageElement, demoPage.getApplication());
    } catch (final TechnicalException e) {
        Assert.assertEquals("TechnicalException found", Messages.getMessage("FAIL_MESSAGE_FORMAT_STRING"), 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 13 with TechnicalException

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

the class StepUT method testRunAllStepsInLoopWithUndefinedStep.

@Test
public void testRunAllStepsInLoopWithUndefinedStep() {
    final List<GherkinConditionedLoopedStep> steps = new ArrayList<>();
    final String expected = ".+;(ETS Backbone VLAN LL2048K\\|ETS Accès L2ETH\\|Accès XDSL ETS\\|Backbone VLAN Virtuelle)";
    final String actual = "VPNtechnique;OSC_ACC-resource_type";
    Context.saveValue("OSC_ACC-resource_type", "ETS Accès L2ETH");
    final GherkinConditionedLoopedStep gherkinConditionedLoopedStep = new GherkinConditionedLoopedStep("1", "I wait '4' seconds.", expected, actual);
    steps.add(gherkinConditionedLoopedStep);
    try {
        step.runAllStepsInLoop(steps);
        Assert.fail("TechnicalException should have been thrown");
    } catch (final TechnicalException e) {
        Assert.assertEquals(String.format(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_STEP_UNDEFINED), "I wait '4' seconds."), e.getMessage());
    }
}
Also used : TechnicalException(com.github.noraui.exception.TechnicalException) GherkinConditionedLoopedStep(com.github.noraui.gherkin.GherkinConditionedLoopedStep) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 14 with TechnicalException

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

the class StepUT method testFormatMessageNotValidMessage.

@Test
public void testFormatMessageNotValidMessage() {
    try {
        final DemoPage demoPage = (DemoPage) Page.getInstance(DEMO_PAGE_NAME);
        final PageElement pageElement = demoPage.getPageElementByKey("-input");
        Messages.format("Message %s in %s.%s", pageElement, demoPage.getApplication());
    } catch (final TechnicalException e) {
        Assert.assertEquals("TechnicalException found", Messages.getMessage("FAIL_MESSAGE_FORMAT_STRING"), 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 15 with TechnicalException

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

the class LogoGameSteps method saveScore.

@Alors("Je sauvegarde le score")
@Then("I save score")
public void saveScore() throws FailureException {
    try {
        WebElement message = Context.waitUntil(ExpectedConditions.presenceOfElementLocated(Utilities.getLocator(this.logoGamePage.scoreMessage)));
        try {
            Context.getCurrentScenario().write("score is:\n" + message.getText());
            Context.getDataOutputProvider().writeDataResult("score", Context.getDataInputProvider().getIndexData(Context.getCurrentScenarioData()).getIndexes().get(0), message.getText());
        } catch (TechnicalException e) {
            logger.error(Messages.getMessage(TechnicalException.TECHNICAL_ERROR_MESSAGE), e);
        }
    } catch (Exception e) {
        new Result.Failure<>(e.getMessage(), "", true, this.logoGamePage.getCallBack());
    }
}
Also used : TechnicalException(com.github.noraui.exception.TechnicalException) WebElement(org.openqa.selenium.WebElement) FailureException(com.github.noraui.exception.FailureException) TechnicalException(com.github.noraui.exception.TechnicalException) Result(com.github.noraui.exception.Result) Alors(cucumber.api.java.fr.Alors) Then(cucumber.api.java.en.Then)

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