From 0d8e999c06070b75bdfe8a780cf10aa709ee8e27 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Fri, 13 May 2016 19:22:59 +0200 Subject: [PATCH] SONAR-7637 WS api/issues/search 'createdAter' parameter should be inclusive --- .../main/java/org/sonar/server/issue/index/IssueIndex.java | 2 +- .../main/java/org/sonar/server/issue/ws/SearchAction.java | 2 +- .../java/org/sonar/server/issue/index/IssueIndexTest.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java index d5ffa3bbb77..0631d8e00c5 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java @@ -363,7 +363,7 @@ public class IssueIndex extends BaseIndex { if (createdAfter != null) { filters.put("__createdAfter", FilterBuilders .rangeFilter(IssueIndexDefinition.FIELD_ISSUE_FUNC_CREATED_AT) - .gt(createdAfter) + .gte(createdAfter) .cache(false)); } if (createdBefore != null) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java index 2e5e2163412..94796e7e8b9 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchAction.java @@ -203,7 +203,7 @@ public class SearchAction implements IssuesWsAction { .setDescription("To retrieve issues created in a specific analysis, identified by an ISO-formatted datetime stamp.") .setExampleValue("2013-05-01T13:00:00+0100"); action.createParam(CREATED_AFTER) - .setDescription("To retrieve issues created after the given date (exclusive). Format: date or datetime ISO formats. If this parameter is set, createdSince must not be set") + .setDescription("To retrieve issues created after the given date (inclusive). Format: date or datetime ISO formats. If this parameter is set, createdSince must not be set") .setExampleValue("2013-05-01 (or 2013-05-01T13:00:00+0100)"); action.createParam(CREATED_BEFORE) .setDescription("To retrieve issues created before the given date (exclusive). Format: date or datetime ISO formats") diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java index 3d5230ca2ea..cbacb61bb50 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexTest.java @@ -606,8 +606,8 @@ public class IssueIndexTest { IssueTesting.newDoc("ISSUE2", file).setFuncCreationDate(DateUtils.parseDate("2014-09-23"))); assertThat(index.search(IssueQuery.builder(userSessionRule).createdAfter(DateUtils.parseDate("2014-09-19")).build(), new SearchOptions()).getDocs()).hasSize(2); - // Lower bound is excluded - assertThat(index.search(IssueQuery.builder(userSessionRule).createdAfter(DateUtils.parseDate("2014-09-20")).build(), new SearchOptions()).getDocs()).hasSize(1); + // Lower bound is included + assertThat(index.search(IssueQuery.builder(userSessionRule).createdAfter(DateUtils.parseDate("2014-09-20")).build(), new SearchOptions()).getDocs()).hasSize(2); assertThat(index.search(IssueQuery.builder(userSessionRule).createdAfter(DateUtils.parseDate("2014-09-21")).build(), new SearchOptions()).getDocs()).hasSize(1); assertThat(index.search(IssueQuery.builder(userSessionRule).createdAfter(DateUtils.parseDate("2014-09-25")).build(), new SearchOptions()).getDocs()).isEmpty(); } @@ -645,7 +645,7 @@ public class IssueIndexTest { // 20 < createdAt < 25: excludes first issue assertThat(index.search(IssueQuery.builder(userSessionRule) .createdAfter(DateUtils.parseDate("2014-09-20")).createdBefore(DateUtils.parseDate("2014-09-25")) - .build(), new SearchOptions()).getDocs()).hasSize(1); + .build(), new SearchOptions()).getDocs()).hasSize(2); // 21 < createdAt < 25 assertThat(index.search(IssueQuery.builder(userSessionRule) -- 2.39.5