@BeforeClass
  public static void beforeTest() throws Exception {
    HiveConf conf = new HiveConfForTest(TestCLIAuthzSessionContext.class);
    conf.setVar(ConfVars.HIVE_AUTHORIZATION_MANAGER, MockedHiveAuthorizerFactory.class.getName());
    conf.setVar(ConfVars.HIVE_AUTHENTICATOR_MANAGER, SessionStateUserAuthenticator.class.getName());
    conf.setBoolVar(ConfVars.HIVE_AUTHORIZATION_ENABLED, true);
    conf.setBoolVar(ConfVars.HIVE_SUPPORT_CONCURRENCY, false);

    // once SessionState for thread is set, CliDriver picks conf from it
    CliSessionState ss = new CliSessionState(conf);
    ss.err = new SessionStream(System.err);
    ss.out = new SessionStream(System.out);
    SessionState.start(ss);
    TestCLIAuthzSessionContext.driver = new CliDriver();
 }
This factory captures the HiveAuthzSessionContext argument and returns mocked
HiveAuthorizer class
itests/hive-unit/src/test/java/org/apache/hive/jdbc/authorization/TestCLIAuthzSessionContext.java