aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch-protocol
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-07-18 18:01:10 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-07-18 18:02:10 +0200
commite93420742f6d1361b5043eb56b15cbdbf7d00690 (patch)
tree5e457115e3fb272bafceb399802d79f1f860aa42 /sonar-batch-protocol
parent29fc472ef063094907dca7b71f443036dd623ea6 (diff)
downloadsonarqube-e93420742f6d1361b5043eb56b15cbdbf7d00690.tar.gz
sonarqube-e93420742f6d1361b5043eb56b15cbdbf7d00690.zip
SONAR-5417 Need bestValue and optimizedBestValue on metric in batch protocol
Diffstat (limited to 'sonar-batch-protocol')
-rw-r--r--sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Metric.java16
-rw-r--r--sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java4
2 files changed, 17 insertions, 3 deletions
diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Metric.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Metric.java
index 2b88577b9f2..704a917aece 100644
--- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Metric.java
+++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Metric.java
@@ -27,10 +27,16 @@ public class Metric {
private final String valueType;
- public Metric(int id, String key, String valueType) {
+ private final Double bestValue;
+
+ private final boolean optimizedBestValue;
+
+ public Metric(int id, String key, String valueType, Double bestValue, boolean optimizedBestValue) {
this.id = id;
this.key = key;
this.valueType = valueType;
+ this.bestValue = bestValue;
+ this.optimizedBestValue = optimizedBestValue;
}
public int id() {
@@ -45,4 +51,12 @@ public class Metric {
return valueType;
}
+ public Double bestValue() {
+ return bestValue;
+ }
+
+ public boolean isOptimizedBestValue() {
+ return optimizedBestValue;
+ }
+
}
diff --git a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java
index f7280858258..db914a091ec 100644
--- a/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java
+++ b/sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java
@@ -34,7 +34,7 @@ public class ProjectReferentialsTest {
@Test
public void testToJson() throws Exception {
ProjectReferentials ref = new ProjectReferentials();
- ref.metrics().add(new Metric(1, "ncloc", "INT"));
+ ref.metrics().add(new Metric(1, "ncloc", "INT", 1.0, true));
ref.addQProfile(new QProfile("squid-java", "Java", "java", new SimpleDateFormat("dd/MM/yyyy").parse("14/03/1984")));
ref.addSettings("foo", new HashMap<String, String>());
ref.settings("foo").put("prop", "value");
@@ -44,7 +44,7 @@ public class ProjectReferentialsTest {
System.out.println(ref.toJson());
JSONAssert
.assertEquals(
- "{timestamp:10,metrics:[{id:1,key:ncloc,valueType:INT}],"
+ "{timestamp:10,metrics:[{id:1,key:ncloc,valueType:INT,bestValue:1.0,optimizedBestValue:true}],"
+ "qprofilesByLanguage:{java:{key:\"squid-java\",name:Java,language:java,rulesUpdatedAt:\"Mar 14, 1984 12:00:00 AM\"}},"
+ "activeRules:[{repositoryKey:repo,ruleKey:rule,severity:MAJOR,internalKey:rule,language:java,params:{}}],"
+ "settingsByModule:{foo:{prop:value}}}",