summaryrefslogtreecommitdiffstats
path: root/sonar-ws-client
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-03-12 15:49:28 +0100
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-03-12 15:49:34 +0100
commit58cd42e65eb6c0d510f868b0d7fa8761de4651dc (patch)
tree50856fab0f0f0cca2ee6d141045dc3ac0cddef9c /sonar-ws-client
parent7e47d5446016e3fefcef32121fdd6fd3c09df8e1 (diff)
downloadsonarqube-58cd42e65eb6c0d510f868b0d7fa8761de4651dc.tar.gz
sonarqube-58cd42e65eb6c0d510f868b0d7fa8761de4651dc.zip
SONAR-5094 Add ability to fetch quality gate failure text on measures
Diffstat (limited to 'sonar-ws-client')
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java22
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java11
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java2
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java8
4 files changed, 43 insertions, 0 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java
index 6d887eea50e..3d40a55e9a5 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java
@@ -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;
@@ -114,6 +116,26 @@ public class Measure extends Model {
}
@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;
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java
index a7449960d81..a6ea0cbbf33 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java
@@ -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();
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java
index ca91f9995c3..e216ced6137 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java
@@ -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"))
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java
index cc5a124e37f..b1e3b3248da 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java
@@ -58,6 +58,14 @@ public class ResourceQueryTest extends QueryTestCase {
}
@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");
query.setRules("ruleA", "ruleB");