vertx/src/test/java/eu/internetofus/common/vertx/RepositoryIT.java
/**
   * Should update the documents of a collection to the current schema version.
   *
   * @param vertx       event bus to use.
   * @param testContext context for the test.
   */
Should update the documents of a collection to the current schema version.
@param vertx       event bus to use.
@param testContext context for the test.
Should update the documents of a collection to the current schema version . @param vertx event bus to use . @param testContext context for the test .
@Test
  public void shouldUpdateSchemaVersionOnCollection(final Vertx vertx, final VertxTestContext testContext) {
    final var collection = "_" + UUID.randomUUID().toString().replaceAll("-", "");
    pool.createCollection(collection, testContext.succeeding(createdCollections -> {
      this.createAndInsertDummyModelsWithSchemaVersionsTo(collection, 100, testContext, () -> {
        final var version = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
        final var repository = new Repository(vertx, pool, version);
        repository.migrateSchemaVersionOnCollectionTo(version, collection).onComplete(testContext.succeeding(empty -> {
          final var options = new FindOptions();
          options.setLimit(10000);
          options.getSort().put("index", 1);
          pool.findWithOptions(collection, new JsonObject(), options,
              testContext.succeeding(values -> testContext.verify(() -> {
                assertThat(values).isNotEmpty().hasSize(100);
                for (var i = 0; i < 100; i++) {
                  final var value = values.get(i);
                  final var expected = new JsonObject().put("_id", value.getString("_id")).put("index", i + 1)
                      .put(Repository.SCHEMA_VERSION, version);
                  assertThat(value).isEqualTo(expected);
                }
                testContext.completeNow();
              })));
        }));
      });
    }));
  }
@ Test public void shouldUpdateSchemaVersionOnCollection ( final Vertx vertx , final VertxTestContext testContext ) { final var collection = "_" + UUID . randomUUID ( ) . toString ( ) . replaceAll ( "-" , "" ) ; pool . createCollection ( collection , testContext . succeeding ( createdCollections -> { this . createAndInsertDummyModelsWithSchemaVersionsTo ( collection , 100 , testContext , ( ) -> { final var version = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" ; final var repository = new Repository ( vertx , pool , version ) ; repository . migrateSchemaVersionOnCollectionTo ( version , collection ) . onComplete ( testContext . succeeding ( empty -> { final var options = new FindOptions ( ) ; options . setLimit ( 10000 ) ; options . getSort ( ) . put ( "index" , 1 ) ; pool . findWithOptions ( collection , new JsonObject ( ) , options , testContext . succeeding ( values -> testContext . verify ( ( ) -> { assertThat ( values ) . isNotEmpty ( ) . hasSize ( 100 ) ; for ( var i = 0 ; i < 100 ; i ++ ) { final var value = values . get ( i ) ; final var expected = new JsonObject ( ) . put ( "_id" , value . getString ( "_id" ) ) . put ( "index" , i + 1 ) . put ( Repository . SCHEMA_VERSION , version ) ; assertThat ( value ) . isEqualTo ( expected ) ; } testContext . completeNow ( ) ; } ) ) ) ; } ) ) ; } ) ; } ) ) ; }
Should update the documents of a collection to the current schema version.
Should update the documents of a collection to the current schema version .