use of com.github.noraui.exception.AssertError in project NoraUi by NoraUi.
the class CommonSteps method doUntil.
/**
* Does steps execution until a given condition is unverified.
*
* @param actual
* actual value for global condition.
* @param expected
* expected value for global condition.
* @param key
* key of 'expected' values ('actual' values)
* @param breakCondition
* 'expected' values
* @param tries
* number of max tries (no infinity loop).
* @param conditions
* list of steps run in a loop.
*/
@Lorsque("Si '(.*)' vérifie '(.*)', je fais jusqu'à '(.*)' respecte '(.*)' avec '(.*)' essais maxi:")
@Then("If '(.*)' matches '(.*)', I do until '(.*)' respects '(.*)' with '(.*)' max tries:")
public void doUntil(String actual, String expected, String key, String breakCondition, int tries, List<GherkinConditionedLoopedStep> conditions) {
try {
if (new GherkinStepCondition("doUntilKey", expected, actual).checkCondition()) {
int i = 0;
do {
i++;
runAllStepsInLoop(conditions);
} while (!Pattern.compile(breakCondition).matcher(Context.getValue(key) == null ? "" : Context.getValue(key)).find() && i <= tries);
}
} catch (final TechnicalException e) {
throw new AssertError(Messages.getMessage(TechnicalException.TECHNICAL_SUBSTEP_ERROR_MESSAGE) + e.getMessage());
}
}
use of com.github.noraui.exception.AssertError in project NoraUi by NoraUi.
the class CommonSteps method whileDo.
/**
* While a given condition is verified, does steps execution.
*
* @param actual
* actual value for global condition.
* @param expected
* expected value for global condition.
* @param key
* key of 'expected' values ('actual' values)
* @param breakCondition
* 'expected' values
* @param tries
* number of max tries (no infinity loop).
* @param conditions
* list of steps run in a loop.
*/
@Lorsque("Si '(.*)' vérifie '(.*)', Tant que '(.*)' respecte '(.*)' je fais avec '(.*)' essais maxi:")
@Then("If '(.*)' matches '(.*)', While '(.*)' respects '(.*)' I do with '(.*)' max tries:")
public void whileDo(String actual, String expected, String key, String breakCondition, int tries, List<GherkinConditionedLoopedStep> conditions) {
try {
if (new GherkinStepCondition("whileDoKey", expected, actual).checkCondition()) {
int i = 0;
while (!Pattern.compile(breakCondition).matcher(Context.getValue(key) == null ? "" : Context.getValue(key)).find() && i <= tries) {
i++;
runAllStepsInLoop(conditions);
}
}
} catch (final TechnicalException e) {
throw new AssertError(Messages.getMessage(TechnicalException.TECHNICAL_SUBSTEP_ERROR_MESSAGE) + e.getMessage());
}
}
Aggregations