@Test
  public void testPermFunction() throws Exception {

    reset(mockedAuthorizer);
    final String funcName = "testauthfunc1";
    int status = driver.compile("create function " + dbName + "." + funcName
        + " as 'org.apache.hadoop.hive.ql.udf.UDFPI'", true);
    assertEquals(0, status);

    List<HivePrivilegeObject> outputs = getHivePrivilegeObjectInputs().getRight();

    HivePrivilegeObject funcObj;
    assertEquals("number of output objects", 1, outputs.size());

    funcObj = outputs.get(0);

    assertEquals("input type", HivePrivilegeObjectType.FUNCTION, funcObj.getType());
    assertTrue("function name", funcName.equalsIgnoreCase(funcObj.getObjectName()));
    assertTrue("db name", dbName.equalsIgnoreCase(funcObj.getDbname()));

    // actually create the permanent function
    driver.run();

    // Verify privilege objects
    reset(mockedAuthorizer);
    status = driver.compile("select  " + dbName + "." + funcName + "() , i from " + tableName, true);
    assertEquals(0, status);

    List<HivePrivilegeObject> inputs = getHivePrivilegeObjectInputs().getLeft();
    assertEquals("number of input objects", 2, inputs.size());
    HivePrivilegeObject tableObj;
    if (inputs.get(0).getType() == HivePrivilegeObjectType.FUNCTION) {
      funcObj = inputs.get(0);
      tableObj = inputs.get(1);
    } else {
      funcObj = inputs.get(1);
      tableObj = inputs.get(0);
    }

    assertEquals("input type", HivePrivilegeObjectType.FUNCTION, funcObj.getType());
    assertEquals("function name", funcName.toLowerCase(), funcObj.getObjectName().toLowerCase());
    assertEquals("db name", dbName.toLowerCase(), funcObj.getDbname().toLowerCase());

    assertEquals("input type", HivePrivilegeObjectType.TABLE_OR_VIEW, tableObj.getType());
    assertEquals("table name", tableName.toLowerCase(), tableObj.getObjectName().toLowerCase());

    // create 2nd permanent function
    String funcName2 = "funcName2";
    driver.run("create function " + dbName + "." + funcName2 + " as 'org.apache.hadoop.hive.ql.udf.UDFRand'");

    // try using 2nd permanent function and verify its only 2nd one that shows up
    // for auth
    reset(mockedAuthorizer);
    status = driver.compile("select  " + dbName + "." + funcName2 + "(i)  from " + tableName, true);
    assertEquals(0, status);

    inputs = getHivePrivilegeObjectInputs().getLeft();
    assertEquals("number of input objects", 2, inputs.size());
    if (inputs.get(0).getType() == HivePrivilegeObjectType.FUNCTION) {
      funcObj = inputs.get(0);
      tableObj = inputs.get(1);
    } else {
      funcObj = inputs.get(1);
      tableObj = inputs.get(0);
    }

    assertEquals("input type", HivePrivilegeObjectType.FUNCTION, funcObj.getType());
    assertEquals("function name", funcName2.toLowerCase(), funcObj.getObjectName().toLowerCase());
    assertEquals("db name", dbName.toLowerCase(), funcObj.getDbname().toLowerCase());

    assertEquals("input type", HivePrivilegeObjectType.TABLE_OR_VIEW, tableObj.getType());
    assertEquals("table name", tableName.toLowerCase(), tableObj.getObjectName().toLowerCase());

    // try using both permanent functions
    reset(mockedAuthorizer);
    status = driver.compile(
        "select  " + dbName + "." + funcName2 + "(i), " + dbName + "." + funcName + "(), j  from " + tableName, true);
    assertEquals(0, status);

    inputs = getHivePrivilegeObjectInputs().getLeft();
    assertEquals("number of input objects", 3, inputs.size());
    boolean foundF1 = false;
    boolean foundF2 = false;
    boolean foundTable = false;
    for (HivePrivilegeObject inp : inputs) {
      if (inp.getType() == HivePrivilegeObjectType.FUNCTION) {
        if (funcName.equalsIgnoreCase(inp.getObjectName())) {
          foundF1 = true;
        } else if (funcName2.equalsIgnoreCase(inp.getObjectName())) {
          foundF2 = true;
        }
      } else if (inp.getType() == HivePrivilegeObjectType.TABLE_OR_VIEW
          && tableName.equalsIgnoreCase(inp.getObjectName().toLowerCase())) {
        foundTable = true;
      }
    }
    assertTrue("Found " + funcName, foundF1);
    assertTrue("Found " + funcName2, foundF2);
    assertTrue("Found Table", foundTable);
  }
This factory creates a mocked HiveAuthorizer class. Use the mocked class to
capture the argument passed to it in the test case.
itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/authorization/plugin/TestHiveAuthorizerCheckInvocation.java