]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5094 Add ability to fetch quality gate failure text on measures
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Wed, 12 Mar 2014 14:49:28 +0000 (15:49 +0100)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Wed, 12 Mar 2014 14:49:34 +0000 (15:49 +0100)
sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java

index 6d887eea50e251dc6eaf0408c065b85730291b98..3d40a55e9a55c67da03859aa6612d24d20166311 100644 (file)
@@ -30,6 +30,8 @@ public class Measure extends Model {
   private String metricName;
   private Double value;
   private String formattedValue;
+  private String alertStatus;
+  private String alertText;
   private String data;
   private String characteristicKey;
   private String characteristicName;
@@ -113,6 +115,26 @@ public class Measure extends Model {
     return this;
   }
 
+  @CheckForNull
+  public String getAlertStatus() {
+    return alertStatus;
+  }
+
+  public Measure setAlertStatus(@Nullable String alertStatus) {
+    this.alertStatus = alertStatus;
+    return this;
+  }
+
+  @CheckForNull
+  public String getAlertText() {
+    return alertText;
+  }
+
+  public Measure setAlertText(@Nullable String alertText) {
+    this.alertText = alertText;
+    return this;
+  }
+
   @CheckForNull
   public String getData() {
     return data;
index a7449960d8193767cbe98e75feab2b635dae52cb..a6ea0cbbf33df891f3d9f0b233419577bb1ac6a6 100644 (file)
@@ -38,6 +38,7 @@ public class ResourceQuery extends Query<Resource> {
   private boolean excludeRules = true;
   private boolean excludeRuleSeverities = true;
   private Boolean includeTrends = null;
+  private Boolean includeAlerts = null;
   private Boolean verbose = Boolean.FALSE;
 
   public ResourceQuery() {
@@ -260,6 +261,15 @@ public class ResourceQuery extends Query<Resource> {
     return this;
   }
 
+  public Boolean isIncludeAlerts() {
+    return includeAlerts;
+  }
+
+  public ResourceQuery setIncludeAlerts(Boolean includeAlerts) {
+    this.includeAlerts = includeAlerts;
+    return this;
+  }
+
   @Override
   public String getUrl() {
     StringBuilder url = new StringBuilder(BASE_URL);
@@ -275,6 +285,7 @@ public class ResourceQuery extends Query<Resource> {
     appendUrlParameter(url, "includetrends", includeTrends);
     appendUrlParameter(url, "characteristics", characteristicKeys);
     appendUrlParameter(url, "languages", languages);
+    appendUrlParameter(url, "includealerts", includeAlerts);
     appendUrlParameter(url, "verbose", verbose);
     return url.toString();
   }
index ca91f9995c3919b0313dba60a9b97723239754ff..e216ced61374f7ff3d5530fd2a90598fd0f788ff 100644 (file)
@@ -98,6 +98,8 @@ public class ResourceUnmarshaller extends AbstractUnmarshaller<Resource> {
         .setMetricName(utils.getString(json, "name"))
         .setValue(utils.getDouble(json, "val"))
         .setFormattedValue(utils.getString(json, "frmt_val"))
+        .setAlertStatus(utils.getString(json, "alert"))
+        .setAlertText(utils.getString(json, "alert_text"))
         .setTrend(utils.getInteger(json, "trend"))
         .setVar(utils.getInteger(json, "var"))
         .setData(utils.getString(json, "data"))
index cc5a124e37fe1645cca58af598d4fd0939dd0033..b1e3b3248dac5aebdca25093734a6bc6435817da 100644 (file)
@@ -57,6 +57,14 @@ public class ResourceQueryTest extends QueryTestCase {
     assertThat(query.getUrl()).isEqualTo(("/api/resources?includetrends=true&verbose=false&"));
   }
 
+  @Test
+  public void measuresWithAlerts() {
+    ResourceQuery query = new ResourceQuery();
+    query.setIncludeAlerts(true);
+
+    assertThat(query.getUrl()).isEqualTo(("/api/resources?includealerts=true&verbose=false&"));
+  }
+
   @Test
   public void measuresOnRules() {
     ResourceQuery query = new ResourceQuery().setMetrics("violations");