@Test
public void repeatedMiddleMissingTest() throws LoadException {

  // GIVEN
  Table t = loadFromJson("[ { " //
      + "\"a\": [ "//
  /* */ + "{ \"b\": [ " //
  /*   */ + "{ \"c\": 1 }," //
  /*   */ + "{ \"d\": 1 }," //
  /*   */ + "{ \"c\": 3 }" //
  /* */ + "] }, "//
  /* */ + "{ \"b\": [ " //
  /*   */ + "{ \"c\": 2 }," //
  /*   */ + "{ \"d\": 2 }," //
  /*   */ + "{ \"c\": 4 }" //
  /* */ + "] } "//
      + "]" + //
      "},"
      //
      + "{ " //
      + "\"a\": [ "//
  /* */ + "{ \"b\": [ " //
  /*   */ + "{ \"c\": 5 }," //
  /*   */ + "{ \"d\": 5 }," //
  /*   */ + "{ \"c\": 6 }" //
  /* */ + "] }, "//
  /* */ + "{ \"b\": [ " //
  /*   */ + "{ \"c\": 7 }," //
  /*   */ + "{ \"d\": 7 }," //
  /*   */ + "{ \"c\": 8 }" //
  /* */ + "] } "//
      + "]" + //
      "}" + " ]");
  // WHEN
  FlattenedTable flattenedTable = flattener.flattenTable(t, null, "a[*].b[*]", UUID.randomUUID());
  // THEN
  Assert.assertEquals(flattenedTable.getShards().size(), 1, "Expected correct table shard count");
  TableShard tableShard = flattenedTable.getShards().iterator().next();
  Assert.assertEquals(tableShard.getLowestRowId(), 0L, "Expected correct lowest row ID");
  Assert.assertEquals(tableShard.getNumberOfRowsInShard(), 12, "Expected correct number of rows.");
  Assert.assertEquals(tableShard.getColumns().keySet(), new HashSet<>(Arrays.asList("a.b.c", "a.b.d")),
      "Expected correct columns.");
  SortedSet<SortedMap<String, Long>> expectedRows = new TreeSet<>(MAP_COMPARATOR);
  SortedMap<String, Long> row = new TreeMap<>();
  row.put("a.b.c", 1L);
  row.put("a.b.d", LoaderColumnInfo.DEFAULT_LONG);
  expectedRows.add(row);
  row = new TreeMap<>();
  row.put("a.b.c", LoaderColumnInfo.DEFAULT_LONG);
  row.put("a.b.d", 1L);
  expectedRows.add(row);
  row = new TreeMap<>();
  row.put("a.b.c", 3L);
  row.put("a.b.d", LoaderColumnInfo.DEFAULT_LONG);
  expectedRows.add(row);
  row = new TreeMap<>();
  row.put("a.b.c", 2L);
  row.put("a.b.d", LoaderColumnInfo.DEFAULT_LONG);
  expectedRows.add(row);
  row = new TreeMap<>();
  row.put("a.b.c", LoaderColumnInfo.DEFAULT_LONG);
  row.put("a.b.d", 2L);
  expectedRows.add(row);
  row = new TreeMap<>();
  row.put("a.b.c", 4L);
  row.put("a.b.d", LoaderColumnInfo.DEFAULT_LONG);
  expectedRows.add(row);
  row = new TreeMap<>();
  row.put("a.b.c", 5L);
  row.put("a.b.d", LoaderColumnInfo.DEFAULT_LONG);
  expectedRows.add(row);
  row = new TreeMap<>();
  row.put("a.b.c", LoaderColumnInfo.DEFAULT_LONG);
  row.put("a.b.d", 5L);
  expectedRows.add(row);
  row = new TreeMap<>();
  row.put("a.b.c", 6L);
  row.put("a.b.d", LoaderColumnInfo.DEFAULT_LONG);
  expectedRows.add(row);
  row = new TreeMap<>();
  row.put("a.b.c", 7L);
  row.put("a.b.d", LoaderColumnInfo.DEFAULT_LONG);
  expectedRows.add(row);
  row = new TreeMap<>();
  row.put("a.b.c", LoaderColumnInfo.DEFAULT_LONG);
  row.put("a.b.d", 7L);
  expectedRows.add(row);
  row = new TreeMap<>();
  row.put("a.b.c", 8L);
  row.put("a.b.d", LoaderColumnInfo.DEFAULT_LONG);
  expectedRows.add(row);
  Assert.assertEquals(getAllRows(tableShard), expectedRows, "Expected to have correct rows.");
}