public Database getDb(String catalogName, String dbName) {
        Optional<ConnectorMetadata> connectorMetadata = getOptionalMetadata(catalogName);
        Database db = connectorMetadata.map(metadata -> metadata.getDb(dbName)).orElse(null);
        // set catalog name if external catalog
        if (db != null && CatalogMgr.isExternalCatalog(catalogName)) {
            db.setCatalogName(catalogName);
        }
        return db;
    }
@Test
    public void testGetDb(@Mocked HiveMetaStoreClient metaStoreThriftClient) throws TException {
        new Expectations() {
            {
                metaStoreThriftClient.getDatabase("db2");
                result = new Database("db2", "", "", null);
                minTimes = 0;
            }
        };

        MetadataMgr metadataMgr = GlobalStateMgr.getCurrentState().getMetadataMgr();

        com.starrocks.catalog.Database database = metadataMgr.getDb("default_catalog", "db1");
        Assert.assertNotNull(database);
        database = metadataMgr.getDb("default_catalog", "db1");
        Assert.assertNotNull(database);

        com.starrocks.catalog.Database database1 = metadataMgr.getDb("hive_catalog", "db2");
        Assert.assertNotNull(database1);
        Assert.assertEquals("hive_catalog.db2", database1.getUUID());

        com.starrocks.catalog.Database database2 = metadataMgr.getDb("hive_catalog", "db3");
        Assert.assertNull(database2);

        Assert.assertNull(metadataMgr.getDb("not_exist_catalog", "xxx"));
    }