aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch-protocol/src
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-07-22 18:51:50 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-07-23 08:35:05 +0200
commitbdd27251c8f15e7f59cd8701dc53efd57cb4f9f4 (patch)
treec248d7ebb85279472f4df121eb0833b10f55e3a2 /sonar-batch-protocol/src
parente7e4d9f3fea348a80388f7cfd9fedfb48b9c799c (diff)
downloadsonarqube-bdd27251c8f15e7f59cd8701dc53efd57cb4f9f4.tar.gz
sonarqube-bdd27251c8f15e7f59cd8701dc53efd57cb4f9f4.zip
SONAR-5477 Return global settings in /batch/global WS
Diffstat (limited to 'sonar-batch-protocol/src')
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/GlobalReferentials.java10
-rw-r--r--sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/GlobalReferentialsTest.java9
2 files changed, 14 insertions, 5 deletions
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/GlobalReferentials.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/GlobalReferentials.java
index a1ad9e31a5a..4a15c7042d2 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/GlobalReferentials.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/GlobalReferentials.java
@@ -41,10 +41,20 @@ public class GlobalReferentials {
return globalSettings;
}
+ public GlobalReferentials addGlobalSetting(String key, String value){
+ globalSettings.put(key, value);
+ return this;
+ }
+
public Collection<Metric> metrics() {
return metrics;
}
+ public GlobalReferentials addMetric(Metric metric){
+ metrics.add(metric);
+ return this;
+ }
+
public long timestamp() {
return timestamp;
}
diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/GlobalReferentialsTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/GlobalReferentialsTest.java
index 3afd7662fc0..6ea2a3bf218 100644
--- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/GlobalReferentialsTest.java
+++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/GlobalReferentialsTest.java
@@ -31,13 +31,12 @@ import static org.fest.assertions.Assertions.assertThat;
public class GlobalReferentialsTest {
@Test
- public void testToJson() throws Exception {
+ public void to_json() throws Exception {
GlobalReferentials ref = new GlobalReferentials();
- ref.metrics().add(new Metric(1, "ncloc", "INT", "Description", -1, "NCLOC", true, false, 2.0, 1.0, true));
- ref.globalSettings().put("prop", "value");
+ ref.addMetric(new Metric(1, "ncloc", "INT", "Description", -1, "NCLOC", true, false, 2.0, 1.0, true));
+ ref.addGlobalSetting("prop", "value");
ref.setTimestamp(10);
- System.out.println(ref.toJson());
JSONAssert
.assertEquals(
"{timestamp:10,"
@@ -47,7 +46,7 @@ public class GlobalReferentialsTest {
}
@Test
- public void testFromJson() throws JSONException {
+ public void from_json() throws JSONException {
GlobalReferentials ref = GlobalReferentials
.fromJson(new StringReader(
"{timestamp:1,"