@Test
  public void testDeleteSnapshots() throws Exception {
    TableName tn = TableName.valueOf(name.getMethodName());
    try (Table t = connection.getTable(QuotaTableUtil.QUOTA_TABLE_NAME)) {
      Quotas quota =
        Quotas.newBuilder().setSpace(QuotaProtos.SpaceQuota.newBuilder().setSoftLimit(7L)
          .setViolationPolicy(QuotaProtos.SpaceViolationPolicy.NO_WRITES).build()).build();
      QuotaUtil.addTableQuota(connection, tn, quota);

      String snapshotName = name.getMethodName() + "_snapshot";
      t.put(QuotaTableUtil.createPutForSnapshotSize(tn, snapshotName, 3L));
      t.put(QuotaTableUtil.createPutForSnapshotSize(tn, snapshotName, 5L));
      assertEquals(1, QuotaTableUtil.getObservedSnapshotSizes(connection).size());

      List<Delete> deletes = QuotaTableUtil.createDeletesForExistingTableSnapshotSizes(connection);
      assertEquals(1, deletes.size());

      t.delete(deletes);
      assertEquals(0, QuotaTableUtil.getObservedSnapshotSizes(connection).size());

      String ns = name.getMethodName();
      t.put(QuotaTableUtil.createPutForNamespaceSnapshotSize(ns, 5L));
      t.put(QuotaTableUtil.createPutForNamespaceSnapshotSize(ns, 3L));
      assertEquals(3L, QuotaTableUtil.getNamespaceSnapshotSize(connection, ns));

      deletes = QuotaTableUtil.createDeletesForExistingNamespaceSnapshotSizes(connection);
      assertEquals(1, deletes.size());

      t.delete(deletes);
      assertEquals(0L, QuotaTableUtil.getNamespaceSnapshotSize(connection, ns));

      t.put(QuotaTableUtil.createPutForSnapshotSize(TableName.valueOf("t1"), "s1", 3L));
      t.put(QuotaTableUtil.createPutForSnapshotSize(TableName.valueOf("t2"), "s2", 3L));
      t.put(QuotaTableUtil.createPutForSnapshotSize(TableName.valueOf("t3"), "s3", 3L));
      t.put(QuotaTableUtil.createPutForSnapshotSize(TableName.valueOf("t4"), "s4", 3L));
      t.put(QuotaTableUtil.createPutForSnapshotSize(TableName.valueOf("t1"), "s5", 3L));

      t.put(QuotaTableUtil.createPutForNamespaceSnapshotSize("ns1", 3L));
      t.put(QuotaTableUtil.createPutForNamespaceSnapshotSize("ns2", 3L));
      t.put(QuotaTableUtil.createPutForNamespaceSnapshotSize("ns3", 3L));

      assertEquals(5, QuotaTableUtil.getTableSnapshots(connection).size());
      assertEquals(3, QuotaTableUtil.getNamespaceSnapshots(connection).size());

      Multimap<TableName, String> tableSnapshotEntriesToRemove = HashMultimap.create();
      tableSnapshotEntriesToRemove.put(TableName.valueOf("t1"), "s1");
      tableSnapshotEntriesToRemove.put(TableName.valueOf("t3"), "s3");
      tableSnapshotEntriesToRemove.put(TableName.valueOf("t4"), "s4");

      Set<String> namespaceSnapshotEntriesToRemove = new HashSet<>();
      namespaceSnapshotEntriesToRemove.add("ns2");
      namespaceSnapshotEntriesToRemove.add("ns1");

      deletes =
        QuotaTableUtil.createDeletesForExistingTableSnapshotSizes(tableSnapshotEntriesToRemove);
      assertEquals(3, deletes.size());
      deletes = QuotaTableUtil
        .createDeletesForExistingNamespaceSnapshotSizes(namespaceSnapshotEntriesToRemove);
      assertEquals(2, deletes.size());
    }
  }
Test the quota table helpers (e.g. CRUD operations)
hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaTableUtil.java