FailOnDuplicatesCollector implements ScriptCollector { @Override public void collect(ScriptFile scriptFile) { if (!versions.contains(scriptFile.getVersion())) { scripts.add(scriptFile); versions.add(scriptFile.getVersion()); } else { throw new MigrationException( format("Found two different files for version %d", scriptFile.getVersion()), scriptFile.getScriptName()); } }  @Override void collect(ScriptFile scriptFile); @Override Collection<ScriptFile> getScriptFiles();  }
@Test(expected = MigrationException.class) public void shouldThrowExceptionWhenDuplicateScriptFileVersionsGiven() { scriptCollector.collect(new ScriptFile(0, "/0_init.cql", "init.cql")); scriptCollector.collect(new ScriptFile(0, "/0_another-init.cql", "another-init.cql")); }