private void runRestoreWithAdditionalMetadata(boolean changeMetadata, boolean addData)
    throws Exception {

    if (admin.isTableDisabled(originalTableName)) {
      admin.enableTable(originalTableName);
    }

    // populate it with data
    final byte[] familyForUpdate = BLOCKSIZE_FAM;

    List<byte[]> familiesWithDataList = new ArrayList<>();
    List<byte[]> emptyFamiliesList = new ArrayList<>();
    if (addData) {
      Table original = UTIL.getConnection().getTable(originalTableName);
      UTIL.loadTable(original, familyForUpdate); // family arbitrarily chosen
      original.close();

      for (byte[] family : families) {
        if (family != familyForUpdate) {
          emptyFamiliesList.add(family);
        }
      }
      familiesWithDataList.add(familyForUpdate);
    } else {
      Collections.addAll(emptyFamiliesList, families);
    }

    // take a "disabled" snapshot
    final String snapshotNameAsString =
      "snapshot" + originalTableName + EnvironmentEdgeManager.currentTime();

    SnapshotTestingUtils.createSnapshotAndValidate(admin, originalTableName, familiesWithDataList,
      emptyFamiliesList, snapshotNameAsString, rootDir, fs, /* onlineSnapshot= */ false);

    admin.enableTable(originalTableName);

    if (changeMetadata) {
      final String newFamilyNameAsString = "newFamily" + EnvironmentEdgeManager.currentTime();
      final byte[] newFamilyName = Bytes.toBytes(newFamilyNameAsString);

      admin.disableTable(originalTableName);
      ColumnFamilyDescriptor familyDescriptor = ColumnFamilyDescriptorBuilder.of(newFamilyName);
      admin.addColumnFamily(originalTableName, familyDescriptor);
      assertTrue("New column family was not added.",
        admin.getDescriptor(originalTableName).toString().contains(newFamilyNameAsString));
    }

    // restore it
    if (!admin.isTableDisabled(originalTableName)) {
      admin.disableTable(originalTableName);
    }

    admin.restoreSnapshot(snapshotNameAsString);
    admin.enableTable(originalTableName);

    // verify that the descrption is reverted
    try (Table original = UTIL.getConnection().getTable(originalTableName)) {
      assertEquals(originalTableDescriptor, admin.getDescriptor(originalTableName));
      assertEquals(originalTableDescriptor, original.getDescriptor());
    }
  }
Verify that when the table is empty, making metadata changes after the restore does not affect
the restored table's original metadata
hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotMetadata.java