### Question:
FlywayMigrationTask implements JavaMigration { @Override public void migrate(Context theContext) { myTask.setDriverType(myFlywayMigrator.getDriverType()); myTask.setDryRun(myFlywayMigrator.isDryRun()); myTask.setNoColumnShrink(myFlywayMigrator.isNoColumnShrink()); myTask.setConnectionProperties(myConnectionProperties); try { executeTask(); } catch (SQLException e) { String description = myTask.getDescription(); if (isBlank(description)) { description = myTask.getClass().getSimpleName(); } String prefix = "Failure executing task \"" + description + "\", aborting! Cause: "; throw new InternalErrorException(prefix + e.toString(), e); } } FlywayMigrationTask(BaseTask theTask, FlywayMigrator theFlywayMigrator); @Override MigrationVersion getVersion(); @Override String getDescription(); @Override Integer getChecksum(); @Override boolean isUndo(); @Override boolean canExecuteInTransaction(); @Override void migrate(Context theContext); void setConnectionProperties(DriverTypeEnum.ConnectionProperties theConnectionProperties);  }### Answer:
@Test public void schemaInitializedStubsFollowingMigration() { when(myFlywayMigrator.isSchemaWasInitialized()).thenReturn(true); FlywayMigrationTask task = new FlywayMigrationTask(myTestTask, myFlywayMigrator); task.migrate(myContext); assertTrue(myTestTask.isDoNothing()); }
@Test public void schemaNotInitializedStubsFollowingMigration() { when(myFlywayMigrator.isSchemaWasInitialized()).thenReturn(false); FlywayMigrationTask task = new FlywayMigrationTask(myTestTask, myFlywayMigrator); task.migrate(myContext); assertFalse(myTestTask.isDoNothing()); }
@Test public void schemaInitializedStubsFollowingMigrationExceptInitSchemaTask() { when(myFlywayMigrator.isSchemaWasInitialized()).thenReturn(true); InitializeSchemaTask initSchemaTask = new TestInitializeSchemaTask(false); FlywayMigrationTask task = new FlywayMigrationTask(initSchemaTask, myFlywayMigrator); task.migrate(myContext); assertFalse(myTestTask.isDoNothing()); }
@Test public void schemaInitializedSetsInitializedFlag() { InitializeSchemaTask initSchemaTask = new TestInitializeSchemaTask(true); FlywayMigrationTask task = new FlywayMigrationTask(initSchemaTask, myFlywayMigrator); task.migrate(myContext); verify(myFlywayMigrator, times(1)).setSchemaWasInitialized(true); }
@Test public void nonInitSchemaInitializedSetsInitializedFlag() { InitializeSchemaTask initSchemaTask = new TestInitializeSchemaTask(false); FlywayMigrationTask task = new FlywayMigrationTask(initSchemaTask, myFlywayMigrator); task.migrate(myContext); verify(myFlywayMigrator, never()).setSchemaWasInitialized(true); }