@Test public void shouldApplyChangeScriptBySplittingContentUsingTheSplitter() throws Exception { when(splitter.split("split; content")).thenReturn(Arrays.asList("split", "content")); applier.applyChangeScript(new StubChangeScript(1, "script", "split; content")); verify(queryExecuter).execute("split"); verify(queryExecuter).execute("content"); }
protected void applyChangeScript(ChangeScript script) { List<String> statements = splitter.split(script.getContent()); for (int i = 0; i < statements.size(); i++) { String statement = statements.get(i); try { if (statements.size() > 1) { System.err.println(" -> statement " + (i+1) + " of " + statements.size() + "..."); } queryExecuter.execute(statement); } catch (SQLException e) { throw new ChangeScriptFailedException(e, script, i+1, statement); } } }
DirectToDbApplier implements ChangeScriptApplier { protected void applyChangeScript(ChangeScript script) { List<String> statements = splitter.split(script.getContent()); for (int i = 0; i < statements.size(); i++) { String statement = statements.get(i); try { if (statements.size() > 1) { System.err.println(" -> statement " + (i+1) + " of " + statements.size() + "..."); } queryExecuter.execute(statement); } catch (SQLException e) { throw new ChangeScriptFailedException(e, script, i+1, statement); } } } }
DirectToDbApplier implements ChangeScriptApplier { protected void applyChangeScript(ChangeScript script) { List<String> statements = splitter.split(script.getContent()); for (int i = 0; i < statements.size(); i++) { String statement = statements.get(i); try { if (statements.size() > 1) { System.err.println(" -> statement " + (i+1) + " of " + statements.size() + "..."); } queryExecuter.execute(statement); } catch (SQLException e) { throw new ChangeScriptFailedException(e, script, i+1, statement); } } } DirectToDbApplier(QueryExecuter queryExecuter, DatabaseSchemaVersionManager schemaVersionManager, QueryStatementSplitter splitter); }
DirectToDbApplier implements ChangeScriptApplier { protected void applyChangeScript(ChangeScript script) { List<String> statements = splitter.split(script.getContent()); for (int i = 0; i < statements.size(); i++) { String statement = statements.get(i); try { if (statements.size() > 1) { System.err.println(" -> statement " + (i+1) + " of " + statements.size() + "..."); } queryExecuter.execute(statement); } catch (SQLException e) { throw new ChangeScriptFailedException(e, script, i+1, statement); } } } DirectToDbApplier(QueryExecuter queryExecuter, DatabaseSchemaVersionManager schemaVersionManager, QueryStatementSplitter splitter); void apply(List<ChangeScript> changeScript); void begin(); }
DirectToDbApplier implements ChangeScriptApplier { protected void applyChangeScript(ChangeScript script) { List<String> statements = splitter.split(script.getContent()); for (int i = 0; i < statements.size(); i++) { String statement = statements.get(i); try { if (statements.size() > 1) { System.err.println(" -> statement " + (i+1) + " of " + statements.size() + "..."); } queryExecuter.execute(statement); } catch (SQLException e) { throw new ChangeScriptFailedException(e, script, i+1, statement); } } } DirectToDbApplier(QueryExecuter queryExecuter, DatabaseSchemaVersionManager schemaVersionManager, QueryStatementSplitter splitter); void apply(List<ChangeScript> changeScript); void begin();  }