@Test public void shouldUpdateChangelogTable() throws Exception { Date now = new Date(); when(queryExecuter.getDatabaseUsername()).thenReturn("DBUSER"); when(timeProvider.now()).thenReturn(now); schemaVersionManager.recordScriptApplied(script); String expected = "INSERT INTO changelog (change_number, complete_dt, applied_by, description) " + "VALUES (?, ?, ?, ?)"; verify(queryExecuter).execute(expected, script.getId(), new Timestamp(now.getTime()), "DBUSER", script.getDescription()); }
public void recordScriptApplied(ChangeScript script) { try { queryExecuter.execute( "INSERT INTO " + changeLogTableName + " (change_number, complete_dt, applied_by, description)" + " VALUES (?, ?, ?, ?)", script.getId(), new Timestamp(timeProvider.now().getTime()), queryExecuter.getDatabaseUsername(), script.getDescription() ); } catch (SQLException e) { throw new SchemaVersionTrackingException("Could not update change log because: " + e.getMessage(), e); } }
DatabaseSchemaVersionManager implements AppliedChangesProvider { public void recordScriptApplied(ChangeScript script) { try { queryExecuter.execute( "INSERT INTO " + changeLogTableName + " (change_number, complete_dt, applied_by, description)" + " VALUES (?, ?, ?, ?)", script.getId(), new Timestamp(timeProvider.now().getTime()), queryExecuter.getDatabaseUsername(), script.getDescription() ); } catch (SQLException e) { throw new SchemaVersionTrackingException("Could not update change log because: " + e.getMessage(), e); } } }
DatabaseSchemaVersionManager implements AppliedChangesProvider { public void recordScriptApplied(ChangeScript script) { try { queryExecuter.execute( "INSERT INTO " + changeLogTableName + " (change_number, complete_dt, applied_by, description)" + " VALUES (?, ?, ?, ?)", script.getId(), new Timestamp(timeProvider.now().getTime()), queryExecuter.getDatabaseUsername(), script.getDescription() ); } catch (SQLException e) { throw new SchemaVersionTrackingException("Could not update change log because: " + e.getMessage(), e); } } DatabaseSchemaVersionManager(QueryExecuter queryExecuter, String changeLogTableName); }
DatabaseSchemaVersionManager implements AppliedChangesProvider { public void recordScriptApplied(ChangeScript script) { try { queryExecuter.execute( "INSERT INTO " + changeLogTableName + " (change_number, complete_dt, applied_by, description)" + " VALUES (?, ?, ?, ?)", script.getId(), new Timestamp(timeProvider.now().getTime()), queryExecuter.getDatabaseUsername(), script.getDescription() ); } catch (SQLException e) { throw new SchemaVersionTrackingException("Could not update change log because: " + e.getMessage(), e); } } DatabaseSchemaVersionManager(QueryExecuter queryExecuter, String changeLogTableName); List<Long> getAppliedChanges(); String getChangelogDeleteSql(ChangeScript script); void recordScriptApplied(ChangeScript script); void setTimeProvider(CurrentTimeProvider timeProvider); }
DatabaseSchemaVersionManager implements AppliedChangesProvider { public void recordScriptApplied(ChangeScript script) { try { queryExecuter.execute( "INSERT INTO " + changeLogTableName + " (change_number, complete_dt, applied_by, description)" + " VALUES (?, ?, ?, ?)", script.getId(), new Timestamp(timeProvider.now().getTime()), queryExecuter.getDatabaseUsername(), script.getDescription() ); } catch (SQLException e) { throw new SchemaVersionTrackingException("Could not update change log because: " + e.getMessage(), e); } } DatabaseSchemaVersionManager(QueryExecuter queryExecuter, String changeLogTableName); List<Long> getAppliedChanges(); String getChangelogDeleteSql(ChangeScript script); void recordScriptApplied(ChangeScript script); void setTimeProvider(CurrentTimeProvider timeProvider);  }