]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-22912 Backup and restore prioritizedRule flag in Quality Profiles
authorDejan Milisavljevic <130993898+dejan-milisavljevic-sonarsource@users.noreply.github.com>
Mon, 16 Sep 2024 08:15:16 +0000 (10:15 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 16 Sep 2024 20:02:47 +0000 (20:02 +0000)
server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ExportRuleDto.java
server/sonar-db-dao/src/main/resources/org/sonar/db/qualityprofile/QualityProfileExportMapper.xml
server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/QProfileBackuperImplIT.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ImportedRule.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileBackuperImpl.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/QProfileParser.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileParserTest.java

index 843e08f9c33ea6492a75e32b0a005b64651ac789..c6a44bc5e3c4c516e8b3b63064ca8d17d9749950 100644 (file)
@@ -24,6 +24,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Objects;
 import java.util.Set;
+import javax.annotation.CheckForNull;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rules.RuleType;
 import org.sonar.db.rule.SeverityUtil;
@@ -38,6 +39,7 @@ public class ExportRuleDto {
   private String template = null;
   private Integer severity = null;
   private Integer type = null;
+  private Boolean prioritizedRule;
   private Set<String> tags = new HashSet<>();
 
   private List<ExportRuleParamDto> params = null;
@@ -70,6 +72,11 @@ public class ExportRuleDto {
     return RuleType.valueOf(type);
   }
 
+  @CheckForNull
+  public Boolean getPrioritizedRule() {
+    return prioritizedRule;
+  }
+
   public Set<String> getTags() {
     return tags;
   }
index 48ee62fbcef8749449a7fe5afeace0c111b67b2d..503f81160e247e7a7ec1d7ed5bfd1084cb63df05 100644 (file)
@@ -19,6 +19,7 @@
     <include refid="selectRuleDescriptionSectionColumns"/>
     a.uuid as "activeRuleUuid",
     a.failure_level as "severity",
+    a.prioritized_rule as "prioritizedRule",
     r.plugin_rule_key as "rule",
     r.plugin_name as "repository",
     r.priority as "defaultSeverity",
@@ -41,6 +42,7 @@
     <id property="activeRuleUuid" column="activeRuleUuid"/>
     <result property="ruleKey" column="ruleKey"/>
     <result property="severity" column="severity"/>
+    <result property="prioritizedRule" column="prioritizedRule"/>
     <result property="rule" column="rule"/>
     <result property="repository" column="repository"/>
     <result property="name" column="name"/>
index bc094c92cd2b2dc70c261a89bcaaeba1388cff6b..f156feab153e5d016df1dd6dbff9600962fb6a57 100644 (file)
@@ -27,9 +27,14 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.function.Consumer;
+import java.util.stream.Stream;
 import javax.annotation.Nullable;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.sonar.api.impl.utils.AlwaysIncreasingSystem2;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
@@ -59,7 +64,7 @@ import static org.sonar.db.rule.RuleDescriptionSectionDto.createDefaultRuleDescr
 import static org.sonar.db.rule.RuleTesting.newRule;
 import static org.sonar.db.rule.RuleTesting.newRuleWithoutDescriptionSection;
 
-public class QProfileBackuperImplIT {
+class QProfileBackuperImplIT {
 
   private static final String EMPTY_BACKUP = "<?xml version='1.0' encoding='UTF-8'?>" +
     "<profile><name>foo</name>" +
@@ -69,8 +74,8 @@ public class QProfileBackuperImplIT {
 
   private final System2 system2 = new AlwaysIncreasingSystem2();
 
-  @Rule
-  public DbTester db = DbTester.create(system2);
+  @RegisterExtension
+  private final DbTester db = DbTester.create(system2);
 
   private final DummyReset reset = new DummyReset();
   private final QProfileFactory profileFactory = new DummyProfileFactory();
@@ -79,10 +84,10 @@ public class QProfileBackuperImplIT {
   private final QProfileBackuper underTest = new QProfileBackuperImpl(db.getDbClient(), reset, profileFactory, ruleCreator, new QProfileParser());
 
   @Test
-  public void backup_generates_xml_file() {
+  void backup_generates_xml_file() {
     RuleDto rule = createRule();
     QProfileDto profile = createProfile(rule.getLanguage());
-    ActiveRuleDto activeRule = activate(profile, rule);
+    ActiveRuleDto activeRule = activate(profile, rule, ar -> ar.setPrioritizedRule(false));
 
     StringWriter writer = new StringWriter();
     underTest.backup(db.getSession(), profile, writer);
@@ -103,7 +108,32 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void backup_rules_having_parameters() {
+  void backup_prioritized_rule() {
+    RuleDto rule = createRule();
+    QProfileDto profile = createProfile(rule.getLanguage());
+    ActiveRuleDto activeRule = activate(profile, rule, ar -> ar.setPrioritizedRule(true));
+
+    StringWriter writer = new StringWriter();
+    underTest.backup(db.getSession(), profile, writer);
+
+    assertThat(writer).hasToString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+      "<profile><name>" + profile.getName() + "</name>" +
+      "<language>" + profile.getLanguage() + "</language>" +
+      "<rules>" +
+      "<rule>" +
+      "<repositoryKey>" + rule.getRepositoryKey() + "</repositoryKey>" +
+      "<key>" + rule.getRuleKey() + "</key>" +
+      "<type>" + RuleType.valueOf(rule.getType()).name() + "</type>" +
+      "<priority>" + activeRule.getSeverityString() + "</priority>" +
+      "<prioritizedRule>true</prioritizedRule>" +
+      "<parameters></parameters>" +
+      "</rule>" +
+      "</rules>" +
+      "</profile>");
+  }
+
+  @Test
+  void backup_rules_having_parameters() {
     RuleDto rule = createRule();
     RuleParamDto param = db.rules().insertRuleParam(rule);
     QProfileDto profile = createProfile(rule.getLanguage());
@@ -126,7 +156,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void backup_empty_profile() {
+  void backup_empty_profile() {
     RuleDto rule = createRule();
     QProfileDto profile = createProfile(rule.getLanguage());
 
@@ -141,7 +171,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void backup_custom_rules_with_params() {
+  void backup_custom_rules_with_params() {
     RuleDto templateRule = db.rules().insert(ruleDefinitionDto -> ruleDefinitionDto
       .setIsTemplate(true));
     RuleDto rule = db.rules().insert(
@@ -176,7 +206,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void backup_custom_rules_without_description_section() {
+  void backup_custom_rules_without_description_section() {
     var rule = newRuleWithoutDescriptionSection();
     db.rules().insert(rule);
     RuleParamDto param = db.rules().insertRuleParam(rule);
@@ -203,7 +233,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void restore_backup_on_the_profile_specified_in_backup() {
+  void restore_backup_on_the_profile_specified_in_backup() {
     Reader backup = new StringReader(EMPTY_BACKUP);
 
     QProfileRestoreSummary summary = underTest.restore(db.getSession(), backup, (String) null);
@@ -216,7 +246,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void restore_detects_deprecated_rule_keys() {
+  void restore_detects_deprecated_rule_keys() {
     String ruleUuid = db.rules().insert(RuleKey.of("sonarjs", "s001")).getUuid();
     db.rules().insertDeprecatedKey(c -> c.setRuleUuid(ruleUuid).setOldRuleKey("oldkey").setOldRepositoryKey("oldrepo"));
 
@@ -245,7 +275,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void restore_ignores_deprecated_rule_keys_if_new_key_is_already_present() {
+  void restore_ignores_deprecated_rule_keys_if_new_key_is_already_present() {
     String ruleUuid = db.rules().insert(RuleKey.of("sonarjs", "s001")).getUuid();
     db.rules().insertDeprecatedKey(c -> c.setRuleUuid(ruleUuid).setOldRuleKey("oldkey").setOldRepositoryKey("oldrepo"));
 
@@ -282,7 +312,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void restore_backup_on_profile_having_different_name() {
+  void restore_backup_on_profile_having_different_name() {
     Reader backup = new StringReader(EMPTY_BACKUP);
 
     QProfileRestoreSummary summary = underTest.restore(db.getSession(), backup, "bar");
@@ -295,7 +325,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void restore_resets_the_activated_rules() {
+  void restore_resets_the_activated_rules() {
     String ruleUuid = db.rules().insert(RuleKey.of("sonarjs", "s001")).getUuid();
     Reader backup = new StringReader("<?xml version='1.0' encoding='UTF-8'?>" +
       "<profile><name>foo</name>" +
@@ -305,6 +335,7 @@ public class QProfileBackuperImplIT {
       "<repositoryKey>sonarjs</repositoryKey>" +
       "<key>s001</key>" +
       "<priority>BLOCKER</priority>" +
+      "<prioritizedRule>true</prioritizedRule>" +
       "<parameters>" +
       "<parameter><key>bar</key><value>baz</value></parameter>" +
       "</parameters>" +
@@ -317,12 +348,55 @@ public class QProfileBackuperImplIT {
     assertThat(reset.calledActivations).hasSize(1);
     RuleActivation activation = reset.calledActivations.get(0);
     assertThat(activation.getSeverity()).isEqualTo("BLOCKER");
+    assertThat(activation.isPrioritizedRule()).isTrue();
     assertThat(activation.getRuleUuid()).isEqualTo(ruleUuid);
     assertThat(activation.getParameter("bar")).isEqualTo("baz");
   }
 
+  @ParameterizedTest
+  @MethodSource("prioritizedRules")
+  void restore_sets_correctly_the_prioritizedRule_flag(boolean prioritizedInProfile, Boolean prioritizedInBackup, boolean expected) {
+    RuleDto rule = createRule();
+    QProfileDto profile = createProfile(rule.getLanguage());
+    ActiveRuleDto activeRule = activate(profile, rule, ar -> ar.setPrioritizedRule(prioritizedInProfile));
+
+    Reader backup = new StringReader("<?xml version='1.0' encoding='UTF-8'?>" +
+      "<profile><name>" + profile.getName() + "</name>" +
+      "<language>" + profile.getLanguage() + "</language>" +
+      "<rules>" +
+      "<rule>" +
+      "<repositoryKey>" + rule.getRepositoryKey() + "</repositoryKey>" +
+      "<key>" + rule.getRuleKey() + "</key>" +
+      "<type>" + RuleType.valueOf(rule.getType()).name() + "</type>" +
+      "<priority>" + activeRule.getSeverityString() + "</priority>" +
+      (prioritizedInBackup == null ? "" : "<prioritizedRule>" + prioritizedInBackup + "</prioritizedRule>") +
+      "</rule>" +
+      "</rules>" +
+      "</profile>");
+
+    underTest.restore(db.getSession(), backup, (String) null);
+
+    assertThat(reset.calledActivations).hasSize(1);
+    RuleActivation activation = reset.calledActivations.get(0);
+    assertThat(activation.getSeverity()).isEqualTo(activeRule.getSeverityString());
+    assertThat(activation.isPrioritizedRule()).isEqualTo(expected);
+    assertThat(activation.getRuleUuid()).isEqualTo(rule.getUuid());
+  }
+
+  private static Stream<Arguments> prioritizedRules() {
+    return Stream.of(
+      Arguments.of(true, false, false),
+      Arguments.of(true, null, false),
+      Arguments.of(true, true, true),
+      Arguments.of(false, false, false),
+      Arguments.of(false, null, false),
+      Arguments.of(false, true, true)
+    );
+  }
+
+
   @Test
-  public void restore_custom_rule() {
+  void restore_custom_rule() {
     when(ruleCreator.create(any(), anyList())).then(invocation -> Collections.singletonList(db.rules().insert(RuleKey.of("sonarjs", "s001"))));
 
     Reader backup = new StringReader("<?xml version='1.0' encoding='UTF-8'?>" +
@@ -353,7 +427,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void restore_skips_rule_without_template_key_and_db_definition() {
+  void restore_skips_rule_without_template_key_and_db_definition() {
     String ruleUuid = db.rules().insert(RuleKey.of("sonarjs", "s001")).getUuid();
     Reader backup = new StringReader("<?xml version='1.0' encoding='UTF-8'?>" +
       "<profile><name>foo</name>" +
@@ -385,7 +459,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void copy_profile() {
+  void copy_profile() {
     RuleDto rule = createRule();
     RuleParamDto param = db.rules().insertRuleParam(rule);
     QProfileDto from = createProfile(rule.getLanguage());
@@ -400,7 +474,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void copy_profile_with_custom_rule() {
+  void copy_profile_with_custom_rule() {
     RuleDto templateRule = db.rules().insert(ruleDefinitionDto -> ruleDefinitionDto
       .setIsTemplate(true));
     RuleDto rule = db.rules().insert(
@@ -422,7 +496,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void fail_to_restore_if_bad_xml_format() {
+  void fail_to_restore_if_bad_xml_format() {
     DbSession session = db.getSession();
     StringReader backup = new StringReader("<rules><rule></rules>");
     IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> underTest.restore(session, backup, (String) null));
@@ -431,7 +505,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void fail_to_restore_if_not_xml_backup() {
+  void fail_to_restore_if_not_xml_backup() {
     DbSession session = db.getSession();
     StringReader backup = new StringReader("foo");
     assertThrows(IllegalArgumentException.class, () -> underTest.restore(session, backup, (String) null));
@@ -439,7 +513,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void fail_to_restore_if_xml_is_not_well_formed() {
+  void fail_to_restore_if_xml_is_not_well_formed() {
     assertThatThrownBy(() -> {
       String notWellFormedXml = "<?xml version='1.0' encoding='UTF-8'?><profile><name>\"profil\"</name><language>\"language\"</language><rules/></profile";
 
@@ -450,7 +524,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void fail_to_restore_if_duplicate_rule() throws Exception {
+  void fail_to_restore_if_duplicate_rule() throws Exception {
     DbSession session = db.getSession();
     String xml = Resources.toString(getClass().getResource("QProfileBackuperIT/duplicates-xml-backup.xml"), UTF_8);
     StringReader backup = new StringReader(xml);
@@ -460,7 +534,7 @@ public class QProfileBackuperImplIT {
   }
 
   @Test
-  public void fail_to_restore_external_rule() {
+  void fail_to_restore_external_rule() {
     db.rules().insert(RuleKey.of("sonarjs", "s001"), r -> r.setIsExternal(true));
     Reader backup = new StringReader("<?xml version='1.0' encoding='UTF-8'?>" +
       "<profile><name>foo</name>" +
@@ -496,8 +570,12 @@ public class QProfileBackuperImplIT {
     return db.qualityProfiles().activateRule(profile, rule);
   }
 
+  private ActiveRuleDto activate(QProfileDto profile, RuleDto rule, Consumer<ActiveRuleDto> consumer) {
+    return db.qualityProfiles().activateRule(profile, rule, consumer);
+  }
+
   private ActiveRuleDto activate(QProfileDto profile, RuleDto rule, RuleParamDto param) {
-    ActiveRuleDto activeRule = db.qualityProfiles().activateRule(profile, rule);
+    ActiveRuleDto activeRule = db.qualityProfiles().activateRule(profile, rule, ar -> ar.setPrioritizedRule(false));
     ActiveRuleParamDto dto = ActiveRuleParamDto.createFor(param)
       .setValue("20")
       .setActiveRuleUuid(activeRule.getUuid());
index e95394078c61b69ed28452d47256c97fac7f6eaa..410fe724eaf747a8297a4db45480784092e487ba 100644 (file)
@@ -32,6 +32,7 @@ class ImportedRule {
   private String name = null;
   private String type = null;
   private String severity = null;
+  private Boolean prioritizedRule = false;
   private String description = null;
   private Map<String, String> parameters = null;
   public Map<String, String> getParameters() {
@@ -58,6 +59,10 @@ class ImportedRule {
     return severity;
   }
 
+  public Boolean getPrioritizedRule() {
+    return prioritizedRule;
+  }
+
   public String getDescription() {
     return description;
   }
@@ -72,6 +77,11 @@ class ImportedRule {
     return this;
   }
 
+  public ImportedRule setPrioritizedRule(Boolean prioritizedRule) {
+    this.prioritizedRule = prioritizedRule;
+    return this;
+  }
+
   ImportedRule setDescription(String description) {
     this.description = description;
     return this;
index 74e58d995a3ce0aa021dddcf7eb0b3ad16b0271e..4c709b0a28512754e5155c82fdd7077c577da6a9 100644 (file)
@@ -228,7 +228,7 @@ public class QProfileBackuperImpl implements QProfileBackuper {
       if (ruleDto == null) {
         continue;
       }
-      activatedRule.add(RuleActivation.create(ruleDto.getUuid(), r.getSeverity(), r.getParameters()));
+      activatedRule.add(RuleActivation.create(ruleDto.getUuid(), r.getSeverity(), r.getPrioritizedRule(), r.getParameters()));
     }
     return activatedRule;
   }
index 013a29905011072cf65717aa72fb43c17e278cf0..f0c1d16411afe5b4d6caaed9a8eb4a9a0dc944d8 100644 (file)
@@ -53,6 +53,7 @@ public class QProfileParser {
   private static final String ATTRIBUTE_REPOSITORY_KEY = "repositoryKey";
   private static final String ATTRIBUTE_KEY = "key";
   private static final String ATTRIBUTE_PRIORITY = "priority";
+  private static final String ATTRIBUTE_PRIORITIZED_RULE = "prioritizedRule";
   private static final String ATTRIBUTE_TEMPLATE_KEY = "templateKey";
   private static final String ATTRIBUTE_TYPE = "type";
   private static final String ATTRIBUTE_DESCRIPTION = "description";
@@ -75,6 +76,9 @@ public class QProfileParser {
       xml.prop(ATTRIBUTE_KEY, ruleToExport.getRuleKey().rule());
       xml.prop(ATTRIBUTE_TYPE, ruleToExport.getRuleType().name());
       xml.prop(ATTRIBUTE_PRIORITY, ruleToExport.getSeverityString());
+      if (Boolean.TRUE.equals(ruleToExport.getPrioritizedRule())) {
+        xml.prop(ATTRIBUTE_PRIORITIZED_RULE, ruleToExport.getPrioritizedRule());
+      }
 
       if (ruleToExport.isCustomRule()) {
         xml.prop(ATTRIBUTE_NAME, ruleToExport.getName());
@@ -177,6 +181,8 @@ public class QProfileParser {
         rule.setDescription(StringUtils.trim(ruleCursor.collectDescendantText(false)));
       } else if (StringUtils.equals(ATTRIBUTE_PRIORITY, nodeName)) {
         rule.setSeverity(StringUtils.trim(ruleCursor.collectDescendantText(false)));
+      } else if (StringUtils.equals(ATTRIBUTE_PRIORITIZED_RULE, nodeName)) {
+        rule.setPrioritizedRule(Boolean.valueOf(StringUtils.trim(ruleCursor.collectDescendantText(false))));
       } else if (StringUtils.equals(ATTRIBUTE_PARAMETERS, nodeName)) {
         SMInputCursor propsCursor = ruleCursor.childElementCursor(ATTRIBUTE_PARAMETER);
         readParameters(propsCursor, parameters);
index 2b8e3ed56af253b9cae59af52f6577ee51459da3..084bed6dad23f9e74889ac8374db6e8569a2d532 100644 (file)
@@ -21,36 +21,78 @@ package org.sonar.server.qualityprofile;
 
 import java.io.Reader;
 import java.io.StringReader;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
-public class QProfileParserTest {
+class QProfileParserTest {
 
   @Test
-  public void readXml() {
-    Reader backup = new StringReader("<?xml version='1.0' encoding='UTF-8'?>" +
-      "<profile>" +
-      "<name>custom rule</name>" +
-      "<language>js</language>" +
-      "<rules><rule>" +
-      "<repositoryKey>sonarjs</repositoryKey>" +
-      "<key>s001</key>" +
-      "<type>CODE_SMELL</type>" +
-      "<priority>CRITICAL</priority>" +
-      "<name>custom rule name</name>" +
-      "<templateKey>rule_mc8</templateKey>" +
-      "<description>custom rule description</description>" +
-      "<parameters><parameter>" +
-      "<key>bar</key>" +
-      "<value>baz</value>" +
-      "</parameter>" +
-      "</parameters>" +
-      "</rule></rules></profile>");
+  void readXml() {
+    Reader backup = new StringReader("""
+      <?xml version='1.0' encoding='UTF-8'?>
+      <profile>
+        <name>custom rule</name>
+        <language>js</language>
+        <rules>
+          <rule>
+            <repositoryKey>sonarjs</repositoryKey>
+            <key>s001</key>
+            <type>CODE_SMELL</type>
+            <priority>CRITICAL</priority>
+            <name>custom rule name</name>
+            <templateKey>rule_mc8</templateKey>
+            <description>custom rule description</description>
+            <parameters>
+              <parameter>
+                <key>bar</key>
+                <value>baz</value>
+              </parameter>
+            </parameters>
+          </rule>
+          <rule>
+            <repositoryKey>sonarjs</repositoryKey>
+            <key>s002</key>
+            <type>CODE_SMELL</type>
+            <priority>CRITICAL</priority>
+            <prioritizedRule>true</prioritizedRule>
+            <name>custom rule name</name>
+            <templateKey>rule_mc8</templateKey>
+            <description>custom rule description</description>
+            <parameters>
+              <parameter>
+                <key>bar</key>
+                <value>baz</value>
+              </parameter>
+            </parameters>
+          </rule>
+          <rule>
+            <repositoryKey>sonarjs</repositoryKey>
+            <key>s003</key>
+            <type>CODE_SMELL</type>
+            <priority>CRITICAL</priority>
+            <prioritizedRule>false</prioritizedRule>
+            <name>custom rule name</name>
+            <templateKey>rule_mc8</templateKey>
+            <description>custom rule description</description>
+            <parameters>
+              <parameter>
+                <key>bar</key>
+                <value>baz</value>
+              </parameter>
+            </parameters>
+          </rule>
+        </rules>
+      </profile>""");
     var parser = new QProfileParser();
     var importedQProfile = parser.readXml(backup);
-    assertThat(importedQProfile.getRules()).hasSize(1);
+    assertThat(importedQProfile.getRules()).hasSize(3);
     var importedRule = importedQProfile.getRules().get(0);
     assertThat(importedRule.getDescription()).isEqualTo("custom rule description");
+    assertThat(importedRule.getPrioritizedRule()).isFalse();
+    importedRule = importedQProfile.getRules().get(1);
+    assertThat(importedRule.getPrioritizedRule()).isTrue();
+    importedRule = importedQProfile.getRules().get(2);
+    assertThat(importedRule.getPrioritizedRule()).isFalse();
   }
 }