]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5406 - Added effortToFix to Rule domain object and WS Json response.
authorStephane Gamard <stephane.gamard@searchbox.com>
Mon, 23 Jun 2014 07:35:55 +0000 (09:35 +0200)
committerStephane Gamard <stephane.gamard@searchbox.com>
Mon, 23 Jun 2014 07:35:55 +0000 (09:35 +0200)
sonar-server/src/main/java/org/sonar/server/rule/Rule.java
sonar-server/src/main/java/org/sonar/server/rule/index/RuleDoc.java
sonar-server/src/main/java/org/sonar/server/rule/index/RuleNormalizer.java
sonar-server/src/main/java/org/sonar/server/rule/ws/RuleMapping.java
sonar-server/src/test/java/org/sonar/server/rule/RuleBackendMediumTest.java

index 74b785903adafab34cf22f3f0012411672df996e..93a238bc12c6062d303823db23e3b11386b611ab 100644 (file)
@@ -24,7 +24,6 @@ import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.server.debt.DebtRemediationFunction;
 
 import javax.annotation.CheckForNull;
-
 import java.util.Date;
 import java.util.List;
 
@@ -41,6 +40,8 @@ public interface Rule {
 
   String htmlDescription();
 
+  String effortToFixDescription();
+
   /**
    * Default severity when activated on a Quality profile
    *
index 3d3d7b301863cfcdae8f4383c28f371985ca06c8..d5f88efdc788acefa19cc54cc2de3f2316e6057f 100644 (file)
@@ -33,7 +33,6 @@ import org.sonar.server.search.IndexUtils;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
-
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -92,6 +91,12 @@ public class RuleDoc extends BaseDoc implements Rule {
     return getNullableField(RuleNormalizer.RuleField.HTML_DESCRIPTION.field());
   }
 
+  @Override
+  @CheckForNull
+  public String effortToFixDescription() {
+    return getNullableField(RuleNormalizer.RuleField.FIX_DESCRIPTION.field());
+  }
+
   @Override
   @CheckForNull
   public String severity() {
index 07d3a37c6699e0650364951f51b6beb7c2741590..d1a3b6fd525037a17d2da31284757a2ab2811a33 100644 (file)
@@ -89,6 +89,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> {
     public static final IndexField HTML_DESCRIPTION = addSearchable(IndexField.Type.TEXT, "htmlDesc");
     public static final IndexField SEVERITY = add(IndexField.Type.STRING, "severity");
     public static final IndexField STATUS = add(IndexField.Type.STRING, "status");
+    public static final IndexField FIX_DESCRIPTION = add(IndexField.Type.STRING, "effortToFix");
     public static final IndexField LANGUAGE = add(IndexField.Type.STRING, "lang");
     public static final IndexField TAGS = add(IndexField.Type.STRING, "tags");
     public static final IndexField SYSTEM_TAGS = add(IndexField.Type.STRING, "sysTags");
@@ -174,6 +175,7 @@ public class RuleNormalizer extends BaseNormalizer<RuleDto, RuleKey> {
       update.put(RuleField.CREATED_AT.field(), rule.getCreatedAt());
       update.put(RuleField.UPDATED_AT.field(), rule.getUpdatedAt());
       update.put(RuleField.HTML_DESCRIPTION.field(), rule.getDescription());
+      update.put(RuleField.FIX_DESCRIPTION.field(), rule.getEffortToFixDescription());
       update.put(RuleField.SEVERITY.field(), rule.getSeverityString());
       update.put(RuleField.STATUS.field(), rule.getStatus().name());
       update.put(RuleField.LANGUAGE.field(), rule.getLanguage());
index 265730b321c6e548a959c6a82c659896a1dce398..4c7585a6d4bf025eb8adc5accc6fd8d51d86dba0 100644 (file)
@@ -53,6 +53,7 @@ public class RuleMapping extends BaseMapping {
     addField("debtRemFn", new IndexStringField("debtRemFnType", RuleNormalizer.RuleField.DEBT_FUNCTION_TYPE.field()));
     addField("debtRemFn", new IndexStringField("debtRemFnCoeff", RuleNormalizer.RuleField.DEBT_FUNCTION_COEFFICIENT.field()));
     addField("debtRemFn", new IndexStringField("debtRemFnOffset", RuleNormalizer.RuleField.DEBT_FUNCTION_OFFSET.field()));
+    addIndexStringField("effortToFixDescription", RuleNormalizer.RuleField.FIX_DESCRIPTION.field());
     addIndexStringField("mdNote", RuleNormalizer.RuleField.NOTE.field());
     addField("htmlNote", new HtmlNoteField(macroInterpreter));
     addIndexStringField("noteLogin", RuleNormalizer.RuleField.NOTE_LOGIN.field());
index 522741cdf4a409968fcd6d7ea927de3b12f92093..f5709040c7f13685ef9c935204dee28cbd2d4b33 100644 (file)
@@ -106,6 +106,7 @@ public class RuleBackendMediumTest {
     assertThat(hit.isTemplate()).isFalse();
     assertThat(hit.tags()).containsOnly("tag1", "tag2");
     assertThat(hit.systemTags()).containsOnly("systag1", "systag2");
+    assertThat(hit.effortToFixDescription()).isEqualTo(persistedDto.getEffortToFixDescription());
   }
 
   @Test