SchemaVersion { public List<SchemaTransition> listTransitionsForTarget(SchemaVersion target) { List<SchemaTransition> transitions = new ArrayList<>(); SchemaVersion migrateTo = next(); while (target.isAfterOrEquals(migrateTo)) { SchemaTransition transition = SchemaTransition.to(migrateTo); transitions.add(transition); migrateTo = migrateTo.next(); } return transitions; } SchemaVersion(int value); int getValue(); boolean isAfterOrEquals(SchemaVersion other); SchemaVersion next(); SchemaVersion previous(); boolean isBefore(SchemaVersion other); List<SchemaTransition> listTransitionsForTarget(SchemaVersion target); @Override final boolean equals(Object o); @Override final int hashCode(); @Override String toString();  }
@Test void listTransitionsForTargetShouldReturnEmptyOnSameVersion() { Assertions.assertThat(VERSION_2.listTransitionsForTarget(VERSION_2)).isEmpty(); }
@Test void listTransitionsForTargetShouldReturnEmptyOnSmallerVersion() { Assertions.assertThat(VERSION_2.listTransitionsForTarget(VERSION_1)).isEmpty(); }
@Test void listTransitionsForTargetShouldReturnListOfVersionsWhenGreater() { Assertions.assertThat(VERSION_2.listTransitionsForTarget(VERSION_4)) .containsExactly(SchemaTransition.to(VERSION_3), SchemaTransition.to(VERSION_4)); }