HiveTableManager { public void alterTable(String tableName, Schema schema, int version) throws MetaStoreException { try { Table table = metaStoreClient.getTable(databaseName, tableName); Table alteredTable = hiveTableStrategy.alterHiveTable(table, schema, version); metaStoreClient.alter_table(databaseName, tableName, alteredTable); } catch (TException e) { throw new MetaStoreException(e); } }  boolean tableExists(String tableName); Table createTable(String tableName, String partitionColumnName, Schema schema, int version, String owner); void grantPublicSelect(String tableName, String grantor); void alterTable(String tableName, Schema schema, int version); int getSchemaVersion(String tableName);  }
@Test public void alterTable() throws Exception { when(metaStoreClient.getTable(DATABASE, TABLE)).thenReturn(table); when(hiveTableStrategy.alterHiveTable(any(Table.class), any(Schema.class), anyInt())).thenReturn(table); underTest.alterTable(TABLE, schema, 1); verify(hiveTableStrategy).alterHiveTable(table, schema, 1); verify(metaStoreClient).alter_table(DATABASE, TABLE, table); }
@Test(expected = MetaStoreException.class) public void alterTable_shouldWrapTException() throws Exception { doThrow(TException.class).when(metaStoreClient).alter_table(anyString(), anyString(), isNull()); underTest.alterTable(TABLE, schema, 1); }