@Test public void saveExistingTable() throws Exception { doNothing().when(metadataManager) .save(any(Table.class)); doNothing().when(dataStore) .initializeTable(any(Table.class), anyBoolean()); doNothing().when(queryStore) .initializeTable(any(String.class)); doReturn(true).when(metadataManager) .exists(any(String.class)); try { Table table = new Table(); table.setName("abcd"); table.setTtl(10); tableManager.save(table); fail(); } catch (FoxtrotException e) { assertEquals(ErrorCode.TABLE_ALREADY_EXISTS, e.getCode()); } }
@Override public void save(Table table) { validateTableParams(table); if(metadataManager.exists(table.getName())) { throw FoxtrotExceptions.createTableExistsException(table.getName()); } queryStore.initializeTable(table.getName()); dataStore.initializeTable(table, false); metadataManager.save(table); }
FoxtrotTableManager implements TableManager { @Override public void save(Table table) { validateTableParams(table); if(metadataManager.exists(table.getName())) { throw FoxtrotExceptions.createTableExistsException(table.getName()); } queryStore.initializeTable(table.getName()); dataStore.initializeTable(table, false); metadataManager.save(table); } }
FoxtrotTableManager implements TableManager { @Override public void save(Table table) { validateTableParams(table); if(metadataManager.exists(table.getName())) { throw FoxtrotExceptions.createTableExistsException(table.getName()); } queryStore.initializeTable(table.getName()); dataStore.initializeTable(table, false); metadataManager.save(table); } @Inject  FoxtrotTableManager(TableMetadataManager metadataManager, QueryStore queryStore, DataStore dataStore); }
FoxtrotTableManager implements TableManager { @Override public void save(Table table) { validateTableParams(table); if(metadataManager.exists(table.getName())) { throw FoxtrotExceptions.createTableExistsException(table.getName()); } queryStore.initializeTable(table.getName()); dataStore.initializeTable(table, false); metadataManager.save(table); } @Inject  FoxtrotTableManager(TableMetadataManager metadataManager, QueryStore queryStore, DataStore dataStore); @Override void save(Table table); @Override void save(Table table, boolean forceCreateTable); @Override Table get(String name); @Override List<Table> getAll(); @Override void update(Table table); @Override void delete(String tableName); }
FoxtrotTableManager implements TableManager { @Override public void save(Table table) { validateTableParams(table); if(metadataManager.exists(table.getName())) { throw FoxtrotExceptions.createTableExistsException(table.getName()); } queryStore.initializeTable(table.getName()); dataStore.initializeTable(table, false); metadataManager.save(table); } @Inject  FoxtrotTableManager(TableMetadataManager metadataManager, QueryStore queryStore, DataStore dataStore); @Override void save(Table table); @Override void save(Table table, boolean forceCreateTable); @Override Table get(String name); @Override List<Table> getAll(); @Override void update(Table table); @Override void delete(String tableName);  }