aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-05-31 12:28:00 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-05-31 12:28:00 +0200
commit03d09a44e949a348b98ef8c45ad20c0bf5d9aadd (patch)
tree9c69eebcc39c816aa716a2d7a3b93004d52cacef /sonar-core
parentaf7068a7ab88aefb32174d929669fbd23145c3bf (diff)
downloadsonarqube-03d09a44e949a348b98ef8c45ad20c0bf5d9aadd.tar.gz
sonarqube-03d09a44e949a348b98ef8c45ad20c0bf5d9aadd.zip
SONAR-4301 Load componentRoot, assignee and reporter from db instead of getting it from issues results
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java5
-rw-r--r--sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java9
2 files changed, 14 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java
index 4901abda11c..e893f2970f8 100644
--- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java
@@ -154,6 +154,11 @@ public class ResourceDao {
}
}
+ public Component findByKey(String key) {
+ ResourceDto resourceDto = getResource(ResourceQuery.create().setKey(key));
+ return resourceDto != null ? toComponent(resourceDto) : null;
+ }
+
public List<Integer> findChildrenComponentIds(Collection<String> componentRootKeys){
if (componentRootKeys.isEmpty()) {
return Collections.emptyList();
diff --git a/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java b/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
index 00102831f4e..458dd84f423 100644
--- a/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/resource/ResourceDaoTest.java
@@ -259,4 +259,13 @@ public class ResourceDaoTest extends AbstractDaoTestCase {
assertThat(dao.findChildrenComponentIds(newArrayList("unknown"))).isEmpty();
assertThat(dao.findChildrenComponentIds(Collections.<String>emptyList())).isEmpty();
}
+
+ @Test
+ public void should_find_component_by_key(){
+ setupData("fixture");
+
+ assertThat(dao.findByKey("org.struts:struts")).isNotNull();
+ assertThat(dao.findByKey("org.struts:struts:org.struts.RequestContext")).isNotNull();
+ assertThat(dao.findByKey("unknown")).isNull();
+ }
}