@Test
  public void testAlterFunction() throws Exception {
    Function newFunction =
        new FunctionBuilder()
            .setDbName(OTHER_DATABASE)
            .setName("test_function_2")
            .setOwner("Owner2")
            .setOwnerType(PrincipalType.GROUP)
            .setClass("org.apache.hadoop.hive.ql.udf.generic.GenericUDFUpper2")
            .setFunctionType(FunctionType.JAVA)
            .build(metaStore.getConf());

    client.alterFunction(testFunctions[0].getDbName(), testFunctions[0].getFunctionName(),
        newFunction);

    Function alteredFunction = client.getFunction(newFunction.getDbName(),
        newFunction.getFunctionName());
    // Currently this method only sets
    //  - Database
    //  - FunctionName
    //  - OwnerName
    //  - OwnerType
    //  - ClassName
    //  - FunctionType
    Assert.assertEquals("Comparing Database", newFunction.getDbName(),
        alteredFunction.getDbName());
    Assert.assertEquals("Comparing FunctionName", newFunction.getFunctionName(),
        alteredFunction.getFunctionName());
    Assert.assertEquals("Comparing OwnerName", newFunction.getOwnerName(),
        alteredFunction.getOwnerName());
    Assert.assertEquals("Comparing OwnerType", newFunction.getOwnerType(),
        alteredFunction.getOwnerType());
    Assert.assertEquals("Comparing ClassName", newFunction.getClassName(),
        alteredFunction.getClassName());
    Assert.assertEquals("Comparing FunctionType", newFunction.getFunctionType(),
        alteredFunction.getFunctionType());
    try {
      client.getFunction(testFunctions[0].getDbName(), testFunctions[0].getDbName());
      Assert.fail("Expected a NoSuchObjectException to be thrown");
    } catch (NoSuchObjectException exception) {
      // Expected exception
    }

    // Test that not changing the database and the function name, but only other parameters, like
    // function class will not cause Exception
    newFunction = testFunctions[1].deepCopy();
    newFunction.setClassName("NewClassName");

    client.alterFunction(testFunctions[1].getDbName(), testFunctions[1].getFunctionName(),
        newFunction);

    alteredFunction = client.getFunction(newFunction.getDbName(), newFunction.getFunctionName());
    Assert.assertEquals("Comparing functions", newFunction, alteredFunction);
  }
This test creates and queries a function and then drops it. Good for testing the happy path.
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestFunctions.java