@Override
    public ProcNodeInterface lookup(String dbIdOrName) throws AnalysisException {
        if (globalStateMgr == null) {
            throw new AnalysisException("globalStateMgr is null");
        }
        if (Strings.isNullOrEmpty(dbIdOrName)) {
            throw new AnalysisException("database id or name is null or empty");
        }

        Database db;
        try {
            db = globalStateMgr.getDb(Long.parseLong(dbIdOrName));
        } catch (NumberFormatException e) {
            db = globalStateMgr.getDb(dbIdOrName);
        }

        if (db == null) {
            throw new AnalysisException("Unknown database id or name \"" + dbIdOrName + "\"");
        }

        return new TablesProcDir(db);
    }
@Test(expected = AnalysisException.class)
    public void testLookupNormal() throws AnalysisException {
        new Expectations(globalStateMgr) {
            {
                globalStateMgr.getDb("db1");
                minTimes = 0;
                result = db1;

                globalStateMgr.getDb("db2");
                minTimes = 0;
                result = db2;

                globalStateMgr.getDb("db3");
                minTimes = 0;
                result = null;

                globalStateMgr.getDb(db1.getId());
                minTimes = 0;
                result = db1;

                globalStateMgr.getDb(db2.getId());
                minTimes = 0;
                result = db2;

                globalStateMgr.getDb(anyLong);
                minTimes = 0;
                result = null;
            }
        };

        DbsProcDir dir;
        ProcNodeInterface node;

        dir = new DbsProcDir(globalStateMgr);
        try {
            node = dir.lookup(String.valueOf(db1.getId()));
            Assert.assertNotNull(node);
            Assert.assertTrue(node instanceof TablesProcDir);
        } catch (AnalysisException e) {
            Assert.fail();
        }

        dir = new DbsProcDir(globalStateMgr);
        try {
            node = dir.lookup(String.valueOf(db2.getId()));
            Assert.assertNotNull(node);
            Assert.assertTrue(node instanceof TablesProcDir);
        } catch (AnalysisException e) {
            Assert.fail();
        }

        dir = new DbsProcDir(globalStateMgr);
        node = dir.lookup("10002");
        Assert.assertNull(node);
    }