Source:
<code>public void testRenameTable() { <START> SchemaTableName tableName = new SchemaTableName("test", "test_rename"); <END> metadata.createSchema(SESSION, "test", ImmutableMap.of()); ConnectorOutputTableHandle table = metadata.beginCreateTable( SESSION, new ConnectorTableMetadata(tableName, ImmutableList.of(), ImmutableMap.of()), Optional.empty()); metadata.finishCreateTable(SESSION, table, ImmutableList.of()); SchemaTableName invalidSchemaTableName = new SchemaTableName("rename", "test_renamed"); ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, tableName); try { metadata.renameTable(SESSION, tableHandle, invalidSchemaTableName); fail("Should fail because schema does not exist"); } catch (PrestoException ex) { assertEquals(ex.getErrorCode(), NOT_FOUND.toErrorCode()); assertEquals(ex.getMessage(), "Schema rename not found"); } SchemaTableName sameSchemaTableName = new SchemaTableName("test", "test_renamed"); metadata.renameTable(SESSION, metadata.getTableHandle(SESSION, tableName), sameSchemaTableName); assertEquals(metadata.listTables(SESSION, "test"), ImmutableList.of(sameSchemaTableName)); metadata.createSchema(SESSION, "test2", ImmutableMap.of()); SchemaTableName differentSchemaTableName = new SchemaTableName("test2", "test_renamed"); metadata.renameTable(SESSION, metadata.getTableHandle(SESSION, sameSchemaTableName), differentSchemaTableName); assertEquals(metadata.listTables(SESSION, "test"), ImmutableList.of()); assertEquals(metadata.listTables(SESSION, "test2"), ImmutableList.of(differentSchemaTableName)); }</code><technical_language>nit: some more meaningful test data. Instead of test test_schema, test_rename test_table_to_be_renamed. is is a bit easier understand test logic</technical_language>

Target:
public void testRenameTable() { SchemaTableName tableName = new SchemaTableName("test_schema", "test_talbe_to_be_renamed"); metadata.createSchema(SESSION, "test_schema", ImmutableMap.of()); ConnectorOutputTableHandle table = metadata.beginCreateTable( SESSION, new ConnectorTableMetadata(tableName, ImmutableList.of(), ImmutableMap.of()), Optional.empty()); metadata.finishCreateTable(SESSION, table, ImmutableList.of()); SchemaTableName invalidSchemaTableName = new SchemaTableName("test_schema_not_exist", "test_table_renamed"); ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, tableName); Throwable throwable = expectThrows(SchemaNotFoundException.class, () -> metadata.renameTable(SESSION, tableHandle, invalidSchemaTableName)); assertTrue(throwable.getMessage().equals("Schema test_schema_not_exist not found")); SchemaTableName sameSchemaTableName = new SchemaTableName("test_schema", "test_renamed"); metadata.renameTable(SESSION, metadata.getTableHandle(SESSION, tableName), sameSchemaTableName); assertEquals(metadata.listTables(SESSION, "test_schema"), ImmutableList.of(sameSchemaTableName)); metadata.createSchema(SESSION, "test_different_schema", ImmutableMap.of()); SchemaTableName differentSchemaTableName = new SchemaTableName("test_different_schema", "test_renamed"); metadata.renameTable(SESSION, metadata.getTableHandle(SESSION, sameSchemaTableName), differentSchemaTableName); assertEquals(metadata.listTables(SESSION, "test_schema"), ImmutableList.of()); assertEquals(metadata.listTables(SESSION, "test_different_schema"), ImmutableList.of(differentSchemaTableName)); }