MigrationRepository { public int getLatestVersion() { if (migrationScripts.isEmpty()) { return 0; } return migrationScripts.get(migrationScripts.size() - 1).getVersion(); } MigrationRepository();  MigrationRepository(String scriptPath);  MigrationRepository(String scriptPath, ScriptCollector scriptCollector);  MigrationRepository(String scriptPath, ScriptCollector scriptCollector, ScannerRegistry scannerRegistry); void setScriptFilter(ScriptFilter scriptFilter); int getLatestVersion(); List<DbMigration> getMigrationsSinceVersion(int version); static final String DEFAULT_SCRIPT_PATH; static final String SCRIPT_EXTENSION; static final String SCRIPT_ENCODING; static final String VERSION_NAME_DELIMITER; static final String SINGLE_LINE_COMMENT_PATTERN; }
@Test public void shouldReturnThreeAsLatestVersionWhenThreeScriptsInResourcesGiven() { int version = migrationRepository.getLatestVersion(); assertThat(version, is(equalTo(3))); }
@Test public void shouldReturnZeroAsVersionWhenEmptyDirectoryGiven() { MigrationRepository repository = new MigrationRepository("cassandra/migrationtest/empty"); assertThat(repository.getLatestVersion(), is(equalTo(0))); }
@Test public void shouldReturnCorrectVersionNumberWhenPathWithLeadingSlashGiven() { MigrationRepository repository = new MigrationRepository("/cassandra/migrationtest/empty"); assertThat(repository.getLatestVersion(), is(equalTo(0))); }