diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-05-30 13:48:46 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-05-30 13:48:46 +0200 |
commit | 35cbb0144ccff8b3ba34ef1cb69d7d0cf3ef1b90 (patch) | |
tree | 69962144199b2183923ef9a495634cc8485ec32e /sonar-core | |
parent | dcc0783e3529e59a42552ac33ded31c4b162e8a8 (diff) | |
download | sonarqube-35cbb0144ccff8b3ba34ef1cb69d7d0cf3ef1b90.tar.gz sonarqube-35cbb0144ccff8b3ba34ef1cb69d7d0cf3ef1b90.zip |
Improve unit test
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java | 18 |
1 files changed, 14 insertions, 4 deletions
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 41089436f81..51002a5ed45 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 @@ -20,6 +20,8 @@ package org.sonar.core.issue.db; +import com.google.common.base.Function; +import com.google.common.collect.Iterables; import org.junit.Before; import org.junit.Test; import org.sonar.api.issue.IssueQuery; @@ -142,14 +144,12 @@ public class IssueDaoTest extends AbstractDaoTestCase { IssueQuery query = IssueQuery.builder().componentRoots(newArrayList("struts")).requiredRole("user").build(); List<IssueDto> issues = newArrayList(dao.selectIssues(query)); assertThat(issues).hasSize(2); - assertThat(issues.get(0).getId()).isEqualTo(100); - assertThat(issues.get(1).getId()).isEqualTo(101); + assertThat(getIssueIds(issues)).containsOnly(100l, 101l); query = IssueQuery.builder().componentRoots(newArrayList("struts-core")).requiredRole("user").build(); issues = newArrayList(dao.selectIssues(query)); assertThat(issues).hasSize(2); - assertThat(issues.get(0).getId()).isEqualTo(100); - assertThat(issues.get(1).getId()).isEqualTo(101); + assertThat(getIssueIds(issues)).containsOnly(100l, 101l); query = IssueQuery.builder().componentRoots(newArrayList("Filter.java")).requiredRole("user").build(); issues = newArrayList(dao.selectIssues(query)); @@ -296,4 +296,14 @@ public class IssueDaoTest extends AbstractDaoTestCase { List<IssueDto> results = newArrayList(dao.selectByIds(newArrayList(100l, 101l, 102l))); assertThat(results).hasSize(3); } + + + private List<Long> getIssueIds(List<IssueDto> issues){ + return newArrayList(Iterables.transform(issues, new Function<IssueDto, Long>() { + @Override + public Long apply(IssueDto input) { + return input.getId(); + } + })); + } } |