From 9560b3c9b5b2b62a9077d7f55d65c42d52b13482 Mon Sep 17 00:00:00 2001 From: lukasz-jarocki-sonarsource Date: Thu, 2 Nov 2023 11:09:30 +0100 Subject: [PATCH] SONAR-20931 storing all information in change_data column in qprofile_changes. This reverts most of the commit 762c9190c6a9955cc94957f0c76ffd607c1f0b33 --- .../org/sonar/server/qualityprofile/ActiveRuleChange.java | 4 ++++ .../org/sonar/server/qualityprofile/QProfileRulesImplIT.java | 2 +- .../qualityprofile/builtin/BuiltInQProfileInsertImplIT.java | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/qualityprofile/ActiveRuleChange.java b/server/sonar-server-common/src/main/java/org/sonar/server/qualityprofile/ActiveRuleChange.java index e8c652032e6..eb42a7e41f5 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/qualityprofile/ActiveRuleChange.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/qualityprofile/ActiveRuleChange.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.Map; import javax.annotation.CheckForNull; import javax.annotation.Nullable; +import org.apache.commons.lang.StringUtils; import org.sonar.db.qualityprofile.ActiveRuleDto; import org.sonar.db.qualityprofile.ActiveRuleKey; import org.sonar.db.qualityprofile.QProfileChangeDto; @@ -130,6 +131,9 @@ public class ActiveRuleChange { .filter(param -> !param.getKey().isEmpty()) .forEach(param -> data.put("param_" + param.getKey(), param.getValue())); + if (StringUtils.isNotEmpty(severity)) { + data.put("severity", severity); + } dto.setData(data); return dto; } diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileRulesImplIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileRulesImplIT.java index 92811121a25..ab2d8dc4c2a 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileRulesImplIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileRulesImplIT.java @@ -97,7 +97,7 @@ public class QProfileRulesImplIT { assertThat(db.getDbClient().qProfileChangeDao().selectByQuery(db.getSession(), new QProfileChangeQuery(qProfile.getKee()))) .extracting(QProfileChangeDto::getUserUuid, QProfileChangeDto::getDataAsMap) - .containsExactlyInAnyOrder(tuple(user.getUuid(), ImmutableMap.of("ruleUuid", rule.getUuid()))); + .containsExactlyInAnyOrder(tuple(user.getUuid(), ImmutableMap.of("ruleUuid", rule.getUuid(), "severity", Severity.CRITICAL))); verify(qualityProfileChangeEventService).distributeRuleChangeEvent(any(), any(), eq(qProfile.getLanguage())); } } diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileInsertImplIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileInsertImplIT.java index 4a38bbf2234..6c3333ee39f 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileInsertImplIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileInsertImplIT.java @@ -221,6 +221,7 @@ public class BuiltInQProfileInsertImplIT { assertThat(change.getUuid()).isNotEmpty(); assertThat(change.getUserUuid()).isNull(); assertThat(change.getRulesProfileUuid()).isEqualTo(profile.getRulesProfileUuid()); + assertThat(change.getDataAsMap()).containsEntry("severity", expectedSeverity); assertThat(change.getSqVersion()).isEqualTo(sonarQubeVersion.toString()); } -- 2.39.5