aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-02-13 17:02:44 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-02-13 17:08:52 +0100
commit94c01944ba8e03b3206ace25853e84094cbacfda (patch)
tree0c6d5784c9d4bc45f5363a48e084e918be7831bc /sonar-core
parent56c6d32be1457b85dd277797206e7db805e55e4c (diff)
downloadsonarqube-94c01944ba8e03b3206ace25853e84094cbacfda.tar.gz
sonarqube-94c01944ba8e03b3206ace25853e84094cbacfda.zip
SONAR-6117 ComponentDto.isRootProject() should not used module uuid path
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/component/ComponentDtoTest.java9
2 files changed, 10 insertions, 1 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java b/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java
index ecad07f8bbd..fe72cc88037 100644
--- a/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/component/ComponentDto.java
@@ -235,7 +235,7 @@ public class ComponentDto extends Dto<String> implements Component {
}
public boolean isRootProject() {
- return MODULE_UUID_PATH_SEP.equals(moduleUuidPath) && Scopes.PROJECT.equals(scope);
+ return moduleUuid == null && Scopes.PROJECT.equals(scope);
}
@Override
diff --git a/sonar-core/src/test/java/org/sonar/core/component/ComponentDtoTest.java b/sonar-core/src/test/java/org/sonar/core/component/ComponentDtoTest.java
index 52fe57359e7..172164cb1c2 100644
--- a/sonar-core/src/test/java/org/sonar/core/component/ComponentDtoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/component/ComponentDtoTest.java
@@ -21,6 +21,8 @@
package org.sonar.core.component;
import org.junit.Test;
+import org.sonar.api.resources.Qualifiers;
+import org.sonar.api.resources.Scopes;
import static org.assertj.core.api.Assertions.assertThat;
@@ -70,4 +72,11 @@ public class ComponentDtoTest {
assertThat(dto.hashCode()).isEqualTo(dtoWithSameId.hashCode());
assertThat(dto.hashCode()).isNotEqualTo(dtoWithDifferentId.hashCode());
}
+
+ @Test
+ public void is_root_project() throws Exception {
+ assertThat(new ComponentDto().setModuleUuid("ABCD").isRootProject()).isFalse();
+ assertThat(new ComponentDto().setModuleUuid("ABCD").setScope(Scopes.DIRECTORY).isRootProject()).isFalse();
+ assertThat(new ComponentDto().setModuleUuid(null).setScope(Scopes.PROJECT).setQualifier(Qualifiers.PROJECT).isRootProject()).isTrue();
+ }
}