diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-07-21 17:28:27 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-07-21 17:42:08 +0200 |
commit | 2b2c1f3bcfae1af11de717d395b0cdf702782a39 (patch) | |
tree | 343f51ecdbeb49841bd1db5db17728cefb6075b6 /sonar-batch-protocol/src | |
parent | 718952272eb780ecb2b3f613a0f0337bacff75f6 (diff) | |
download | sonarqube-2b2c1f3bcfae1af11de717d395b0cdf702782a39.tar.gz sonarqube-2b2c1f3bcfae1af11de717d395b0cdf702782a39.zip |
SONAR-5417 Add additional metric attributes
Diffstat (limited to 'sonar-batch-protocol/src')
-rw-r--r-- | sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/input/Metric.java | 55 | ||||
-rw-r--r-- | sonar-batch-protocol/src/test/java/org/sonar/batch/protocol/input/ProjectReferentialsTest.java | 4 |
2 files changed, 56 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 21193575608..f09f3b34e81 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 @@ -30,14 +30,42 @@ public class Metric { private final String valueType; + private final String description; + + private final int direction; + + private final String name; + + private final boolean qualitative; + + private final boolean userManaged; + + private final Double worstValue; + private final Double bestValue; private final boolean optimizedBestValue; - public Metric(int id, String key, String valueType, @Nullable Double bestValue, boolean optimizedBestValue) { + public Metric(int id, + String key, + String valueType, + String description, + int direction, + String name, + boolean qualitative, + boolean userManaged, + @Nullable Double worstValue, + @Nullable Double bestValue, + boolean optimizedBestValue) { this.id = id; this.key = key; this.valueType = valueType; + this.description = description; + this.direction = direction; + this.name = name; + this.qualitative = qualitative; + this.userManaged = userManaged; + this.worstValue = worstValue; this.bestValue = bestValue; this.optimizedBestValue = optimizedBestValue; } @@ -54,6 +82,31 @@ public class Metric { return valueType; } + public String description() { + return description; + } + + public int direction() { + return direction; + } + + public String name() { + return name; + } + + public boolean isQualitative() { + return qualitative; + } + + public boolean isUserManaged() { + return userManaged; + } + + @CheckForNull + public Double worstValue() { + return worstValue; + } + @CheckForNull public Double bestValue() { return bestValue; 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 db914a091ec..deeca583cb5 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", 1.0, true)); + ref.metrics().add(new Metric(1, "ncloc", "INT", "Description", -1, "NCLOC", true, false, 2.0, 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,bestValue:1.0,optimizedBestValue:true}]," + "{timestamp:10,metrics:[{id:1,key:ncloc,valueType:INT,description:Description,direction:-1,name:NCLOC,qualitative:true,userManaged:false,worstValue:2.0,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}}}", |