ChangeScriptRepository implements AvailableChangeScriptsProvider { public List<ChangeScript> getOrderedListOfDoChangeScripts() { return Collections.unmodifiableList(scripts); } @SuppressWarnings("unchecked")  ChangeScriptRepository(List<ChangeScript> scripts); List<ChangeScript> getOrderedListOfDoChangeScripts(); List<ChangeScript> getAvailableChangeScripts();  }
@Test public void shouldReturnAnOrderedListOfChangeScripts() throws Exception { ChangeScript one = new ChangeScript(1); ChangeScript two = new ChangeScript(2); ChangeScript three = new ChangeScript(3); ChangeScript four = new ChangeScript(4); ChangeScriptRepository repository = new ChangeScriptRepository(Arrays.asList( three, two, four, one )); List<ChangeScript> list = repository.getOrderedListOfDoChangeScripts(); assertThat(4, equalTo(list.size())); assertSame(one, list.get(0)); assertSame(two, list.get(1)); assertSame(three, list.get(2)); assertSame(four, list.get(3)); }
@Test public void shouldAllowChangeScriptsThatStartFromZero() throws Exception { ChangeScript zero = new ChangeScript(0); ChangeScript four = new ChangeScript(4); ChangeScriptRepository repository = new ChangeScriptRepository(Arrays.asList( zero, four )); List<ChangeScript> list = repository.getOrderedListOfDoChangeScripts(); assertThat(2, equalTo(list.size())); assertSame(zero, list.get(0)); assertSame(four, list.get(1)); }