public void createQprofileChangesForRuleUpdates(DbSession dbSession, Set<PluginRuleUpdate> pluginRuleUpdates) {
    List<QProfileChangeDto> changesToPersist = pluginRuleUpdates.stream()
      .flatMap(pluginRuleUpdate -> {
        RuleChangeDto ruleChangeDto = createNewRuleChange(pluginRuleUpdate);
        insertRuleChange(dbSession, ruleChangeDto);

        return findQualityProfilesForRule(dbSession, pluginRuleUpdate.getRuleUuid()).stream()
          .map(qualityProfileUuid -> buildQprofileChangeDtoForRuleChange(qualityProfileUuid, ruleChangeDto));
      }).toList();

    if (!changesToPersist.isEmpty()) {
      dbClient.qProfileChangeDao().bulkInsert(dbSession, changesToPersist);
    }
  }
@Test
  public void updateWithoutCommit_whenOneRuleBelongingToTwoQualityProfilesChanged_thenInsertOneRuleChangeAndTwoQualityProfileChanges() {
    List<ActiveRuleDto> activeRuleDtos = List.of(
      new ActiveRuleDto().setProfileUuid("profileUuid1").setRuleUuid(RULE_UUID),
      new ActiveRuleDto().setProfileUuid("profileUuid2").setRuleUuid(RULE_UUID));
    when(activeRuleDao.selectByRuleUuid(any(), any())).thenReturn(activeRuleDtos);

    PluginRuleUpdate pluginRuleUpdate = new PluginRuleUpdate();
    pluginRuleUpdate.setNewCleanCodeAttribute(CleanCodeAttribute.CLEAR);
    pluginRuleUpdate.setOldCleanCodeAttribute(CleanCodeAttribute.TESTED);
    pluginRuleUpdate.setRuleUuid(RULE_UUID);

    underTest.createQprofileChangesForRuleUpdates(dbSession, Set.of(pluginRuleUpdate));

    verify(qualityProfileChangeDao, times(1)).bulkInsert(argThat(dbSession::equals),
      argThat(qProfileChangeDtos ->
        qProfileChangeDtos.stream()
          .allMatch(dto -> "UPDATED".equals(dto.getChangeType()) && dto.getRuleChange() != null)));
  }