vertx/src/test/java/eu/internetofus/common/vertx/RepositoryIT.java
/**
   * Should return a page of models.
   *
   * @param vertx       event bus to use.
   * @param testContext context for the test.
   */
Should return a page of models.
@param vertx       event bus to use.
@param testContext context for the test.
Should return a page of models . @param vertx event bus to use . @param testContext context for the test .
@Test
  public void shouldSearchPageObject(final Vertx vertx, final VertxTestContext testContext) {
    final var repository = new Repository(vertx, pool, "schemaVersion");
    final var options = new FindOptions();
    options.setSkip(3);
    options.setLimit(1);
    testContext.assertComplete(repository.searchPageObject(TEN_DUMMY_COLLECTION,
        new JsonObject().put("index", new JsonObject().put("$mod", new JsonArray().add(2).add(1))), options, "models",
        null)).onSuccess(page -> testContext.verify(() -> {
          assertThat(page).isNotNull();
          assertThat(page.getInteger("offset")).isNotNull().isEqualTo(3);
          assertThat(page.getInteger("total")).isNotNull().isEqualTo(5);
          final var models = page.getJsonArray("models");
          assertThat(models).isNotNull();
          assertThat(models.size()).isEqualTo(1);
          final var element = models.getJsonObject(0);
          assertThat(element.getString("_id")).isNotNull();
          assertThat(element.getInteger("index")).isNotNull().isEqualTo(7);
          testContext.completeNow();
        }));
  }
@ Test public void shouldSearchPageObject ( final Vertx vertx , final VertxTestContext testContext ) { final var repository = new Repository ( vertx , pool , "schemaVersion" ) ; final var options = new FindOptions ( ) ; options . setSkip ( 3 ) ; options . setLimit ( 1 ) ; testContext . assertComplete ( repository . searchPageObject ( TEN_DUMMY_COLLECTION , new JsonObject ( ) . put ( "index" , new JsonObject ( ) . put ( "$mod" , new JsonArray ( ) . add ( 2 ) . add ( 1 ) ) ) , options , "models" , null ) ) . onSuccess ( page -> testContext . verify ( ( ) -> { assertThat ( page ) . isNotNull ( ) ; assertThat ( page . getInteger ( "offset" ) ) . isNotNull ( ) . isEqualTo ( 3 ) ; assertThat ( page . getInteger ( "total" ) ) . isNotNull ( ) . isEqualTo ( 5 ) ; final var models = page . getJsonArray ( "models" ) ; assertThat ( models ) . isNotNull ( ) ; assertThat ( models . size ( ) ) . isEqualTo ( 1 ) ; final var element = models . getJsonObject ( 0 ) ; assertThat ( element . getString ( "_id" ) ) . isNotNull ( ) ; assertThat ( element . getInteger ( "index" ) ) . isNotNull ( ) . isEqualTo ( 7 ) ; testContext . completeNow ( ) ; } ) ) ; }
Should return a page of models.
Should return a page of models .