@Test
  public void testAlterTableAlreadyExists() throws Exception {
    Table originalTable = testTables[0];
    Table newTable = originalTable.deepCopy();

    newTable.setTableName(testTables[2].getTableName());
    try {
      // Already existing table
      client.alter_table(originalTable.getDbName(), originalTable.getTableName(), newTable);
      // TODO: Maybe throw AlreadyExistsException.
      Assert.fail("Expected an InvalidOperationException to be thrown");
    } catch (InvalidOperationException exception) {
      // Expected exception
    }
  }
This test creates and queries a table and then drops it. Good for testing the happy path
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java