@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 whenExecute_TelemetryDataIsProperlyAdded() {
    migrationContainer.add(MigrationStep2.class, MigrationStep1.class, MigrationStep3.class);
    when(databaseMigrationState.getCompletedMigrations()).thenReturn(3);

    List<RegisteredMigrationStep> steps = asList(
      registeredStepOf(1, MigrationStep2.class),
      registeredStepOf(2, MigrationStep1.class),
      registeredStepOf(3, MigrationStep3.class));

    ((SpringComponentContainer) migrationContainer).startComponents();

    underTest.execute(steps, migrationStatusListener);

    assertThat(telemetryDbMigrationTotalTimeProvider.getValue().get()).isPositive();
    assertThat(telemetryDbMigrationStepsProvider.getValue()).hasValue(3);
    assertThat(telemetryDbMigrationSuccessProvider.getValue()).hasValue(true);

  }