aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewActionPlan.java11
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/issue/UpdateActionPlan.java11
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java24
3 files changed, 29 insertions, 17 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewActionPlan.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewActionPlan.java
index 4b9460f44bd..74c92acbfe8 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewActionPlan.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewActionPlan.java
@@ -19,6 +19,9 @@
*/
package org.sonar.wsclient.issue;
+import org.sonar.wsclient.internal.EncodingUtils;
+
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -28,7 +31,6 @@ import java.util.Map;
public class NewActionPlan {
static final String BASE_URL = "/api/action_plans/create";
-
private final Map<String, Object> params = new HashMap<String, Object>();
private NewActionPlan() {
@@ -57,11 +59,8 @@ public class NewActionPlan {
return this;
}
- /**
- * Due date of the action plan. Format is 'day/month/year', for instance, '31/12/2013'.
- */
- public NewActionPlan deadLine(String s) {
- params.put("deadLine", s);
+ public NewActionPlan deadLine(Date deadLine) {
+ params.put("deadLine", EncodingUtils.toQueryParam(deadLine, false));
return this;
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/UpdateActionPlan.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/UpdateActionPlan.java
index 8914e898fce..2ca316217b3 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/UpdateActionPlan.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/UpdateActionPlan.java
@@ -19,6 +19,9 @@
*/
package org.sonar.wsclient.issue;
+import org.sonar.wsclient.internal.EncodingUtils;
+
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -28,7 +31,6 @@ import java.util.Map;
public class UpdateActionPlan {
static final String BASE_URL = "/api/action_plans/update";
-
private final Map<String, Object> params = new HashMap<String, Object>();
private UpdateActionPlan() {
@@ -57,11 +59,8 @@ public class UpdateActionPlan {
return this;
}
- /**
- * Due date of the action plan. Format is 'day/month/year', for instance, '31/12/2013'.
- */
- public UpdateActionPlan deadLine(String s) {
- params.put("deadLine", s);
+ public UpdateActionPlan deadLine(Date deadLine) {
+ params.put("deadLine", EncodingUtils.toQueryParam(deadLine, false));
return this;
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java
index d6597c2e918..4498541a1db 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java
@@ -25,6 +25,9 @@ import org.junit.Test;
import org.sonar.wsclient.MockHttpServerInterceptor;
import org.sonar.wsclient.internal.HttpRequestFactory;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.List;
import static org.fest.assertions.Assertions.assertThat;
@@ -68,14 +71,15 @@ public class DefaultActionPlanClientTest {
}
@Test
- public void should_create_action_plan() {
+ public void should_create_action_plan() throws Exception {
HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
httpServer.doReturnBody("{\"actionPlan\": {\"key\": \"382f6f2e-ad9d-424a-b973-9b065e04348a\"}}");
ActionPlanClient client = new DefaultActionPlanClient(requestFactory);
- ActionPlan result = client.create(NewActionPlan.create().name("Short term").project("org.sonar.Sample").description("Short term issues").deadLine("01/01/2014"));
+ ActionPlan result = client.create(
+ NewActionPlan.create().name("Short term").project("org.sonar.Sample").description("Short term issues").deadLine(stringToDate("2014-01-01")));
- assertThat(httpServer.requestedPath()).isEqualTo("/api/action_plans/create?project=org.sonar.Sample&description=Short%20term%20issues&name=Short%20term&deadLine=01/01/2014");
+ assertThat(httpServer.requestedPath()).isEqualTo("/api/action_plans/create?project=org.sonar.Sample&description=Short%20term%20issues&name=Short%20term&deadLine=2014-01-01");
assertThat(result).isNotNull();
}
@@ -85,9 +89,10 @@ public class DefaultActionPlanClientTest {
httpServer.doReturnBody("{\"actionPlan\": {\"key\": \"382f6f2e-ad9d-424a-b973-9b065e04348a\"}}");
ActionPlanClient client = new DefaultActionPlanClient(requestFactory);
- ActionPlan result = client.update(UpdateActionPlan.create().key("382f6f2e-ad9d-424a-b973-9b065e04348a").name("Short term").description("Short term issues").deadLine("01/01/2014"));
+ ActionPlan result = client.update(
+ UpdateActionPlan.create().key("382f6f2e-ad9d-424a-b973-9b065e04348a").name("Short term").description("Short term issues").deadLine(stringToDate("2014-01-01")));
- assertThat(httpServer.requestedPath()).isEqualTo("/api/action_plans/update?description=Short%20term%20issues&name=Short%20term&deadLine=01/01/2014&key=382f6f2e-ad9d-424a-b973-9b065e04348a");
+ assertThat(httpServer.requestedPath()).isEqualTo("/api/action_plans/update?description=Short%20term%20issues&name=Short%20term&deadLine=2014-01-01&key=382f6f2e-ad9d-424a-b973-9b065e04348a");
assertThat(result).isNotNull();
}
@@ -139,4 +144,13 @@ public class DefaultActionPlanClientTest {
assertThat(result).isNotNull();
}
+ private static Date stringToDate(String sDate) {
+ try {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-dd-MM");
+ return sdf.parse(sDate);
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
}