aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-05-30 16:12:35 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-05-30 16:12:35 +0200
commit78eb1791cdbb6b95f6f1493692a4b14d13d12178 (patch)
tree2df481474b9955df516f7d6ecdaef8a0e7d508d7 /sonar-core
parent73b1299333b3e0707a4d73e4c4fad1874a158eac (diff)
downloadsonarqube-78eb1791cdbb6b95f6f1493692a4b14d13d12178.tar.gz
sonarqube-78eb1791cdbb6b95f6f1493692a4b14d13d12178.zip
SONAR-4301 Sort issues by id desc on selectByIds and selectIssues
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java23
2 files changed, 25 insertions, 0 deletions
diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
index 09c2ab1fb14..463e7f0fd36 100644
--- a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
@@ -144,6 +144,7 @@
and p.id=i.component_id
and i.root_component_id=root.id
</where>
+ order by i.id desc
</select>
<select id="selectIssues" parameterType="map" resultType="Issue" fetchSize="100000">
@@ -254,6 +255,7 @@
and i.issue_creation_date &lt; #{query.createdBefore}
</if>
</where>
+ order by i.id desc
</sql>
</mapper>
diff --git a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java
index 51002a5ed45..ec9f735b8cb 100644
--- a/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java
@@ -90,6 +90,18 @@ public class IssueDaoTest extends AbstractDaoTestCase {
}
@Test
+ public void should_select_issues_sort_results_by_id_desc() {
+ setupData("shared", "should_select_all");
+
+ IssueQuery query = IssueQuery.builder().requiredRole("user").build();
+
+ List<IssueDto> results = dao.selectIssues(query);
+ assertThat(results.get(0).getId()).isEqualTo(102);
+ assertThat(results.get(1).getId()).isEqualTo(101);
+ assertThat(results.get(2).getId()).isEqualTo(100);
+ }
+
+ @Test
public void should_select_by_rules() {
setupData("shared", "should_select_by_rules");
@@ -297,6 +309,17 @@ public class IssueDaoTest extends AbstractDaoTestCase {
assertThat(results).hasSize(3);
}
+ @Test
+ public void should_select_by_ids_sort_results_by_id_desc() {
+ setupData("shared", "should_select_by_ids");
+
+ List<IssueDto> results = newArrayList(dao.selectByIds(newArrayList(100l, 101l, 102l)));
+
+ assertThat(results.get(0).getId()).isEqualTo(102);
+ assertThat(results.get(1).getId()).isEqualTo(101);
+ assertThat(results.get(2).getId()).isEqualTo(100);
+ }
+
private List<Long> getIssueIds(List<IssueDto> issues){
return newArrayList(Iterables.transform(issues, new Function<IssueDto, Long>() {