@Override
  public Health check() {
    Platform.Status platformStatus = platform.status();
    if (platformStatus == Platform.Status.UP
      && VALID_DATABASEMIGRATION_STATUSES.contains(migrationState.getStatus())
      && !restartFlagHolder.isRestarting()) {
      return Health.GREEN;
    }
    return Health.builder()
      .setStatus(Health.Status.RED)
      .addCause("SonarQube webserver is not up")
      .build();
  }
@Test
  public void returns_RED_with_cause_if_platform_status_is_UP_migration_status_is_valid_but_SQ_is_restarting() {
    when(platform.status()).thenReturn(Platform.Status.UP);
    when(migrationState.getStatus()).thenReturn(random.nextBoolean() ? DatabaseMigrationState.Status.NONE : DatabaseMigrationState.Status.SUCCEEDED);
    when(restartFlagHolder.isRestarting()).thenReturn(true);

    Health health = underTest.check();

    verifyRedHealthWithCause(health);
  }