vertx/src/test/java/eu/internetofus/common/vertx/RepositoryIT.java
/**
   * Should not update the documents of a collection to the current schema
   * version.
   *
   * @param vertx       event bus to use.
   * @param testContext context for the test.
   */
Should not update the documents of a collection to the current schema
version.

@param vertx       event bus to use.
@param testContext context for the test.
Should not 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 shouldNotUpdateSchemaVersionOnCollection(final Vertx vertx, final VertxTestContext testContext) {
    final var version = UUID.randomUUID().toString();
    final Repository repository = new Repository(vertx, pool, version) {
      /**
       * {@inheritDoc}
       */
      @Override
      protected JsonObject createQueryToReturnDocumentsWithAVersionLessThan(final String version) {
        return new JsonObject().put(Repository.SCHEMA_VERSION, new JsonObject().put("$undefinedOperator", "value"));
      }
    };
    repository.migrateSchemaVersionOnCollectionTo(version, TEN_DUMMY_COLLECTION)
        .onComplete(testContext.failing(empty -> {
          final var options = new FindOptions();
          options.setLimit(10000);
          options.getSort().put("index", 1);
          pool.findWithOptions(TEN_DUMMY_COLLECTION, new JsonObject(), options,
              testContext.succeeding(values -> testContext.verify(() -> {
                assertThat(values).isNotEmpty().hasSize(10);
                for (var i = 0; i < 10; i++) {
                  final var value = values.get(i);
                  final var expected = new JsonObject().put("_id", value.getString("_id")).put("index", i);
                  assertThat(value).isEqualTo(expected);
                }
                testContext.completeNow();
              })));
        }));
  }
@ Test public void shouldNotUpdateSchemaVersionOnCollection ( final Vertx vertx , final VertxTestContext testContext ) { final var version = UUID . randomUUID ( ) . toString ( ) ; final Repository repository = new Repository ( vertx , pool , version ) { /**
       * {@inheritDoc}
       */ @ Override protected JsonObject createQueryToReturnDocumentsWithAVersionLessThan ( final String version ) { return new JsonObject ( ) . put ( Repository . SCHEMA_VERSION , new JsonObject ( ) . put ( "$undefinedOperator" , "value" ) ) ; } } ; repository . migrateSchemaVersionOnCollectionTo ( version , TEN_DUMMY_COLLECTION ) . onComplete ( testContext . failing ( empty -> { final var options = new FindOptions ( ) ; options . setLimit ( 10000 ) ; options . getSort ( ) . put ( "index" , 1 ) ; pool . findWithOptions ( TEN_DUMMY_COLLECTION , new JsonObject ( ) , options , testContext . succeeding ( values -> testContext . verify ( ( ) -> { assertThat ( values ) . isNotEmpty ( ) . hasSize ( 10 ) ; for ( var i = 0 ; i < 10 ; i ++ ) { final var value = values . get ( i ) ; final var expected = new JsonObject ( ) . put ( "_id" , value . getString ( "_id" ) ) . put ( "index" , i ) ; assertThat ( value ) . isEqualTo ( expected ) ; } testContext . completeNow ( ) ; } ) ) ) ; } ) ) ; }
Should not update the documents of a collection to the current schema
 version.
Should not update the documents of a collection to the current schema version .