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 shouldAggregatePageObjectModels(final Vertx vertx, final VertxTestContext testContext) {
    final var repository = new Repository(vertx, pool, "schemaVersion");
    final var query = new JsonObject().put("index", new JsonObject().put("$mod", new JsonArray().add(2).add(0)));
    final var order = new JsonObject().put("index", -1).put("children.j", 1).put("children.grandChildren.k", -1)
        .put("children.grandChildren.elders.l", 1);
    testContext.assertComplete(repository.aggregatePageObject(TEN_AGGREGATION_COLLECTION, query, order, 10, 5,
        "children.grandChildren.elders")).onSuccess(page -> testContext.verify(() -> {
          assertThat(page).isNotNull();
          assertThat(page.getInteger("offset")).isNotNull().isEqualTo(10);
          assertThat(page.getInteger("total")).isNotNull().isEqualTo(5000);
          final var elders = page.getJsonArray("elders");
          assertThat(elders).isNotNull().hasSize(5).containsExactly(
              new JsonObject().put("i", 8).put("j", 0).put("k", 8).put("l", 0),
              new JsonObject().put("i", 8).put("j", 0).put("k", 8).put("l", 1),
              new JsonObject().put("i", 8).put("j", 0).put("k", 8).put("l", 2),
              new JsonObject().put("i", 8).put("j", 0).put("k", 8).put("l", 3),
              new JsonObject().put("i", 8).put("j", 0).put("k", 8).put("l", 4));
          testContext.completeNow();
        }));
  }
@ Test public void shouldAggregatePageObjectModels ( final Vertx vertx , final VertxTestContext testContext ) { final var repository = new Repository ( vertx , pool , "schemaVersion" ) ; final var query = new JsonObject ( ) . put ( "index" , new JsonObject ( ) . put ( "$mod" , new JsonArray ( ) . add ( 2 ) . add ( 0 ) ) ) ; final var order = new JsonObject ( ) . put ( "index" , - 1 ) . put ( "children.j" , 1 ) . put ( "children.grandChildren.k" , - 1 ) . put ( "children.grandChildren.elders.l" , 1 ) ; testContext . assertComplete ( repository . aggregatePageObject ( TEN_AGGREGATION_COLLECTION , query , order , 10 , 5 , "children.grandChildren.elders" ) ) . onSuccess ( page -> testContext . verify ( ( ) -> { assertThat ( page ) . isNotNull ( ) ; assertThat ( page . getInteger ( "offset" ) ) . isNotNull ( ) . isEqualTo ( 10 ) ; assertThat ( page . getInteger ( "total" ) ) . isNotNull ( ) . isEqualTo ( 5000 ) ; final var elders = page . getJsonArray ( "elders" ) ; assertThat ( elders ) . isNotNull ( ) . hasSize ( 5 ) . containsExactly ( new JsonObject ( ) . put ( "i" , 8 ) . put ( "j" , 0 ) . put ( "k" , 8 ) . put ( "l" , 0 ) , new JsonObject ( ) . put ( "i" , 8 ) . put ( "j" , 0 ) . put ( "k" , 8 ) . put ( "l" , 1 ) , new JsonObject ( ) . put ( "i" , 8 ) . put ( "j" , 0 ) . put ( "k" , 8 ) . put ( "l" , 2 ) , new JsonObject ( ) . put ( "i" , 8 ) . put ( "j" , 0 ) . put ( "k" , 8 ) . put ( "l" , 3 ) , new JsonObject ( ) . put ( "i" , 8 ) . put ( "j" , 0 ) . put ( "k" , 8 ) . put ( "l" , 4 ) ) ; testContext . completeNow ( ) ; } ) ) ; }
Should return a page of models.
Should return a page of models .