@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_status_with_cause_if_platform_status_is_UP_but_migrationStatus_is_neither_NONE_nor_SUCCEED() {
    when(platform.status()).thenReturn(Platform.Status.UP);
    DatabaseMigrationState.Status[] statusesButValidOnes = Arrays.stream(DatabaseMigrationState.Status.values())
      .filter(s -> s != DatabaseMigrationState.Status.NONE)
      .filter(s -> s != DatabaseMigrationState.Status.SUCCEEDED)
      .toArray(DatabaseMigrationState.Status[]::new);
    DatabaseMigrationState.Status randomInvalidStatus = statusesButValidOnes[random.nextInt(statusesButValidOnes.length)];
    when(migrationState.getStatus()).thenReturn(randomInvalidStatus);

    Health health = underTest.check();

    verifyRedHealthWithCause(health);
  }