@Override
  public void execute(ComputationStep.Context context) {
    List<ActiveRule> activeRules = new ArrayList<>();
    try (CloseableIterator<ScannerReport.ActiveRule> batchActiveRules = batchReportReader.readActiveRules()) {
      while (batchActiveRules.hasNext()) {
        ScannerReport.ActiveRule scannerReportActiveRule = batchActiveRules.next();
        Optional<Rule> rule = ruleRepository.findByKey(RuleKey.of(scannerReportActiveRule.getRuleRepository(), scannerReportActiveRule.getRuleKey()));
        if (rule.isPresent() && rule.get().getStatus() != RuleStatus.REMOVED && !rule.get().isExternal()) {
          activeRules.add(convert(scannerReportActiveRule, rule.get()));
        }
      }
    }

    activeRulesHolder.set(activeRules);
  }
@Test
  void feed_active_rules() {
    ruleRepository.add(XOO_X1)
      .setPluginKey("xoo");
    ruleRepository.add(XOO_X2)
      .setPluginKey("xoo");

    ScannerReport.ActiveRule.Builder batch1 = ScannerReport.ActiveRule.newBuilder()
      .setRuleRepository(XOO_X1.repository())
      .setRuleKey(XOO_X1.rule())
      .setSeverity(Constants.Severity.BLOCKER)
      .setCreatedAt(1000L)
      .setUpdatedAt(1200L);
    batch1.getMutableParamsByKey().put("p1", "v1");

    ScannerReport.ActiveRule.Builder batch2 = ScannerReport.ActiveRule.newBuilder()
      .setRuleRepository(XOO_X2.repository()).setRuleKey(XOO_X2.rule()).setSeverity(Constants.Severity.MAJOR);
    batchReportReader.putActiveRules(asList(batch1.build(), batch2.build()));

    underTest.execute(new TestComputationStepContext());

    assertThat(activeRulesHolder.getAll()).hasSize(2);

    ActiveRule ar1 = activeRulesHolder.get(XOO_X1).get();
    assertThat(ar1.getSeverity()).isEqualTo(Severity.BLOCKER);
    assertThat(ar1.getParams()).containsExactly(MapEntry.entry("p1", "v1"));
    assertThat(ar1.getPluginKey()).isEqualTo("xoo");
    assertThat(ar1.getUpdatedAt()).isEqualTo(1200L);

    ActiveRule ar2 = activeRulesHolder.get(XOO_X2).get();
    assertThat(ar2.getSeverity()).isEqualTo(Severity.MAJOR);
    assertThat(ar2.getParams()).isEmpty();
    assertThat(ar2.getPluginKey()).isEqualTo("xoo");
    assertThat(ar1.getUpdatedAt()).isEqualTo(1200L);
  }