vertx/src/test/java/eu/internetofus/common/vertx/AggregationBuilderTest.java
/**
   * Should create empty query with {@code null} pattern.
   *
   * @see AggregationBuilder#unwind(String)
   */
Should create empty query with  null pattern.
Should create empty query with null pattern .
@Test
  public void shouldCreateAggregationUnwindCommand() {
    var expected = new JsonArray();
    var builder = new AggregationBuilder();
    assertThat(builder.unwind("elements")).isSameAs(builder);
    expected.add(new JsonObject().put("$unwind",
        new JsonObject().put("path", "$elements").put("includeArrayIndex", "elementsIndex")));
    assertThat(builder.build()).isEqualTo(expected);
    assertThat(builder.unwind("transactions.messages")).isSameAs(builder);
    expected.add(new JsonObject().put("$unwind",
        new JsonObject().put("path", "$transactions").put("includeArrayIndex", "transactionsIndex")));
    expected.add(new JsonObject().put("$unwind",
        new JsonObject().put("path", "$transactions.messages").put("includeArrayIndex", "messagesIndex")));
    assertThat(builder.build()).isEqualTo(expected);
    assertThat(builder.unwind("a.b.c.d.e")).isSameAs(builder);
    expected
        .add(new JsonObject().put("$unwind", new JsonObject().put("path", "$a").put("includeArrayIndex", "aIndex")));
    expected
        .add(new JsonObject().put("$unwind", new JsonObject().put("path", "$a.b").put("includeArrayIndex", "bIndex")));
    expected.add(
        new JsonObject().put("$unwind", new JsonObject().put("path", "$a.b.c").put("includeArrayIndex", "cIndex")));
    expected.add(
        new JsonObject().put("$unwind", new JsonObject().put("path", "$a.b.c.d").put("includeArrayIndex", "dIndex")));
    expected.add(
        new JsonObject().put("$unwind", new JsonObject().put("path", "$a.b.c.d.e").put("includeArrayIndex", "eIndex")));
    assertThat(builder.build()).isEqualTo(expected);
  }
@ Test public void shouldCreateAggregationUnwindCommand ( ) { var expected = new JsonArray ( ) ; var builder = new AggregationBuilder ( ) ; assertThat ( builder . unwind ( "elements" ) ) . isSameAs ( builder ) ; expected . add ( new JsonObject ( ) . put ( "$unwind" , new JsonObject ( ) . put ( "path" , "$elements" ) . put ( "includeArrayIndex" , "elementsIndex" ) ) ) ; assertThat ( builder . build ( ) ) . isEqualTo ( expected ) ; assertThat ( builder . unwind ( "transactions.messages" ) ) . isSameAs ( builder ) ; expected . add ( new JsonObject ( ) . put ( "$unwind" , new JsonObject ( ) . put ( "path" , "$transactions" ) . put ( "includeArrayIndex" , "transactionsIndex" ) ) ) ; expected . add ( new JsonObject ( ) . put ( "$unwind" , new JsonObject ( ) . put ( "path" , "$transactions.messages" ) . put ( "includeArrayIndex" , "messagesIndex" ) ) ) ; assertThat ( builder . build ( ) ) . isEqualTo ( expected ) ; assertThat ( builder . unwind ( "a.b.c.d.e" ) ) . isSameAs ( builder ) ; expected . add ( new JsonObject ( ) . put ( "$unwind" , new JsonObject ( ) . put ( "path" , "$a" ) . put ( "includeArrayIndex" , "aIndex" ) ) ) ; expected . add ( new JsonObject ( ) . put ( "$unwind" , new JsonObject ( ) . put ( "path" , "$a.b" ) . put ( "includeArrayIndex" , "bIndex" ) ) ) ; expected . add ( new JsonObject ( ) . put ( "$unwind" , new JsonObject ( ) . put ( "path" , "$a.b.c" ) . put ( "includeArrayIndex" , "cIndex" ) ) ) ; expected . add ( new JsonObject ( ) . put ( "$unwind" , new JsonObject ( ) . put ( "path" , "$a.b.c.d" ) . put ( "includeArrayIndex" , "dIndex" ) ) ) ; expected . add ( new JsonObject ( ) . put ( "$unwind" , new JsonObject ( ) . put ( "path" , "$a.b.c.d.e" ) . put ( "includeArrayIndex" , "eIndex" ) ) ) ; assertThat ( builder . build ( ) ) . isEqualTo ( expected ) ; }
Should create empty query with {@code null} pattern.
Should create empty query with { @code null } pattern .