diff options
Diffstat (limited to 'sonar-batch-protocol/src')
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," |