From e93420742f6d1361b5043eb56b15cbdbf7d00690 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Fri, 18 Jul 2014 18:01:10 +0200 Subject: SONAR-5417 Need bestValue and optimizedBestValue on metric in batch protocol --- .../main/java/org/sonar/batch/protocol/input/Metric.java | 16 +++++++++++++++- .../batch/protocol/input/ProjectReferentialsTest.java | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'sonar-batch-protocol') 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()); 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}}}", -- cgit v1.2.3