vertx/src/test/java/eu/internetofus/common/vertx/RepositoryIT.java
/**
   * Insert into a collection some {@link DummyComplexModel}.
   *
   * @param collectionName name of the collection to add the models.
   * @param size           the number of models to insert.
   * @param testContext    context for the test.
   * @param success        to call when the model has been inserted.
   */
Insert into a collection some  DummyComplexModel.
@param collectionName name of the collection to add the models.
@param size           the number of models to insert.
@param testContext    context for the test.
@param success        to call when the model has been inserted.
Insert into a collection some DummyComplexModel . @param collectionName name of the collection to add the models . @param size the number of models to insert . @param testContext context for the test . @param success to call when the model has been inserted .
protected void createAndInsertDummyComplexModelsWithExtraFieldsTo(final String collectionName, final int size,
      final VertxTestContext testContext, final Runnable success) {
    if (size <= 0) {
      success.run();
    } else {
      final var model = new DummyComplexModelTest().createModelExample(size);
      model.id = null;
      final var document = model.toJsonObject().put("extraValue", "value")
          .put("extraObject", new JsonObject().put("key", "value"))
          .put("extraArray", new JsonArray().add(1).add(new JsonObject().put("key", "value")))
          .put(Repository.SCHEMA_VERSION, "0");
      if (model.siblings != null) {
        final var siblings = document.getJsonArray("siblings");
        for (var pos = 0; pos < siblings.size(); pos++) {
          siblings.getJsonObject(pos).put("extra", "value").put("extraObject", new JsonObject().put("key", "value"))
              .put("extraArray", new JsonArray().add(1).add(new JsonObject().put("key", "value")));
        }
      }
      pool.insert(collectionName, document, testContext.succeeding(stored -> this
          .createAndInsertDummyComplexModelsWithExtraFieldsTo(collectionName, size - 1, testContext, success)));
    }
  }
protected void createAndInsertDummyComplexModelsWithExtraFieldsTo ( final String collectionName , final int size , final VertxTestContext testContext , final Runnable success ) { if ( size <= 0 ) { success . run ( ) ; } else { final var model = new DummyComplexModelTest ( ) . createModelExample ( size ) ; model . id = null ; final var document = model . toJsonObject ( ) . put ( "extraValue" , "value" ) . put ( "extraObject" , new JsonObject ( ) . put ( "key" , "value" ) ) . put ( "extraArray" , new JsonArray ( ) . add ( 1 ) . add ( new JsonObject ( ) . put ( "key" , "value" ) ) ) . put ( Repository . SCHEMA_VERSION , "0" ) ; if ( model . siblings != null ) { final var siblings = document . getJsonArray ( "siblings" ) ; for ( var pos = 0 ; pos < siblings . size ( ) ; pos ++ ) { siblings . getJsonObject ( pos ) . put ( "extra" , "value" ) . put ( "extraObject" , new JsonObject ( ) . put ( "key" , "value" ) ) . put ( "extraArray" , new JsonArray ( ) . add ( 1 ) . add ( new JsonObject ( ) . put ( "key" , "value" ) ) ) ; } } pool . insert ( collectionName , document , testContext . succeeding ( stored -> this . createAndInsertDummyComplexModelsWithExtraFieldsTo ( collectionName , size - 1 , testContext , success ) ) ) ; } }
Insert into a collection some {@link DummyComplexModel}.
Insert into a collection some { @link DummyComplexModel } .