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

      String dbName = "testdb";
      String dbWithLocation = "dbWithLocation";
      try {
        silentDropDatabase(dbName);
        silentDropDatabase(dbWithLocation);
      } catch (Exception e) {
        LOG.info("Drop database failed for " + dbName);
      }

      new DatabaseBuilder()
          .setName(dbName)
          .create(client, conf);

      List<String> capabilities = new ArrayList<>();
      capabilities.add("EXTWRITE");
      setHMSClient("TestGetDatabaseEXTWRITE", (String[])(capabilities.toArray(new String[0])));
      Database db = client.getDatabase(dbName);
      assertTrue("Database location not as expected:actual=" + db.getLocationUri(),
          db.getLocationUri().contains(conf.get(MetastoreConf.ConfVars.WAREHOUSE_EXTERNAL.getVarname())));

      capabilities = new ArrayList<>();
      capabilities.add("HIVEFULLACIDWRITE");
      setHMSClient("TestGetDatabaseACIDWRITE", (String[])(capabilities.toArray(new String[0])));

      db = client.getDatabase(dbName);
      assertTrue("Database location expected to be external warehouse:actual=" + db.getLocationUri(),
          db.getLocationUri().contains(conf.get(MetastoreConf.ConfVars.WAREHOUSE_EXTERNAL.getVarname())));
      resetHMSClient();

      capabilities = new ArrayList<>();
      capabilities.add("HIVEMANAGEDINSERTWRITE");
      setHMSClient("TestGetDatabaseINSERTWRITE", (String[])(capabilities.toArray(new String[0])));

      db = client.getDatabase(dbName);
      assertTrue("Database location expected to be external warehouse:actual=" + db.getLocationUri(),
          db.getLocationUri().contains(conf.get(MetastoreConf.ConfVars.WAREHOUSE_EXTERNAL.getVarname())));
      resetHMSClient();

      Warehouse wh = new Warehouse(conf);
      String mgdPath = wh.getDefaultDatabasePath(dbWithLocation, false).toString();
      new DatabaseBuilder()
          .setName(dbWithLocation)
          .setLocation(mgdPath)
          .create(client, conf);

      capabilities = new ArrayList<>();
      capabilities.add("EXTWRITE");
      setHMSClient("TestGetDatabaseWithLocation", (String[])(capabilities.toArray(new String[0])));

      db = client.getDatabase(dbWithLocation);
      assertTrue("Database location expected to be external warehouse:actual=" + db.getLocationUri(),
          db.getLocationUri().contains(conf.get(MetastoreConf.ConfVars.WAREHOUSE_EXTERNAL.getVarname())));
      assertNull("Database managed location expected to be null", db.getManagedLocationUri());
      resetHMSClient();

      capabilities.add("HIVEMANAGEDINSERTWRITE");
      setHMSClient("TestGetDatabaseWithLocation#2", (String[])(capabilities.toArray(new String[0])));

      db = client.getDatabase(dbWithLocation);
      assertTrue("Database location expected to be external warehouse", db.getLocationUri().contains(conf.get(MetastoreConf.ConfVars.WAREHOUSE_EXTERNAL.getVarname())));
      assertEquals("Database managedLocationUri expected to be set to locationUri", mgdPath, db.getManagedLocationUri());
      resetHMSClient();
    } catch (Exception e) {
      System.err.println(org.apache.hadoop.util.StringUtils.stringifyException(e));
      System.err.println("testTransformerDatabase() failed.");
      fail("testTransformerDatabase failed:" + 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