HiveTableManager { public Table createTable(String tableName, String partitionColumnName, Schema schema, int version, String owner) throws MetaStoreException { try { URI location = locationResolver.resolveLocation(databaseName + "/" + tableName, true); Table table = hiveTableStrategy.newHiveTable(databaseName, tableName, partitionColumnName, location.toString(), schema, version); table.setOwner(owner); metaStoreClient.createTable(table); return 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 createTable() throws Exception { when(locationResolver.resolveLocation(anyString(), anyBoolean())).thenReturn(location); when( hiveTableStrategy.newHiveTable(anyString(), anyString(), anyString(), anyString(), any(Schema.class), anyInt())) .thenReturn(table); underTest.createTable(TABLE, PARTITION_COLUMN, schema, 1, "owner"); verify(locationResolver).resolveLocation(DATABASE + "/" + TABLE, true); verify(hiveTableStrategy).newHiveTable(DATABASE, TABLE, PARTITION_COLUMN, location.toString(), schema, 1); verify(table).setOwner("owner"); verify(metaStoreClient).createTable(table); }
@Test(expected = MetaStoreException.class) public void createTable_shouldWrapTException() throws Exception { when(locationResolver.resolveLocation(anyString(), anyBoolean())).thenReturn(location); when( hiveTableStrategy.newHiveTable(anyString(), anyString(), anyString(), anyString(), any(Schema.class), anyInt())) .thenReturn(table); doThrow(TException.class).when(metaStoreClient).createTable(table); underTest.createTable(TABLE, PARTITION_COLUMN, schema, 1, "owner"); }