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()) {
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;
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);
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);