]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 fix index of rule debt characteristics
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 25 Jun 2014 12:25:13 +0000 (14:25 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 25 Jun 2014 12:25:13 +0000 (14:25 +0200)
sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java
sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionMediumTest.java
sonar-server/src/test/resources/org/sonar/server/rule/ws/ShowActionMediumTest/show_rule_with_overridden_debt_infos.json

index 2e3bba794b74d73b0bbff7ed4d48ebb4136b3722..a9aaafdb9a3c64801bca1b1dbfe8b33e141daab9 100644 (file)
@@ -199,6 +199,11 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> {
       }
 
       //TODO Legacy ID in DTO should be Key
+      update.put(RuleField.CHARACTERISTIC.field(), null);
+      update.put(RuleField.SUB_CHARACTERISTIC.field(), null);
+      update.put(RuleField.DEFAULT_CHARACTERISTIC.field(), null);
+      update.put(RuleField.DEFAULT_SUB_CHARACTERISTIC.field(), null);
+
       CharacteristicDto characteristic = null;
       CharacteristicDto defaultCharacteristic = null;
       if (rule.getDefaultSubCharacteristicId() != null) {
@@ -218,7 +223,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> {
             db.debtCharacteristicDao().selectById(characteristic.getParentId(), session);
           update.put(RuleField.CHARACTERISTIC.field(), parentCharacteristic.getKey());
           if (defaultCharacteristic != null) {
-            if (characteristic.getId() == defaultCharacteristic.getId()) {
+            if (characteristic.getId().equals(defaultCharacteristic.getId())) {
               update.put(RuleField.DEFAULT_CHARACTERISTIC.field(), parentCharacteristic.getKey());
             } else {
               update.put(RuleField.DEFAULT_CHARACTERISTIC.field(),
@@ -227,11 +232,6 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> {
             }
           }
         }
-      } else {
-        update.put(RuleField.CHARACTERISTIC.field(), null);
-        update.put(RuleField.SUB_CHARACTERISTIC.field(), null);
-        update.put(RuleField.DEFAULT_CHARACTERISTIC.field(), null);
-        update.put(RuleField.DEFAULT_SUB_CHARACTERISTIC.field(), null);
       }
 
       String dType = null, dCoefficient = null, dOffset = null;
index 9373d3691bda290103173fd5357b7ac6ba05ec0d..3c8229b9b468f53b9b7d370ac19cc0eb4490ce0e 100644 (file)
@@ -134,8 +134,7 @@ public class ShowActionMediumTest {
   }
 
   @Test
-  @Ignore
-  public void show_rule_with_overridden_debt_infos() throws Exception {
+  public void show_rule_with_overridden_debt() throws Exception {
     MockUserSession.set()
       .setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN)
       .setLogin("me");
index 67aa980fb1c4e02585e91ccc50bdc9ef5c067b4c..84a0cc89f5e8ade003f829f16723681cf17389d5 100644 (file)
@@ -10,7 +10,7 @@
     "tags": ["tag1", "tag2"],
     "sysTags": ["systag1", "systag2"],
     "debtChar": "API",
-    "debtSubChar": "API Abuse",
+    "debtSubChar": "API_ABUSE",
     "debtRemFnType": "LINEAR_OFFSET",
     "debtRemFnCoeff": "5d",
     "debtRemFnOffset": "10h",