@Given("^wait: (\\d+)s times: (\\d+)$") public void waitSecondsUntil(int seconds, int maxRetry) { wait.configure(1000 * seconds, maxRetry); }
@When("^execute sql:$") public void executeSql(String sql) { databaseExecuteContext.statement(variables.interpret(sql)); databaseExecuteContext.execute(); wait.waitable(databaseExecuteContext); }
private Object verify(ProceedingJoinPoint joinPoint) throws Throwable { Object proceed = joinPoint.proceed(); wait.off(); return proceed; }
void retry() { assertNotNull(waitables); this.waitables.forEach(Waitable::retry); last().ifPresent(waitable -> verifier.toBeVerified(waitable.result())); }
@Around("@annotation(cucumber.api.java.en.Then)") public Object until(ProceedingJoinPoint joinPoint) throws Throwable { if (!wait.on()) { return verify(joinPoint); } return waiting(joinPoint); }
private Object waiting(ProceedingJoinPoint joinPoint) throws Throwable { int count = 0; while (count < wait.maxRetry()) { try { return verify(joinPoint); } catch (Throwable throwable) { LOGGER.info(throwable.getMessage()); count++; sleep(); retry(count); } } return verify(joinPoint); }
@When("^collection: '([^\"]*)' find all$") public void findAll(String collection) { mongoQuery.collection(collection); mongoQuery.filter(null); verifier.toBeVerified(mongoQuery.find()); wait.waitable(mongoQuery); }
private Object verify(ProceedingJoinPoint joinPoint) throws Throwable { Object proceed = joinPoint.proceed(); wait.off(); return proceed; }
void retry() { assertNotNull(waitables); this.waitables.forEach(Waitable::retry); last().ifPresent(waitable -> verifier.toBeVerified(waitable.result())); }
@Around("@annotation(cucumber.api.java.en.Then)") public Object until(ProceedingJoinPoint joinPoint) throws Throwable { if (!wait.on()) { return verify(joinPoint); } return waiting(joinPoint); }
private Object waiting(ProceedingJoinPoint joinPoint) throws Throwable { int count = 0; while (count < wait.maxRetry()) { try { return verify(joinPoint); } catch (Throwable throwable) { LOGGER.info(throwable.getMessage()); count++; sleep(); retry(count); } } return verify(joinPoint); }
@When("^query:$") public void query(String sql) { databaseQueryContext.query(variables.interpret(sql)); databaseQueryContext.send(); verifier.toBeVerified(databaseQueryContext.results()); wait.waitable(databaseQueryContext); }
@Given("^wait: (\\d+)ms times: (\\d+)$") public void waitMillisUntil(int millis, int maxRetry) { wait.configure(millis, maxRetry); }
@When("^collection: '([^\"]*)' find:$") public void find(String collection, String filter) { mongoQuery.collection(collection); mongoQuery.filter(variables.interpret(filter)); verifier.toBeVerified(mongoQuery.find()); wait.waitable(mongoQuery); }
@Given("^wait: (\\d+)s times: (\\d+)$") public void waitSecondsUntil(int seconds, int maxRetry) { wait.configure(1000 * seconds, maxRetry); }
@When("^execute sql: ([^\"]*)$") public void executeSqlFromFile(String fileName) throws IOException { String file = configuration.classpathFile(fileName); databaseExecuteContext.statement(variables.interpret(read(file))); databaseExecuteContext.execute(); wait.waitable(databaseExecuteContext); } }