hbaseMetadata.deleteTableIndex(1, "");
}
@Test
public void testDeleteIndex() {
final TableSchema tableSchema =
new TableSchema(COLUMN_SCHEMAS,
ImmutableList.<IndexSchema>of(
new IndexSchema(INDEX_NAME, Lists.newArrayList(COLUMN_NAME), false)));
// Create a new table with the configured details
hbaseMetadata.createTable(TABLE_NAME, tableSchema);
final long tableId = hbaseMetadata.getTableId(TABLE_NAME);
// Verify that the table schema contains indices after creation
final TableSchema schemaBefore = hbaseMetadata.getSchema(tableId);
assertNotNull(schemaBefore);
final Collection<IndexSchema> schemaIndices = schemaBefore.getIndices();
assertEquals(1, schemaIndices.size());
final IndexSchema newIndexDetails = Iterables.find(schemaIndices, indexPredicate);
assertNotNull(newIndexDetails);
final List<String> indexColumns = newIndexDetails.getColumns();
assertEquals(1, indexColumns.size());
assertEquals(COLUMN_NAME, indexColumns.get(0));
// Verify that the index exists after table creation
final Map<String, Long> tableIndexInfo = hbaseMetadata.getIndexIds(tableId);
assertEquals(1, tableIndexInfo.size());
assertTrue(tableIndexInfo.containsKey(INDEX_NAME));
// Remove an existing index from the table
hbaseMetadata.deleteTableIndex(tableId, INDEX_NAME);
// Verify that the table schema has been correctly updated
final TableSchema schemaAfter = hbaseMetadata.getSchema(tableId);
assertNotNull(schemaAfter);
assertTrue(schemaAfter.getIndices().isEmpty());
// Verify that the index has been removed correctly
assertTrue(hbaseMetadata.getIndexIds(tableId).isEmpty());
}