From 71ba082eb96d16a2d96cb6e57bd1a93263da09c5 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 12 Aug 2013 18:32:19 +0200 Subject: [PATCH] SONAR-4563 complete web service client --- .../java/org/sonar/wsclient/issue/IssueQuery.java | 9 +++++++++ .../org/sonar/wsclient/issue/IssueQueryTest.java | 14 ++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueQuery.java index f291d31051a..23f200f6053 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueQuery.java @@ -101,6 +101,15 @@ public class IssueQuery { return this; } + /** + * Require second precision. + * @since 3.7 + */ + public IssueQuery createdAt(Date d) { + params.put("createdAt", EncodingUtils.toQueryParam(d, true)); + return this; + } + public IssueQuery createdAfter(Date d) { params.put("createdAfter", EncodingUtils.toQueryParam(d, true)); return this; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/IssueQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/IssueQueryTest.java index 941894aee78..14b352d5eae 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/IssueQueryTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/IssueQueryTest.java @@ -36,7 +36,7 @@ public class IssueQueryTest { @Test public void get_all_issues_by_parameter() throws ParseException { - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); IssueQuery query = IssueQuery.create() .issues("ABCDE", "FGHIJ") .assignees("arthur", "perceval") @@ -51,14 +51,15 @@ public class IssueQueryTest { .statuses("OPEN", "CLOSED") .severities("BLOCKER", "INFO") .reporters("login1", "login2") - .createdBefore(df.parse("2015-12-13T05:59")) - .createdAfter(df.parse("2012-01-23T13:40")) + .createdAt(df.parse("2015-01-02T05:59:50:50")) + .createdBefore(df.parse("2015-12-13T05:59:50")) + .createdAfter(df.parse("2012-01-23T13:40:50")) .sort("ASSIGNEE") .asc(false) .pageSize(5) .pageIndex(4); - assertThat(query.urlParams()).hasSize(19); + assertThat(query.urlParams()).hasSize(20); assertThat(query.urlParams()).includes(entry("issues", "ABCDE,FGHIJ")); assertThat(query.urlParams()).includes(entry("assignees", "arthur,perceval")); assertThat(query.urlParams()).includes(entry("assigned", true)); @@ -72,8 +73,9 @@ public class IssueQueryTest { assertThat(query.urlParams()).includes(entry("statuses", "OPEN,CLOSED")); assertThat(query.urlParams()).includes(entry("severities", "BLOCKER,INFO")); assertThat(query.urlParams()).includes(entry("reporters", "login1,login2")); - assertThat((String)query.urlParams().get("createdBefore")).startsWith("2015-12-13T05:59"); - assertThat((String)query.urlParams().get("createdAfter")).startsWith("2012-01-23T13:40:00"); + assertThat((String)query.urlParams().get("createdBefore")).startsWith("2015-12-13T05:59:50"); + assertThat((String)query.urlParams().get("createdAfter")).startsWith("2012-01-23T13:40:50"); + assertThat((String)query.urlParams().get("createdAt")).startsWith("2015-01-02T05:59:50"); assertThat(query.urlParams()).includes(entry("sort", "ASSIGNEE")); assertThat(query.urlParams()).includes(entry("asc", false)); assertThat(query.urlParams()).includes(entry("pageSize", 5)); -- 2.39.5