vertx/src/test/java/eu/internetofus/common/vertx/RepositoryIT.java
/**
   * Should store with a map.
   *
   * @param vertx       event bus to use.
   * @param testContext context for the test.
   */
Should store with a map.
@param vertx       event bus to use.
@param testContext context for the test.
Should store with a map . @param vertx event bus to use . @param testContext context for the test .
@Test
  public void shouldStoreWithMap(final Vertx vertx, final VertxTestContext testContext) {
    final var document = new JsonObject().put("key1", "value").put("key2", 2).put("key3", false).put("key4",
        new JsonArray());
    final var version = UUID.randomUUID().toString();
    final var repository = new Repository(vertx, pool, version);
    testContext.assertComplete(repository
        .storeOneDocument(TEST_COLLECTION, document, model -> model.put("id", model.remove("_id"))).compose(stored -> {
          document.mergeIn(stored);
          return pool.find(TEST_COLLECTION, new JsonObject().put(Repository.SCHEMA_VERSION, version));
        })).onSuccess(value -> testContext.verify(() -> {
          assertThat(value).isNotEmpty().hasSize(1);
          final var element = value.get(0);
          assertThat(element).isNotEqualTo(document);
          element.put("id", element.remove("_id"));
          assertThat(element).isNotEqualTo(document);
          element.remove(Repository.SCHEMA_VERSION);
          assertThat(element).isEqualTo(document);
          testContext.completeNow();
        }));
  }
@ Test public void shouldStoreWithMap ( final Vertx vertx , final VertxTestContext testContext ) { final var document = new JsonObject ( ) . put ( "key1" , "value" ) . put ( "key2" , 2 ) . put ( "key3" , false ) . put ( "key4" , new JsonArray ( ) ) ; final var version = UUID . randomUUID ( ) . toString ( ) ; final var repository = new Repository ( vertx , pool , version ) ; testContext . assertComplete ( repository . storeOneDocument ( TEST_COLLECTION , document , model -> model . put ( "id" , model . remove ( "_id" ) ) ) . compose ( stored -> { document . mergeIn ( stored ) ; return pool . find ( TEST_COLLECTION , new JsonObject ( ) . put ( Repository . SCHEMA_VERSION , version ) ) ; } ) ) . onSuccess ( value -> testContext . verify ( ( ) -> { assertThat ( value ) . isNotEmpty ( ) . hasSize ( 1 ) ; final var element = value . get ( 0 ) ; assertThat ( element ) . isNotEqualTo ( document ) ; element . put ( "id" , element . remove ( "_id" ) ) ; assertThat ( element ) . isNotEqualTo ( document ) ; element . remove ( Repository . SCHEMA_VERSION ) ; assertThat ( element ) . isEqualTo ( document ) ; testContext . completeNow ( ) ; } ) ) ; }
Should store with a map.
Should store with a map .