MigrationContainer { @Nullable public List<Migration> findMigrationPath(int start, int end) { if (start == end) { return Collections.emptyList(); } boolean migrateUp = end > start; List<Migration> result = new ArrayList<>(); return findUpMigrationPath(result, migrateUp, start, end); }  void addMigrations(Migration... migrations); @Nullable List<Migration> findMigrationPath(int start, int end);  }
@Test public void testFindMigrationPath() { MigrationContainer migrationContainer = new MigrationContainer(); migrationContainer.addMigrations(MIGRATION_12, MIGRATION_23, MIGRATION_34); assertEquals(MIGRATION_12, migrationContainer.findMigrationPath(1, 2).get(0)); assertEquals(MIGRATION_23, migrationContainer.findMigrationPath(2, 3).get(0)); assertEquals(MIGRATION_34, migrationContainer.findMigrationPath(3, 4).get(0)); assertEquals(0, migrationContainer.findMigrationPath(1, 1).size()); assertEquals(1, migrationContainer.findMigrationPath(1, 2).size()); assertEquals(2, migrationContainer.findMigrationPath(1, 3).size()); assertEquals(3, migrationContainer.findMigrationPath(1, 4).size()); }
@Test public void testFindMigrationPath_shouldReturnNullIfMigrationNotFound() { MigrationContainer migrationContainer = new MigrationContainer(); assertNull(migrationContainer.findMigrationPath(1, 2)); }