HiveTableManager { public int getSchemaVersion(String tableName) throws MetaStoreException { try { Table table = metaStoreClient.getTable(databaseName, tableName); return hiveTableStrategy.getSchemaVersion(table); } 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 getSchemaVersion() throws Exception { when(metaStoreClient.getTable(DATABASE, TABLE)).thenReturn(table); when(hiveTableStrategy.getSchemaVersion(table)).thenReturn(1); int result = underTest.getSchemaVersion(TABLE); assertThat(result, is(1)); }
@Test(expected = MetaStoreException.class) public void getSchemaVersion_shouldWrapTException() throws Exception { doThrow(TException.class).when(metaStoreClient).getTable(DATABASE, TABLE); underTest.getSchemaVersion(TABLE); }