class SpreadsheetMetadata implements ConnectorMetadata {

  @Override
  public ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName) {
    Path spreadsheetPath = getSpreadsheetBasePath(session.getUser());
    Path filePath = getSpreadsheetFilePath(session, spreadsheetPath, tableName.getSchemaName());
    return new SpreadsheetTableHandle(session.getUser(), tableName, filePath.toString());
  }

}

class SpreadsheetMetadataTest {

  private static UserGroupInformation ugi;
  private static final String SCHEMA_NAME;
  public static final ConnectorSession SESSION;
  private boolean useFileCache;
  private Configuration conf;

  @Test
  public void testGetTableHandle() throws IOException {

    Path basePath = setupTest(conf, SESSION.getUser(), SpreadsheetMetadataTest.class);
    SpreadsheetMetadata spreadsheetMetadata = new SpreadsheetMetadata(ugi, conf, basePath, SPREADSHEETS, useFileCache,
        true);
    List<SchemaTableName> listTables = spreadsheetMetadata.listTables(SESSION, SCHEMA_NAME);
    for (SchemaTableName name : listTables) {
      ConnectorTableHandle tableHandle = spreadsheetMetadata.getTableHandle(SESSION, name);
      assertTrue(tableHandle instanceof SpreadsheetTableHandle);
      SpreadsheetTableHandle spreadsheetTableHandle = (SpreadsheetTableHandle) tableHandle;
      String filePath = new Path(new Path(new Path(basePath, SESSION.getUser()), SPREADSHEETS),
          PRESTO_EXAMPLE_XLSX).toString();
      assertEquals(filePath, spreadsheetTableHandle.getSpreadsheetPath());
      SchemaTableName tableName = spreadsheetTableHandle.getTableName();
      assertEquals(name, tableName);
      assertEquals(SESSION.getUser(), spreadsheetTableHandle.getUser());
    }
  }

}