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);
}
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
Aggregations