From d46582652ab35d9e24f6486380aedf10ba98d04a Mon Sep 17 00:00:00 2001 From: OrlovAlexander Date: Thu, 17 Oct 2024 12:13:24 +0200 Subject: [PATCH] SONAR-23259 Update QualityProfileChangesUpdater --- .../registration/QualityProfileChangesUpdater.java | 11 ----------- .../QualityProfileChangesUpdaterTest.java | 11 ++++------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/QualityProfileChangesUpdater.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/QualityProfileChangesUpdater.java index d9b74a99222..8f55e1962a8 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/QualityProfileChangesUpdater.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/registration/QualityProfileChangesUpdater.java @@ -88,17 +88,6 @@ public class QualityProfileChangesUpdater { private static Set createRuleImpactChanges(PluginRuleUpdate pluginRuleUpdate, RuleChangeDto ruleChangeDto) { Set 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 removedIterator = (Sets.difference(pluginRuleUpdate.getOldImpacts().keySet(), pluginRuleUpdate.getMatchingSoftwareQualities())).iterator(); Iterator addedIterator = (Sets.difference(pluginRuleUpdate.getNewImpacts().keySet(), pluginRuleUpdate.getMatchingSoftwareQualities())).iterator(); while (removedIterator.hasNext() || addedIterator.hasNext()) { diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/registration/QualityProfileChangesUpdaterTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/registration/QualityProfileChangesUpdaterTest.java index 6b2680733df..91cf442389e 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/registration/QualityProfileChangesUpdaterTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/registration/QualityProfileChangesUpdaterTest.java @@ -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); -- 2.39.5