We recently migrated from MongoBee to Mongock, and with Mongock 5 version the @ChangeLog
and @ChangeSet
are depricated. Writing the @ChangeUnit
is easy enough and rollback methods are very helpful.
However, I'm unable to figure out how to write a test simulating the migration in test DB and validating the changes in DB, as there are @BeforeExecution
, @RollbackBeforeExecution
, @Execution
and @RollbackExecution
attributes or lifecycle methods in a @ChangeUnit.
Earlier, I used to just call the method with @ChangeSet
annotation like
assertOriginalStructure();
someMigrationChangeLog.updateIndexOnSomething();
assertIndexUpdated();
Now, I'm unsure if there is a clean way to write the above test as there is some logic in @BeforeExecution
and also in @Execution
. I know individually calling the annotated methods will work, but I wanted to know if there is a way to just run one @ChangeUnit
as a whole.