@Override
  public void start() {
    boolean hasExternalPlugins = pluginRepository.getPlugins().stream().anyMatch(plugin -> plugin.getType().equals(PluginType.EXTERNAL));
    try (DbSession session = dbClient.openSession(false)) {
      PropertyDto property = Optional.ofNullable(dbClient.propertiesDao().selectGlobalProperty(session, PLUGINS_RISK_CONSENT))
        .orElse(defaultPluginRiskConsentProperty());
      if (hasExternalPlugins && NOT_ACCEPTED == PluginRiskConsent.valueOf(property.getValue())) {
        addWarningInSonarDotLog();
        property.setValue(REQUIRED.name());
        dbClient.propertiesDao().saveProperty(session, property);
        session.commit();
      } else if (!hasExternalPlugins && REQUIRED == PluginRiskConsent.valueOf(property.getValue())) {
        dbClient.propertiesDao().deleteGlobalProperty(PLUGINS_RISK_CONSENT, session);
        session.commit();
      }
    }
  }
@Test
  public void consent_does_not_change_when_value_is_accepted() {
    setupExternalPluginConsent(ACCEPTED);
    setupExternalPlugin();

    underTest.start();

    assertThat(dbClient.propertiesDao().selectGlobalProperty(PLUGINS_RISK_CONSENT))
      .extracting(PropertyDto::getValue)
      .isEqualTo(ACCEPTED.name());
  }