@Override
  public void run() {
    try (DbSession dbSession = dbClient.openSession(false)) {
      List<AlmSettingDto> bitbucketServerDtos = dbClient.almSettingDao().selectByAlm(dbSession, ALM.BITBUCKET);
      List<AlmSettingDto> bitbucketCloudDtos = dbClient.almSettingDao().selectByAlm(dbSession, ALM.BITBUCKET_CLOUD);

      if (bitbucketServerDtos.isEmpty() && bitbucketCloudDtos.isEmpty()) {
        metrics.setBitbucketStatusToRed();
        return;
      }

      try {
        validate(bitbucketServerDtos, bitbucketCloudDtos);
        metrics.setBitbucketStatusToGreen();
      } catch (RuntimeException e) {
        metrics.setBitbucketStatusToRed();
      }

    }
  }
@Test
  public void run_bitbucketIntegrationNotConfigured_setRedStatusInMetricsOnce() {
    when(almSettingsDao.selectByAlm(dbSession, ALM.BITBUCKET)).thenReturn(Collections.emptyList());
    when(almSettingsDao.selectByAlm(dbSession, ALM.BITBUCKET_CLOUD)).thenReturn(Collections.emptyList());

    underTest.run();

    verify(metrics, times(0)).setBitbucketStatusToGreen();
    verify(metrics, times(1)).setBitbucketStatusToRed();
  }