@Override public void createTaskTables() { if (config.get().isCreateTables()) { final MetadataStorageTablesConfig tablesConfig = tablesConfigSupplier.get(); final String entryType = tablesConfig.getTaskEntryType(); createEntryTable(tablesConfig.getEntryTable(entryType)); createLogTable(tablesConfig.getLogTable(entryType), entryType); createLockTable(tablesConfig.getLockTable(entryType), entryType); } }
@Test public void testCreateTables() throws Exception { final LinkedList<String> tables = new LinkedList<String>(); final String entryType = tablesConfig.getTaskEntryType(); tables.add(tablesConfig.getConfigTable()); tables.add(tablesConfig.getSegmentsTable()); tables.add(tablesConfig.getRulesTable()); tables.add(tablesConfig.getLockTable(entryType)); tables.add(tablesConfig.getLogTable(entryType)); tables.add(tablesConfig.getEntryTable(entryType)); tables.add(tablesConfig.getAuditTable()); connector.createSegmentTable(); connector.createConfigTable(); connector.createRulesTable(); connector.createTaskTables(); connector.createAuditTable(); connector .getDBI() .withHandle( new HandleCallback<Void>() { @Override public Void withHandle(Handle handle) throws Exception { for (String table : tables) { Assert.assertTrue( String.format("table %s was not created!", table), connector.tableExists(handle, table)); } return null; } }); for (String table : tables) { dropTable(table); } }