@Test
  public void testInsufficientlyReportedTableFiltering() throws Exception {
    final Map<TableName, Integer> reportedRegions = new HashMap<>();
    final Map<TableName, Integer> actualRegions = new HashMap<>();
    final Configuration conf = HBaseConfiguration.create();
    conf.setDouble(QuotaObserverChore.QUOTA_OBSERVER_CHORE_REPORT_PERCENT_KEY, 0.95);

    TableName tooFewRegionsTable = TableName.valueOf("tn1");
    TableName sufficientRegionsTable = TableName.valueOf("tn2");
    TableName tooFewRegionsNamespaceTable = TableName.valueOf("ns1", "tn2");
    TableName sufficientRegionsNamespaceTable = TableName.valueOf("ns1", "tn2");
    final TablesWithQuotas tables = new TablesWithQuotas(conn, conf) {
      @Override
      Configuration getConfiguration() {
        return conf;
      }

      @Override
      int getNumRegions(TableName tableName) {
        return actualRegions.get(tableName);
      }

      @Override
      int getNumReportedRegions(TableName table, QuotaSnapshotStore<TableName> tableStore) {
        return reportedRegions.get(table);
      }
    };
    tables.addTableQuotaTable(tooFewRegionsTable);
    tables.addTableQuotaTable(sufficientRegionsTable);
    tables.addNamespaceQuotaTable(tooFewRegionsNamespaceTable);
    tables.addNamespaceQuotaTable(sufficientRegionsNamespaceTable);

    reportedRegions.put(tooFewRegionsTable, 5);
    actualRegions.put(tooFewRegionsTable, 10);
    reportedRegions.put(sufficientRegionsTable, 19);
    actualRegions.put(sufficientRegionsTable, 20);
    reportedRegions.put(tooFewRegionsNamespaceTable, 9);
    actualRegions.put(tooFewRegionsNamespaceTable, 10);
    reportedRegions.put(sufficientRegionsNamespaceTable, 98);
    actualRegions.put(sufficientRegionsNamespaceTable, 100);

    // Unused argument
    tables.filterInsufficientlyReportedTables(null);
    Set<TableName> filteredTablesWithTableQuotas = tables.getTableQuotaTables();
    assertEquals(Collections.singleton(sufficientRegionsTable), filteredTablesWithTableQuotas);
    Set<TableName> filteredTablesWithNamespaceQutoas = tables.getNamespaceQuotaTables();
    assertEquals(Collections.singleton(sufficientRegionsNamespaceTable),
      filteredTablesWithNamespaceQutoas);
  }
Non-HBase cluster unit tests for {@link TablesWithQuotas}.
hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestTablesWithQuotas.java