]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-23259 Update QualityProfileChangesUpdater
authorOrlovAlexander <alexander.orlov@sonarsource.com>
Thu, 17 Oct 2024 10:13:24 +0000 (12:13 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 18 Oct 2024 20:03:11 +0000 (20:03 +0000)
server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/QualityProfileChangesUpdater.java
server/sonar-webserver-core/src/test/java/org/sonar/server/rule/registration/QualityProfileChangesUpdaterTest.java

index d9b74a99222a7421598ba0646667130d5b1cfd79..8f55e1962a8a8c751001b1aad9af463db3fedd49 100644 (file)
@@ -88,17 +88,6 @@ public class QualityProfileChangesUpdater {
   private static Set<RuleImpactChangeDto> createRuleImpactChanges(PluginRuleUpdate pluginRuleUpdate, RuleChangeDto ruleChangeDto) {
     Set<RuleImpactChangeDto> ruleImpactChangeDtos = new HashSet<>();
 
-    pluginRuleUpdate.getMatchingSoftwareQualities().stream()
-      .map(softwareQuality -> {
-        RuleImpactChangeDto ruleImpactChangeDto = new RuleImpactChangeDto();
-        ruleImpactChangeDto.setRuleChangeUuid(ruleChangeDto.getUuid());
-        ruleImpactChangeDto.setOldSeverity(pluginRuleUpdate.getOldImpacts().get(softwareQuality));
-        ruleImpactChangeDto.setOldSoftwareQuality(softwareQuality);
-        ruleImpactChangeDto.setNewSeverity(pluginRuleUpdate.getNewImpacts().get(softwareQuality));
-        ruleImpactChangeDto.setNewSoftwareQuality(softwareQuality);
-        return ruleImpactChangeDto;
-      }).forEach(ruleImpactChangeDtos::add);
-
     Iterator<SoftwareQuality> removedIterator = (Sets.difference(pluginRuleUpdate.getOldImpacts().keySet(), pluginRuleUpdate.getMatchingSoftwareQualities())).iterator();
     Iterator<SoftwareQuality> addedIterator = (Sets.difference(pluginRuleUpdate.getNewImpacts().keySet(), pluginRuleUpdate.getMatchingSoftwareQualities())).iterator();
     while (removedIterator.hasNext() || addedIterator.hasNext()) {
index 6b2680733df2811228c136eba05c1ffb11d70dbf..91cf442389e7d3e24f031219abbbed86cc89c1b5 100644 (file)
@@ -21,8 +21,8 @@ package org.sonar.server.rule.registration;
 
 import java.util.List;
 import java.util.Set;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 import org.sonar.api.issue.impact.Severity;
 import org.sonar.api.issue.impact.SoftwareQuality;
@@ -62,7 +62,7 @@ public class QualityProfileChangesUpdaterTest {
 
   private final QualityProfileChangesUpdater underTest = new QualityProfileChangesUpdater(dbClient, UuidFactoryImpl.INSTANCE, sonarQubeVersion);
 
-  @Before
+  @BeforeEach
   public void before() {
     when(dbClient.ruleChangeDao()).thenReturn(ruleChangeDao);
     when(dbClient.qProfileChangeDao()).thenReturn(qualityProfileChangeDao);
@@ -123,10 +123,7 @@ public class QualityProfileChangesUpdaterTest {
     assertThat(firstChange.getNewCleanCodeAttribute()).isEqualTo(CleanCodeAttribute.CLEAR);
     assertThat(firstChange.getOldCleanCodeAttribute()).isEqualTo(CleanCodeAttribute.TESTED);
     assertThat(firstChange.getRuleUuid()).isEqualTo(RULE_UUID);
-    assertThat(firstChange.getRuleImpactChanges()).hasSize(1);
-    assertThat(firstChange.getRuleImpactChanges()).extracting(RuleImpactChangeDto::getNewSoftwareQuality,
-        RuleImpactChangeDto::getOldSoftwareQuality, RuleImpactChangeDto::getOldSeverity, RuleImpactChangeDto::getNewSeverity)
-      .containsExactly(tuple(SoftwareQuality.RELIABILITY, SoftwareQuality.RELIABILITY, Severity.MEDIUM, Severity.LOW));
+    assertThat(firstChange.getRuleImpactChanges()).isEmpty();
 
     assertThat(secondChange.getNewCleanCodeAttribute()).isEqualTo(CleanCodeAttribute.EFFICIENT);
     assertThat(secondChange.getOldCleanCodeAttribute()).isEqualTo(CleanCodeAttribute.DISTINCT);