issue.getImpacts()
.stream()
.filter(i -> convertToSoftwareQuality(issue.type()).equals(i.softwareQuality()))
- .forEach(i -> issue.addImpact(i.softwareQuality(), ImpactSeverityMapper.mapImpactSeverity(issue.severity()), true));
+ .forEach(i -> {
+ Severity newSeverity = ImpactSeverityMapper.mapImpactSeverity(issue.severity());
+ issue.addImpact(i.softwareQuality(), newSeverity, true);
+ issue.setFieldChange(context, IMPACT_SEVERITY,
+ i.softwareQuality() + ":" + i.severity(),
+ i.softwareQuality() + ":" + newSeverity);
+ });
}
if (!previousImpacts.equals(issue.getImpacts())) {
import java.util.Random;
import java.util.Set;
import org.apache.commons.lang3.time.DateUtils;
+import org.assertj.core.groups.Tuple;
import org.junit.jupiter.api.Test;
import org.sonar.api.issue.Issue;
import org.sonar.api.issue.IssueStatus;
boolean updated = underTest.setImpacts(issue, currentImpacts, context);
assertThat(updated).isTrue();
assertThat(issue.getImpacts()).isEqualTo(newImpacts);
+ assertThat(issue.changes()).isEmpty();
}
@Test
assertThat(updated).isTrue();
assertThat(issue.getImpacts()).isEqualTo(Set.of(new DefaultImpact(SoftwareQuality.MAINTAINABILITY, Severity.HIGH, true),
new DefaultImpact(SoftwareQuality.RELIABILITY, Severity.HIGH, false)));
+ assertThat(issue.changes()).isEmpty();
}
@Test
boolean updated = underTest.setImpacts(issue, currentImpacts, context);
assertThat(updated).isTrue();
assertThat(issue.getImpacts()).isEqualTo(Set.of(new DefaultImpact(SoftwareQuality.MAINTAINABILITY, Severity.BLOCKER, true)));
+ assertThat(issue.changes()).hasSize(1).extracting(f -> f.diffs().get("impactSeverity").oldValue(), f -> f.diffs().get("impactSeverity").newValue())
+ .containsExactly(Tuple.tuple("MAINTAINABILITY:LOW", "MAINTAINABILITY:BLOCKER"));
}
@Test
issue.setType(RuleType.BUG);
boolean updated = underTest.setImpacts(issue, currentImpacts, context);
assertThat(updated).isFalse();
+ assertThat(issue.changes()).isEmpty();
}
@Test
issue.setType(RuleType.BUG);
boolean updated = underTest.setImpacts(issue, currentImpacts, context);
assertThat(updated).isFalse();
+ assertThat(issue.changes()).isEmpty();
}
@Test