@Test
  public void testGetTablesExt() throws Exception {
    try {
      resetHMSClient();

      final String dbName = "dbext";
      String tblName = "test_get_tables_ext";
      int count = 10;
      Map<String, Object> tProps = new HashMap<>();

      tProps.put("DBNAME", dbName);
      tProps.put("TBLNAME", tblName);

      StringBuilder table_params = new StringBuilder();
      List<String> capabilities = new ArrayList<>();
      TableType type = TableType.EXTERNAL_TABLE;

      capabilities.add("HIVEFULLACIDWRITE");
      capabilities.add("HIVEFULLACIDREAD");
      capabilities.add("HIVECACHEINVALIDATE");
      capabilities.add("CONNECTORREAD");
      capabilities.add("CONNECTORWRITE");

      tProps.put("CAPABILITIES", capabilities);
      tProps.put("TABLECOUNT", count);
      tProps.put("TBLTYPE", type);

      setHMSClient("test_get_tables_ext", (String[])(capabilities.toArray(new String[0])));

      List<String> tables = createTables(tProps);
      int requestedFields = (new GetTablesRequestBuilder().with(GetTablesExtRequestFields.PROCESSOR_CAPABILITIES)).bitValue();
      List<ExtendedTableInfo> extTables = client.getTablesExt(null, dbName, "*", requestedFields, 2000);
      LOG.debug("Return list size=" + extTables.size() + ",bitValue=" + requestedFields);
      assertEquals("Return list size does not match expected size:extTables", count, extTables.size());
      for (ExtendedTableInfo tableInfo : extTables) {
        assertNull("Return object should not have read capabilities", tableInfo.getRequiredReadCapabilities());
        assertNull("Return object should not have write capabilities", tableInfo.getRequiredWriteCapabilities());
        assertEquals("AccessType not expected to be set", 0, tableInfo.getAccessType());
      }

      requestedFields = (new GetTablesRequestBuilder().with(GetTablesExtRequestFields.ACCESS_TYPE)).bitValue();
      extTables = client.getTablesExt(null, dbName, "*", requestedFields, 2000);
      LOG.debug("Return list size=" + extTables.size() + ",bitValue=" + requestedFields);
      assertEquals("Return list size does not match expected size", count, extTables.size());
      for (ExtendedTableInfo tableInfo : extTables) {
        assertNull("Return object should not have read capabilities", tableInfo.getRequiredReadCapabilities());
        assertNull("Return object should not have write capabilities", tableInfo.getRequiredWriteCapabilities());
        assertTrue("AccessType expected to be set", tableInfo.getAccessType() > 0);
      }

      requestedFields = (new GetTablesRequestBuilder().with(GetTablesExtRequestFields.ALL)).bitValue();
      extTables = client.getTablesExt(null, dbName, "*", requestedFields, 2000);
      LOG.debug("Return list size=" + extTables.size() + ",bitValue=" + requestedFields);
      assertEquals("Return list size does not match expected size", count, extTables.size());
      for (ExtendedTableInfo tableInfo : extTables) {
        assertTrue("AccessType expected to be set", tableInfo.getAccessType() > 0);
      }

      extTables = client.getTablesExt(null, dbName, "*", requestedFields, (count - 3));
      LOG.debug("Return list size=" + extTables.size() + ",bitValue=" + requestedFields);
      assertEquals("Return list size does not match expected size", (count - 3), extTables.size());
      for (ExtendedTableInfo tableInfo : extTables) {
        assertTrue("AccessType expected to be set", tableInfo.getAccessType() > 0);
      }

      extTables = client.getTablesExt(null, dbName, "*", requestedFields, -1);
      LOG.debug("Return list size=" + extTables.size() + ",bitValue=" + requestedFields);
      assertEquals("Return list size does not match expected size", count, extTables.size());

      count = 300;
      tProps.put("TBLNAME", "test_limit");
      tProps.put("TABLECOUNT", count);
      tables = createTables(tProps);
      assertEquals("Unexpected number of tables created", count, tables.size());

      extTables = client.getTablesExt(null, dbName, "test_limit*", requestedFields, count);
      assertEquals("Unexpected number of tables returned", count, extTables.size());

      extTables = client.getTablesExt(null, dbName, "test_limit*", requestedFields, (count/2));
      assertEquals("Unexpected number of tables returned", (count/2), extTables.size());

      extTables = client.getTablesExt(null, dbName, "test_limit*", requestedFields, 1);
      assertEquals("Unexpected number of tables returned", 1, extTables.size());

      LOG.info("Test execution complete:testTablesExt");
    } catch (Exception e) {
      System.err.println(StringUtils.stringifyException(e));
      System.err.println("testGetTablesExt() failed.");
      fail("testGetTablesExt failed with " + e.getMessage());
    } finally {
      resetHMSClient();
    }
  }
EXTERNAL_TABLE
  1) Old table (name in upper case) with no capabilities
  2) Old table with no capabilities
  3a) New table with capabilities with no client requirements
  3b) New table with capabilities with no matching client requirements
  3c) New table with capabilities with partial match requirements
  3d) New table with capabilities with full match requirements
itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetastoreTransformer.java