@Override
  public void execute(List<RegisteredMigrationStep> steps, MigrationStatusListener listener) {
    Profiler globalProfiler = Profiler.create(LOGGER);
    globalProfiler.startInfo(GLOBAL_START_MESSAGE, databaseMigrationState.getTotalMigrations());
    boolean allStepsExecuted = false;
    try {
      for (RegisteredMigrationStep step : steps) {
        this.execute(step);
        listener.onMigrationStepCompleted();
      }
      allStepsExecuted = true;
    } finally {
      long dbMigrationDuration = 0L;
      if (allStepsExecuted) {
        dbMigrationDuration = globalProfiler.stopInfo(GLOBAL_END_MESSAGE,
          databaseMigrationState.getCompletedMigrations(),
          databaseMigrationState.getTotalMigrations(),
          "success");
      } else {
        dbMigrationDuration = globalProfiler.stopError(GLOBAL_END_MESSAGE,
          databaseMigrationState.getCompletedMigrations(),
          databaseMigrationState.getTotalMigrations(),
          "failure");
      }
      telemetryDbMigrationTotalTimeProvider.setDbMigrationTotalTime(dbMigrationDuration);
      telemetryDbMigrationStepsProvider.setDbMigrationCompletedSteps(databaseMigrationState.getCompletedMigrations());
      telemetryDbMigrationSuccessProvider.setDbMigrationSuccess(allStepsExecuted);
    }
  }
@Test
  void execute_execute_the_instance_of_type_specified_in_step_in_stream_order() {
    migrationContainer.add(MigrationStep1.class, MigrationStep2.class, MigrationStep3.class);
    ((SpringComponentContainer) migrationContainer).startComponents();

    underTest.execute(asList(
      registeredStepOf(1, MigrationStep2.class),
      registeredStepOf(2, MigrationStep1.class),
      registeredStepOf(3, MigrationStep3.class)),
      migrationStatusListener);

    assertThat(SingleCallCheckerMigrationStep.calledSteps)
      .containsExactly(MigrationStep2.class, MigrationStep1.class, MigrationStep3.class);
    assertThat(logTester.logs()).hasSize(8);
    assertLogLevel(Level.INFO,
      "Executing 5 DB migrations...",
      "3/5 #1 '1-MigrationStep2'...",
      "3/5 #1 '1-MigrationStep2': success | time=",
      "3/5 #2 '2-MigrationStep1'...",
      "3/5 #2 '2-MigrationStep1': success | time=",
      "3/5 #3 '3-MigrationStep3'...",
      "3/5 #3 '3-MigrationStep3': success | time=",
      "Executed 2/5 DB migrations: success | time=");

    assertThat(migrationContainer.getComponentByType(MigrationStep1.class).isCalled()).isTrue();
    assertThat(migrationContainer.getComponentByType(MigrationStep2.class).isCalled()).isTrue();
    assertThat(migrationContainer.getComponentByType(MigrationStep3.class).isCalled()).isTrue();
    verify(migrationStatusListener, times(3)).onMigrationStepCompleted();

  }