@Test
public void adjustRowIdsDoesNotAffectOriginal() throws LoadException {

  // GIVEN
  String json = "[ { " //
      + "\"a\": [ "//
  /* */ + "{ \"b\": 1, \"d\":[99, 100] }, "//
  /* */ + "{ \"b\": 2, \"d\":[] }"//
      + "]" + //
      ",\"c\" : [ 9, 10 ] }," //
  //
      + "{ " //
      + "\"a\": [ "//
  /* */ + "{ \"b\": 3, \"d\":[300,301,302] }, "//
  /* */ + "{ \"b\": 4, \"d\":[303,304,305] }, "//
  /* */ + "{ \"b\": 5, \"d\":[306,307,308] } "//
      + "]" + ",\"c\" : [ 0 ]}" + " ]";
  Table origTable = loadFromJson(100L, json);
  FlattenedTable flattenedTable = flattener.flattenTable(origTable, null, "a[*]", UUID.randomUUID());
  // assume flattenedTable was rowId-adjusted.
  for (StandardColumnShard colShard : flattenedTable.getShards().iterator().next().getColumns().values()) {
    ((AdjustableStandardColumnShard) colShard).adjustToFirstRowId(200L);
  }
  // WHEN
  FlattenedTable facadedTable =
      flattenedTableUtil.facadeWithDefaultRowIds(flattenedTable, TABLE, "a[*]", UUID.randomUUID());
  // THEN
  Assert.assertEquals(flattenedTable.getShards().size(), 1L, "Expected correct flattened shards size.");
  assertValidFirstRowId(flattenedTable.getShards().iterator().next(), 200L);
  Assert.assertEquals(facadedTable.getShards().size(), 1L, "Expected correct facaded shards size.");
  assertValidFirstRowId(facadedTable.getShards().iterator().next(), 100L);
  // WHEN adjust firstRowId in facade
  for (StandardColumnShard colShard : facadedTable.getShards().iterator().next().getColumns().values()) {
    ((AdjustableStandardColumnShard) colShard).adjustToFirstRowId(500L);
  }
  // THEN
  assertValidFirstRowId(flattenedTable.getShards().iterator().next(), 200L); // flattenedTable did not change.
  assertValidFirstRowId(facadedTable.getShards().iterator().next(), 500L);
}