LiquibaseMigrationWatcher implements ChangeExecListener { @Override public void ran(final ChangeSet changeSet, final DatabaseChangeLog databaseChangeLog, final Database database, final ExecType execType) { lastVersion = changeSet; totalRun++; } LiquibaseMigrationWatcher(final List<ChangeSetStatus> changesets); @Override void willRun(final ChangeSet changeSet,
                        final DatabaseChangeLog databaseChangeLog,
                        final Database database,
                        final RunStatus runStatus); @Override void ran(final ChangeSet changeSet,
                    final DatabaseChangeLog databaseChangeLog,
                    final Database database,
                    final ExecType execType); @Override void rolledBack(final ChangeSet changeSet,
                           final DatabaseChangeLog databaseChangeLog,
                           final Database database); @Override void preconditionFailed(final PreconditionFailedException error,
                                   final FailOption onFail); @Override void preconditionErrored(final PreconditionErrorException error,
                                    final ErrorOption onError); @Override void willRun(final Change change,
                        final ChangeSet changeSet,
                        final DatabaseChangeLog changeLog,
                        final Database database); @Override void ran(final Change change,
                    final ChangeSet changeSet,
                    final DatabaseChangeLog changeLog,
                    final Database database); @Override void runFailed(final ChangeSet changeSet,
                          final DatabaseChangeLog databaseChangeLog,
                          final Database database,
                          final Exception exception); Boolean isMigrated(); ChangeSet getCurrentVersion();  }
@Test public void ran() { List<ChangeSetStatus> changeSets = new ArrayList<>(); ChangeSet mockChangeSet = Mockito.mock(ChangeSet.class); DatabaseChangeLog mockDbChangeLog = Mockito.mock(DatabaseChangeLog.class); Database mockDatabase = Mockito.mock(Database.class); LiquibaseMigrationWatcher w = new LiquibaseMigrationWatcher(changeSets); assertFalse(w.isMigrated()); assertNull(w.getCurrentVersion()); w.ran(mockChangeSet, mockDbChangeLog, mockDatabase, ExecType.EXECUTED); assertTrue(w.isMigrated()); assertSame(mockChangeSet, w.getCurrentVersion()); }