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 shouldSearchPageObjectModels(final Vertx vertx, final VertxTestContext testContext) {
    final var repository = new Repository(vertx, pool, "schemaVersion");
    final var options = new FindOptions();
    options.setSkip(1);
    options.setLimit(3);
    testContext.assertComplete(repository.searchPageObject(TEN_DUMMY_COLLECTION,
        new JsonObject().put("index", new JsonObject().put("$mod", new JsonArray().add(2).add(0))), options, "models",
        model -> model.remove("_id"))).onSuccess(page -> testContext.verify(() -> {
          assertThat(page).isNotNull();
          assertThat(page.getInteger("offset")).isNotNull().isEqualTo(1);
          assertThat(page.getInteger("total")).isNotNull().isEqualTo(5);
          final var models = Model.fromJsonArray(page.getJsonArray("models"), DummyModel.class);
          assertThat(models).isNotNull().hasSize(3);
          for (var pos = 0; pos < 3; pos++) {
            final var element = models.get(pos);
            final var expected = new DummyModel();
            expected.index = 2 + pos * 2;
            assertThat(element).isNotNull().isEqualTo(expected);
          }
          testContext.completeNow();
        }));
  }
@ Test public void shouldSearchPageObjectModels ( final Vertx vertx , final VertxTestContext testContext ) { final var repository = new Repository ( vertx , pool , "schemaVersion" ) ; final var options = new FindOptions ( ) ; options . setSkip ( 1 ) ; options . setLimit ( 3 ) ; testContext . assertComplete ( repository . searchPageObject ( TEN_DUMMY_COLLECTION , new JsonObject ( ) . put ( "index" , new JsonObject ( ) . put ( "$mod" , new JsonArray ( ) . add ( 2 ) . add ( 0 ) ) ) , options , "models" , model -> model . remove ( "_id" ) ) ) . onSuccess ( page -> testContext . verify ( ( ) -> { assertThat ( page ) . isNotNull ( ) ; assertThat ( page . getInteger ( "offset" ) ) . isNotNull ( ) . isEqualTo ( 1 ) ; assertThat ( page . getInteger ( "total" ) ) . isNotNull ( ) . isEqualTo ( 5 ) ; final var models = Model . fromJsonArray ( page . getJsonArray ( "models" ) , DummyModel . class ) ; assertThat ( models ) . isNotNull ( ) . hasSize ( 3 ) ; for ( var pos = 0 ; pos < 3 ; pos ++ ) { final var element = models . get ( pos ) ; final var expected = new DummyModel ( ) ; expected . index = 2 + pos * 2 ; assertThat ( element ) . isNotNull ( ) . isEqualTo ( expected ) ; } testContext . completeNow ( ) ; } ) ) ; }
Should return a page of models.
Should return a page of models .