components/src/test/java/eu/internetofus/common/components/StoreServices.java
/**
   * Store some tasks.
   *
   * @param max         number of tasks to create.
   * @param delay       in the creation of the tasks.
   * @param vertx       event bus to use.
   * @param testContext test context to use.
   * @param change      function to modify the pattern before to store it. The
   *                    first argument is the index and the second the created
   *                    task.
   *
   * @return the future with the created tasks.
   */
Store some tasks.
@param max         number of tasks to create.
@param delay       in the creation of the tasks.
@param vertx       event bus to use.
@param testContext test context to use.
@param change      function to modify the pattern before to store it. The
first argument is the index and the second the created
task.

@return the future with the created tasks.
Store some tasks . @param max number of tasks to create . @param delay in the creation of the tasks . @param vertx event bus to use . @param testContext test context to use . @param change function to modify the pattern before to store it . The first argument is the index and the second the created task . @return the future with the created tasks .
static Future<List<Task>> storeSomeTask(final int max, final long delay, final Vertx vertx,
      final VertxTestContext testContext, final BiConsumer<Integer, Task> change) {
    Future<List<Task>> future = Future.succeededFuture(new ArrayList<Task>());
    for (var i = 0; i < max; i++) {
      final var exampleIndex = i;
      future = future
          .compose(tasks -> new TaskTest().createModelExample(exampleIndex, vertx, testContext).compose(task -> {
            if (change != null) {
              change.accept(exampleIndex, task);
            }
            task.id = null;
            return storeTask(task, vertx, testContext).compose(storedTask -> {
              tasks.add(storedTask);
              final Promise<List<Task>> promise = Promise.promise();
              if (delay > 0) {
                vertx.setTimer(delay, id -> promise.complete(tasks));
              } else {
                promise.complete(tasks);
              }
              return promise.future();
            });
          }));
    }
    return future;
  }
static Future < List < Task > > storeSomeTask ( final int max , final long delay , final Vertx vertx , final VertxTestContext testContext , final BiConsumer < Integer , Task > change ) { Future < List < Task > > future = Future . succeededFuture ( new ArrayList < Task > ( ) ) ; for ( var i = 0 ; i < max ; i ++ ) { final var exampleIndex = i ; future = future . compose ( tasks -> new TaskTest ( ) . createModelExample ( exampleIndex , vertx , testContext ) . compose ( task -> { if ( change != null ) { change . accept ( exampleIndex , task ) ; } task . id = null ; return storeTask ( task , vertx , testContext ) . compose ( storedTask -> { tasks . add ( storedTask ) ; final Promise < List < Task > > promise = Promise . promise ( ) ; if ( delay > 0 ) { vertx . setTimer ( delay , id -> promise . complete ( tasks ) ) ; } else { promise . complete ( tasks ) ; } return promise . future ( ) ; } ) ; } ) ) ; } return future ; }
Store some tasks.
Store some tasks .