aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-batch/src')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java5
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java10
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml2
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml2
4 files changed, 10 insertions, 9 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java
index 0f7faddb25f..84e486f605e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java
@@ -338,15 +338,16 @@ public final class DefaultResourcePersister implements ResourcePersister {
if (Scopes.isProject(parentResource)) {
model.setModuleUuid(parentResource.getUuid());
String parentModuleUuidPath = parentModel.getModuleUuidPath();
- model.setModuleUuidPath(parentModuleUuidPath != null ? parentModuleUuidPath + "." + parentModel.getUuid() : parentModel.getUuid());
+ model.setModuleUuidPath(StringUtils.isNotBlank(parentModuleUuidPath) ? parentModuleUuidPath + "." + parentModel.getUuid() : parentModel.getUuid());
} else {
model.setModuleUuid(parentModel.getModuleUuid());
String parentModuleUuidPath = parentModel.getModuleUuidPath();
- model.setModuleUuidPath(parentModuleUuidPath != null ? parentModuleUuidPath : parentModel.getUuid());
+ model.setModuleUuidPath(StringUtils.isNotBlank(parentModuleUuidPath) ? parentModuleUuidPath : parentModel.getUuid());
}
} else {
// Root module && libraries
model.setProjectUuid(model.getUuid());
+ model.setModuleUuidPath("");
}
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java
index 23ad3689cf6..7f54b3d5ebb 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java
@@ -122,7 +122,7 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase {
assertThat(newProject.uuid()).isNotNull();
assertThat(newProject.projectUuid()).isEqualTo(newProject.uuid());
assertThat(newProject.moduleUuid()).isNull();
- assertThat(newProject.moduleUuidPath()).isNull();
+ assertThat(newProject.moduleUuidPath()).isEqualTo("");
// SONAR-3636 : created_at must be fed when inserting a new entry in the 'projects' table
assertThat(newProject.getCreatedAt()).isNotNull();
} finally {
@@ -147,7 +147,7 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase {
assertThat(newProject.uuid()).isNotNull();
assertThat(newProject.projectUuid()).isEqualTo(newProject.uuid());
assertThat(newProject.moduleUuid()).isNull();
- assertThat(newProject.moduleUuidPath()).isNull();
+ assertThat(newProject.moduleUuidPath()).isEqualTo("");
} finally {
MyBatis.closeQuietly(session);
}
@@ -183,7 +183,7 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase {
assertThat(root.uuid()).isNotNull();
assertThat(root.projectUuid()).isEqualTo(root.uuid());
assertThat(root.moduleUuid()).isNull();
- assertThat(root.moduleUuidPath()).isNull();
+ assertThat(root.moduleUuidPath()).isEqualTo("");
ComponentDto a = session.getMapper(ComponentMapper.class).selectByKey("a");
assertThat(a.uuid()).isNotNull();
assertThat(a.projectUuid()).isEqualTo(root.uuid());
@@ -262,7 +262,7 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase {
assertThat(root.uuid()).isNotNull();
assertThat(root.projectUuid()).isEqualTo(root.uuid());
assertThat(root.moduleUuid()).isNull();
- assertThat(root.moduleUuidPath()).isNull();
+ assertThat(root.moduleUuidPath()).isEqualTo("");
ComponentDto a = session.getMapper(ComponentMapper.class).selectByKey("a");
System.out.println("A: " + a.uuid());
assertThat(a.uuid()).isNotNull();
@@ -355,7 +355,7 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase {
assertThat(newLib.uuid()).isNotNull();
assertThat(newLib.projectUuid()).isEqualTo(newLib.uuid());
assertThat(newLib.moduleUuid()).isNull();
- assertThat(newLib.moduleUuidPath()).isNull();
+ assertThat(newLib.moduleUuidPath()).isEqualTo("");
} finally {
MyBatis.closeQuietly(session);
}
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml
index f36a8e48f96..283baaf3dde 100644
--- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml
+++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml
@@ -1,6 +1,6 @@
<dataset>
- <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" uuid="BCDE" project_uuid="BCDE" module_uuid="[null]" module_uuid_path="[null]"
+ <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" uuid="BCDE" project_uuid="BCDE" module_uuid="[null]" module_uuid_path=""
name="Foo" long_name="Foo" description="some description"
enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" created_at="[null]" path="[null]" deprecated_kee="foo"/>
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml
index cca8b5570dc..d04674f42b8 100644
--- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml
+++ b/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml
@@ -1,6 +1,6 @@
<dataset>
- <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" uuid="BCDE" project_uuid="BCDE" module_uuid="[null]" module_uuid_path="[null]"
+ <projects id="1001" scope="PRJ" qualifier="TRK" kee="foo" root_id="[null]" uuid="BCDE" project_uuid="BCDE" module_uuid="[null]" module_uuid_path=""
name="new name" long_name="new name" description="new description"
enabled="true" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="foo" />