diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-07-29 17:43:05 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-07-29 17:43:05 +0200 |
commit | 2ad5e41e3cce45040b4c5edbe19d09be640c293d (patch) | |
tree | 47751511ad3e77e324172a99a3aa5d963dd7f050 /sonar-ws-client/src | |
parent | 93d8dec0e5eb0fc6da292f6409a460aa0c9e86b6 (diff) | |
download | sonarqube-2ad5e41e3cce45040b4c5edbe19d09be640c293d.tar.gz sonarqube-2ad5e41e3cce45040b4c5edbe19d09be640c293d.zip |
Fix wsclient of POST /api/manual_mesasures with integer values
Diffstat (limited to 'sonar-ws-client/src')
2 files changed, 24 insertions, 3 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureCreateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureCreateQuery.java index 83d95c37922..b4c55497a96 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureCreateQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureCreateQuery.java @@ -26,6 +26,7 @@ public class ManualMeasureCreateQuery extends CreateQuery<ManualMeasure> { private String resourceKey; private String metricKey; + private Integer intValue; private Double value; private String textValue; private String description; @@ -52,6 +53,15 @@ public class ManualMeasureCreateQuery extends CreateQuery<ManualMeasure> { return this; } + public Integer getIntValue() { + return intValue; + } + + public ManualMeasureCreateQuery setIntValue(Integer intValue) { + this.intValue = intValue; + return this; + } + public String getTextValue() { return textValue; } @@ -76,7 +86,11 @@ public class ManualMeasureCreateQuery extends CreateQuery<ManualMeasure> { url.append(ManualMeasureQuery.BASE_URL); appendUrlParameter(url, "resource", resourceKey); appendUrlParameter(url, "metric", metricKey); - appendUrlParameter(url, "val", value); + if (value != null) { + appendUrlParameter(url, "val", value); + } else if (intValue != null) { + appendUrlParameter(url, "val", intValue); + } // limitations : POST body is not used, so the complete URL size is limited appendUrlParameter(url, "text", textValue); diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ManualMeasureCreateQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ManualMeasureCreateQueryTest.java index 1a191df8d7a..6231876a75e 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ManualMeasureCreateQueryTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ManualMeasureCreateQueryTest.java @@ -35,8 +35,15 @@ public class ManualMeasureCreateQueryTest extends QueryTestCase { @Test public void shouldCreateWithAllOptionalProperties() { - ManualMeasureCreateQuery query = ManualMeasureCreateQuery.create("foo", "team_size").setValue(3.14).setTextValue("xxx").setDescription("yyy"); - assertThat(query.getUrl(), is("/api/manual_measures?resource=foo&metric=team_size&val=3.14&text=xxx&desc=yyy&")); + ManualMeasureCreateQuery query = ManualMeasureCreateQuery.create("foo", "burned_budget").setValue(3.14).setTextValue("xxx").setDescription("yyy"); + assertThat(query.getUrl(), is("/api/manual_measures?resource=foo&metric=burned_budget&val=3.14&text=xxx&desc=yyy&")); + assertThat(query.getModelClass().getName(), is(ManualMeasure.class.getName())); + } + + @Test + public void shouldSetIntValue() { + ManualMeasureCreateQuery query = ManualMeasureCreateQuery.create("foo", "team_size").setIntValue(45); + assertThat(query.getUrl(), is("/api/manual_measures?resource=foo&metric=team_size&val=45&")); assertThat(query.getModelClass().getName(), is(ManualMeasure.class.getName())); } }
\ No newline at end of file |