vertx/src/test/java/eu/internetofus/common/vertx/RepositoryIT.java
/**
   * Start the database.
   *
   * @param vertx       event bus to use.
   * @param testContext context for the test.
   */
Start the database.
@param vertx       event bus to use.
@param testContext context for the test.
Start the database . @param vertx event bus to use . @param testContext context for the test .
@BeforeAll
  public static void startDatabaseContainer(final Vertx vertx, final VertxTestContext testContext) {
    container = new MongoContainer<>();
    final var persitenceConf = container.startMongoContainer().getMongoDBConfig();
    pool = MongoClient.createShared(vertx, persitenceConf, "repository_pool_name");
    testContext
        .assertComplete(pool.createCollection(EMPTY_COLLECTION).compose(empty -> pool.createCollection(TEST_COLLECTION))
            .compose(test -> pool.createCollection(TEN_DUMMY_COLLECTION)).compose(tem -> {
              Future<String> future = Future.succeededFuture();
              for (var i = 0; i < 10; i++) {
                final var model = new DummyModel();
                model.index = i;
                future = future.compose(stored -> pool.insert(TEN_DUMMY_COLLECTION, model.toJsonObject()));
              }
              return future;
            }).compose(test -> pool.createCollection(TEN_AGGREGATION_COLLECTION)).compose(tem -> {
              Future<String> future = Future.succeededFuture();
              for (var i = 0; i < 10; i++) {
                final var children = new JsonArray();
                for (var j = 0; j < 10; j++) {
                  final var grandChildren = new JsonArray();
                  for (var k = 0; k < 10; k++) {
                    final var elders = new JsonArray();
                    for (var l = 0; l < 10; l++) {
                      final var elder = new JsonObject().put("i", i).put("j", j).put("k", k).put("l", l);
                      elders.add(elder);
                    }
                    final var grandChild = new JsonObject().put("i", i).put("j", j).put("k", k).put("elders", elders);
                    grandChildren.add(grandChild);
                  }
                  final var child = new JsonObject().put("i", i).put("j", j).put("grandChildren", grandChildren);
                  children.add(child);
                }
                final var model = new JsonObject().put("index", i).put("children", children);
                future = future.compose(stored -> pool.insert(TEN_AGGREGATION_COLLECTION, model));
              }
              return future;
            })
        ).onSuccess(stored -> testContext.completeNow());
  }
@ BeforeAll public static void startDatabaseContainer ( final Vertx vertx , final VertxTestContext testContext ) { container = new MongoContainer < > ( ) ; final var persitenceConf = container . startMongoContainer ( ) . getMongoDBConfig ( ) ; pool = MongoClient . createShared ( vertx , persitenceConf , "repository_pool_name" ) ; testContext . assertComplete ( pool . createCollection ( EMPTY_COLLECTION ) . compose ( empty -> pool . createCollection ( TEST_COLLECTION ) ) . compose ( test -> pool . createCollection ( TEN_DUMMY_COLLECTION ) ) . compose ( tem -> { Future < String > future = Future . succeededFuture ( ) ; for ( var i = 0 ; i < 10 ; i ++ ) { final var model = new DummyModel ( ) ; model . index = i ; future = future . compose ( stored -> pool . insert ( TEN_DUMMY_COLLECTION , model . toJsonObject ( ) ) ) ; } return future ; } ) . compose ( test -> pool . createCollection ( TEN_AGGREGATION_COLLECTION ) ) . compose ( tem -> { Future < String > future = Future . succeededFuture ( ) ; for ( var i = 0 ; i < 10 ; i ++ ) { final var children = new JsonArray ( ) ; for ( var j = 0 ; j < 10 ; j ++ ) { final var grandChildren = new JsonArray ( ) ; for ( var k = 0 ; k < 10 ; k ++ ) { final var elders = new JsonArray ( ) ; for ( var l = 0 ; l < 10 ; l ++ ) { final var elder = new JsonObject ( ) . put ( "i" , i ) . put ( "j" , j ) . put ( "k" , k ) . put ( "l" , l ) ; elders . add ( elder ) ; } final var grandChild = new JsonObject ( ) . put ( "i" , i ) . put ( "j" , j ) . put ( "k" , k ) . put ( "elders" , elders ) ; grandChildren . add ( grandChild ) ; } final var child = new JsonObject ( ) . put ( "i" , i ) . put ( "j" , j ) . put ( "grandChildren" , grandChildren ) ; children . add ( child ) ; } final var model = new JsonObject ( ) . put ( "index" , i ) . put ( "children" , children ) ; future = future . compose ( stored -> pool . insert ( TEN_AGGREGATION_COLLECTION , model ) ) ; } return future ; } ) ) . onSuccess ( stored -> testContext . completeNow ( ) ) ; }
Start the database.
Start the database .