diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-01-05 12:33:31 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2015-01-05 12:33:31 +0100 |
commit | 57c683d7042fb519aeacb77362e8da268dbfc5ee (patch) | |
tree | b311edeb5190e06ae96b86d5835930d0e23220d5 | |
parent | d6a95decd3786e41a14586b85e81ac5645d7d953 (diff) | |
download | sonarqube-57c683d7042fb519aeacb77362e8da268dbfc5ee.tar.gz sonarqube-57c683d7042fb519aeacb77362e8da268dbfc5ee.zip |
SONAR-5753 moduleUuidPath of foot projects should be empty instead of NULL
15 files changed, 53 insertions, 45 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java index f1b414359a5..c1ce39f0b36 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java @@ -99,6 +99,7 @@ public class PopulateProjectsUuidColumnsMigration implements DatabaseMigration { if (component.getUuid() == null) { component.setUuid(getOrCreateUuid(component, uuidByComponentId)); component.setProjectUuid(getOrCreateUuid(project, uuidByComponentId)); + component.setModuleUuidPath(""); componentsToMigrate.add(component); } } @@ -115,6 +116,7 @@ public class PopulateProjectsUuidColumnsMigration implements DatabaseMigration { for (Component component : readSession.getMapper(Migration50Mapper.class).selectDisabledDirectComponentChildrenForProjects(project.getId())) { component.setUuid(getOrCreateUuid(component, uuidByComponentId)); component.setProjectUuid(projectUuid); + component.setModuleUuidPath(""); writeSession.getMapper(Migration50Mapper.class).updateComponentUuids(component); counter.getAndIncrement(); @@ -122,6 +124,7 @@ public class PopulateProjectsUuidColumnsMigration implements DatabaseMigration { for (Component component : readSession.getMapper(Migration50Mapper.class).selectDisabledNoneDirectComponentChildrenForProjects(project.getId())) { component.setUuid(getOrCreateUuid(component, uuidByComponentId)); component.setProjectUuid(projectUuid); + component.setModuleUuidPath(""); writeSession.getMapper(Migration50Mapper.class).updateComponentUuids(component); counter.getAndIncrement(); @@ -159,6 +162,7 @@ public class PopulateProjectsUuidColumnsMigration implements DatabaseMigration { String uuid = Uuids.create(); component.setUuid(uuid); component.setProjectUuid(uuid); + component.setModuleUuidPath(""); writeSession.getMapper(Migration50Mapper.class).updateComponentUuids(component); counter.getAndIncrement(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentTesting.java b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentTesting.java index d1a6db4a09a..347a2afb8e1 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentTesting.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentTesting.java @@ -54,7 +54,7 @@ public class ComponentTesting { .setUuid(Uuids.create()) .setProjectUuid(subProjectOrProject.projectUuid()) .setModuleUuid(subProjectOrProject.uuid()) - .setModuleUuidPath(subProjectOrProject.moduleUuidPath() == null ? subProjectOrProject.uuid() + "." : subProjectOrProject.moduleUuidPath() + subProjectOrProject.uuid() + ".") + .setModuleUuidPath(subProjectOrProject.moduleUuidPath() == null ? subProjectOrProject.uuid() : subProjectOrProject.moduleUuidPath() + "." + subProjectOrProject.uuid()) .setKey("KEY_" + uuid) .setName("NAME_" + uuid) .setLongName("LONG_NAME_" + uuid) diff --git a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest.java b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest.java index a61d93c52c7..0ec5cfaebcc 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest.java @@ -73,7 +73,7 @@ public class PopulateProjectsUuidColumnsMigrationTest { assertThat(root.getUuid()).isNotNull(); assertThat(root.getProjectUuid()).isEqualTo(root.getUuid()); assertThat(root.getModuleUuid()).isNull(); - assertThat(root.getModuleUuidPath()).isNull(); + assertThat(root.getModuleUuidPath()).isEmpty(); Component module = mapper.selectComponentByKey("org.struts:struts-core"); assertThat(module.getUuid()).isNotNull(); @@ -114,7 +114,7 @@ public class PopulateProjectsUuidColumnsMigrationTest { assertThat(root.getUuid()).isEqualTo("ABCD"); assertThat(root.getProjectUuid()).isEqualTo("ABCD"); assertThat(root.getModuleUuid()).isNull(); - assertThat(root.getModuleUuidPath()).isNull(); + assertThat(root.getModuleUuidPath()).isEmpty(); Component module = mapper.selectComponentByKey("org.struts:struts-core"); assertThat(module.getUuid()).isEqualTo("BCDE"); @@ -162,28 +162,28 @@ public class PopulateProjectsUuidColumnsMigrationTest { assertThat(module.getProjectUuid()).isEqualTo(root.getUuid()); // Module and module path will always be null for removed components assertThat(module.getModuleUuid()).isNull(); - assertThat(module.getModuleUuidPath()).isNull(); + assertThat(module.getModuleUuidPath()).isEmpty(); Component subModule = mapper.selectComponentByKey("org.struts:struts-db"); assertThat(subModule.getUuid()).isNotNull(); assertThat(subModule.getProjectUuid()).isEqualTo(root.getUuid()); // Module and module path will always be null for removed components assertThat(subModule.getModuleUuid()).isNull(); - assertThat(subModule.getModuleUuidPath()).isNull(); + assertThat(subModule.getModuleUuidPath()).isEmpty(); Component directory = mapper.selectComponentByKey("org.struts:struts-core:src/org/struts"); assertThat(directory.getUuid()).isNotNull(); assertThat(directory.getProjectUuid()).isEqualTo(root.getUuid()); // Module and module path will always be null for removed components assertThat(directory.getModuleUuid()).isNull(); - assertThat(directory.getModuleUuidPath()).isNull(); + assertThat(directory.getModuleUuidPath()).isEmpty(); Component file = mapper.selectComponentByKey("org.struts:struts-core:src/org/struts/RequestContext.java"); assertThat(file.getUuid()).isNotNull(); assertThat(file.getProjectUuid()).isEqualTo(root.getUuid()); // Module and module path will always be null for removed components assertThat(file.getModuleUuid()).isNull(); - assertThat(file.getModuleUuidPath()).isNull(); + assertThat(file.getModuleUuidPath()).isEmpty(); } @Test @@ -197,7 +197,7 @@ public class PopulateProjectsUuidColumnsMigrationTest { assertThat(root.getUuid()).isNotNull(); assertThat(root.getProjectUuid()).isEqualTo(root.getUuid()); assertThat(root.getModuleUuid()).isNull(); - assertThat(root.getModuleUuidPath()).isNull(); + assertThat(root.getModuleUuidPath()).isEmpty(); } @Test @@ -211,7 +211,7 @@ public class PopulateProjectsUuidColumnsMigrationTest { assertThat(root.getUuid()).isNotNull(); assertThat(root.getProjectUuid()).isEqualTo(root.getUuid()); assertThat(root.getModuleUuid()).isNull(); - assertThat(root.getModuleUuidPath()).isNull(); + assertThat(root.getModuleUuidPath()).isEmpty(); } @Test @@ -225,7 +225,7 @@ public class PopulateProjectsUuidColumnsMigrationTest { assertThat(view.getUuid()).isNotNull(); assertThat(view.getProjectUuid()).isEqualTo(view.getUuid()); assertThat(view.getModuleUuid()).isNull(); - assertThat(view.getModuleUuidPath()).isNull(); + assertThat(view.getModuleUuidPath()).isEmpty(); Component subView = mapper.selectComponentByKey("subView"); assertThat(subView.getUuid()).isNotNull(); @@ -251,7 +251,7 @@ public class PopulateProjectsUuidColumnsMigrationTest { assertThat(dev.getUuid()).isNotNull(); assertThat(dev.getProjectUuid()).isEqualTo(dev.getUuid()); assertThat(dev.getModuleUuid()).isNull(); - assertThat(dev.getModuleUuidPath()).isNull(); + assertThat(dev.getModuleUuidPath()).isEmpty(); Component techDev = mapper.selectComponentByKey("DEV:developer@company.net:org.struts:struts"); assertThat(techDev.getUuid()).isNotNull(); @@ -272,21 +272,21 @@ public class PopulateProjectsUuidColumnsMigrationTest { assertThat(root.getUuid()).isNotNull(); assertThat(root.getProjectUuid()).isEqualTo(root.getUuid()); assertThat(root.getModuleUuid()).isNull(); - assertThat(root.getModuleUuidPath()).isNull(); + assertThat(root.getModuleUuidPath()).isEmpty(); // Module with a snapshot having no islast=true Component module = mapper.selectComponentByKey("org.struts:struts-core"); assertThat(module.getUuid()).isNotNull(); assertThat(module.getProjectUuid()).isEqualTo(module.getUuid()); assertThat(module.getModuleUuid()).isNull(); - assertThat(module.getModuleUuidPath()).isNull(); + assertThat(module.getModuleUuidPath()).isEmpty(); // File linked on a no more existing project - Component file = mapper.selectComponentByKey("org.struts:struts-core:src/org/struts/RequestContext.java"); + Component file = mapper.selectComponentByKey("org.struts:struts-core:src/org/struts/RequestContext.java"); assertThat(file.getUuid()).isNotNull(); assertThat(file.getProjectUuid()).isEqualTo(file.getUuid()); assertThat(file.getModuleUuid()).isNull(); - assertThat(file.getModuleUuidPath()).isNull(); + assertThat(file.getModuleUuidPath()).isEmpty(); } } diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_components.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_components.xml index cff6eb31173..e38e16ae56f 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_components.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_components.xml @@ -2,7 +2,7 @@ <!-- root project --> <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" description="the description" long_name="Apache Struts" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="[null]" created_at="2014-06-18" /> @@ -18,7 +18,7 @@ <!-- module --> <projects id="2" root_id="1" kee="org.struts:struts-core" name="Struts Core" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" scope="PRJ" qualifier="BRC" long_name="Struts Core" deprecated_kee="[null]" description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" created_at="2014-06-18" /> <snapshots id="2" project_id="2" parent_snapshot_id="1" root_project_id="1" root_snapshot_id="1" @@ -33,7 +33,7 @@ <!-- sub module --> <projects id="3" root_id="2" kee="org.struts:struts-db" name="Struts Db" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" scope="PRJ" qualifier="BRC" long_name="Struts Db" deprecated_kee="[null]" description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" created_at="2014-06-18" /> <snapshots id="3" project_id="3" parent_snapshot_id="2" root_project_id="1" root_snapshot_id="1" @@ -48,7 +48,7 @@ <!-- directory --> <projects long_name="org.struts" id="4" scope="DIR" qualifier="DIR" kee="org.struts:struts-core:src/org/struts" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" name="src/org/struts" root_id="2" description="[null]" deprecated_kee="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" path="src/org/struts" created_at="2014-06-18" /> @@ -64,7 +64,7 @@ <!-- file --> <projects long_name="org.struts.RequestContext" id="5" scope="FIL" qualifier="FIL" kee="org.struts:struts-core:src/org/struts/RequestContext.java" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" name="RequestContext.java" root_id="2" description="[null]" deprecated_kee="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="src/org/struts/RequestContext.java" created_at="2014-06-18" /> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_components_without_uuid.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_components_without_uuid.xml index c10e10949b5..4c4c2ec4e28 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_components_without_uuid.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_components_without_uuid.xml @@ -2,7 +2,7 @@ <!-- root project --> <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" description="the description" long_name="Apache Struts" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="[null]" created_at="2014-06-18" /> @@ -18,7 +18,7 @@ <!-- module with a snapshot having no islast=true --> <projects id="2" root_id="1" kee="org.struts:struts-core" name="Struts Core" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" scope="PRJ" qualifier="BRC" long_name="Struts Core" deprecated_kee="[null]" description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" created_at="2014-06-18" /> <snapshots id="2" project_id="2" parent_snapshot_id="1" root_project_id="1" root_snapshot_id="1" @@ -33,7 +33,7 @@ <!-- file linked on a no more existing project --> <projects long_name="org.struts.RequestContext" id="5" scope="FIL" qualifier="FIL" kee="org.struts:struts-core:src/org/struts/RequestContext.java" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" name="RequestContext.java" root_id="999" description="[null]" deprecated_kee="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="src/org/struts/RequestContext.java" created_at="2014-06-18" /> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_developer.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_developer.xml index 0be69725843..f2a7202514c 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_developer.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_developer.xml @@ -2,7 +2,7 @@ <!-- developer --> <projects id="1" kee="DEV:developer@company.net" name="developer@company.net" long_name="Developer" scope="PRJ" qualifier="DEV" root_id="[null]" description="[null]" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="[null]" created_at="2014-09-01" /> <snapshots id="1" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]" @@ -17,7 +17,7 @@ <!-- technical project --> <projects id="2" root_id="1" scope="PRJ" qualifier="DEV_PRJ" kee="DEV:developer@company.net:org.struts:struts" name="Struts" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" description="the description" long_name="Apache Struts" enabled="[true]" language="[null]" copy_resource_id="10" person_id="[null]" path="[null]" deprecated_kee="[null]" created_at="2014-06-18" /> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_disable_components.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_disable_components.xml index fed87fc45a7..a1e51111fc0 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_disable_components.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_disable_components.xml @@ -2,7 +2,7 @@ <!-- root project --> <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" description="the description" long_name="Apache Struts" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="[null]" created_at="2014-06-18" /> @@ -18,7 +18,7 @@ <!-- removed module --> <projects id="2" root_id="1" kee="org.struts:struts-core" name="Struts Core" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" scope="PRJ" qualifier="BRC" long_name="Struts Core" deprecated_kee="[null]" description="[null]" enabled="[false]" language="[null]" copy_resource_id="[null]" person_id="[null]" created_at="2014-06-18" /> <snapshots id="2" project_id="2" parent_snapshot_id="1" root_project_id="1" root_snapshot_id="1" @@ -33,7 +33,7 @@ <!--removed sub module --> <projects id="3" root_id="2" kee="org.struts:struts-db" name="Struts Db" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" scope="PRJ" qualifier="BRC" long_name="Struts Db" deprecated_kee="[null]" description="[null]" enabled="[false]" language="[null]" copy_resource_id="[null]" person_id="[null]" created_at="2014-06-18" /> <snapshots id="3" project_id="3" parent_snapshot_id="2" root_project_id="1" root_snapshot_id="1" @@ -48,7 +48,7 @@ <!-- removed directory --> <projects long_name="org.struts" id="4" scope="DIR" qualifier="DIR" kee="org.struts:struts-core:src/org/struts" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" name="src/org/struts" root_id="2" description="[null]" deprecated_kee="[null]" enabled="[false]" language="[null]" copy_resource_id="[null]" person_id="[null]" path="src/org/struts" created_at="2014-06-18" /> @@ -64,7 +64,7 @@ <!-- removed file --> <projects long_name="org.struts.RequestContext" id="5" scope="FIL" qualifier="FIL" kee="org.struts:struts-core:src/org/struts/RequestContext.java" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" name="RequestContext.java" root_id="2" description="[null]" deprecated_kee="[null]" enabled="[false]" language="java" copy_resource_id="[null]" person_id="[null]" path="src/org/struts/RequestContext.java" created_at="2014-06-18" /> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_library.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_library.xml index d1e8908bf04..bc464dc5264 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_library.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_library.xml @@ -2,7 +2,7 @@ <!-- library --> <projects id="1" root_id="[null]" scope="PRJ" qualifier="LIB" kee="org.hamcrest:hamcrest-library" name="org.hamcrest:hamcrest-library" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" description="[null]" long_name="org.hamcrest:hamcrest-library" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="[null]" created_at="2014-06-18" /> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_provisioned_project.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_provisioned_project.xml index 9e688d16451..0d3962b8d67 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_provisioned_project.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_provisioned_project.xml @@ -2,7 +2,7 @@ <!-- provisioned project --> <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" description="the description" long_name="Apache Struts" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="[null]" created_at="2014-06-18" /> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_view.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_view.xml index 5a1a222a2ba..7b20b9d98ee 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_view.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/migrate_view.xml @@ -2,7 +2,7 @@ <!-- view --> <projects id="1" kee="view" name="View" long_name="View" scope="PRJ" qualifier="VW" root_id="[null]" description="[null]" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="[null]" created_at="2014-09-01" /> <snapshots id="1" project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]" @@ -17,7 +17,7 @@ <!-- sub view --> <projects id="2" kee="subView" name="Sub View" long_name="Sub View" scope="PRJ" qualifier="SVW" root_id="1" description="[null]" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="[null]" created_at="2014-09-01" /> <snapshots id="2" project_id="2" parent_snapshot_id="1" root_project_id="1" root_snapshot_id="1" @@ -32,7 +32,7 @@ <!-- technical project --> <projects id="3" root_id="1" scope="FIL" qualifier="TRK" kee="vieworg.struts:struts" name="Struts" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" description="the description" long_name="Apache Struts" enabled="[true]" language="[null]" copy_resource_id="10" person_id="[null]" path="[null]" deprecated_kee="[null]" created_at="2014-06-18" /> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/not_migrate_already_migrated_components.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/not_migrate_already_migrated_components.xml index 98471afd445..524a1e3a682 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/not_migrate_already_migrated_components.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigrationTest/not_migrate_already_migrated_components.xml @@ -2,7 +2,7 @@ <!-- root project migrated --> <projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" - uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="[null]" + uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="" description="the description" long_name="Apache Struts" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" path="[null]" deprecated_kee="[null]" created_at="2014-06-18" /> @@ -33,7 +33,7 @@ <!-- sub module not migrated --> <projects id="3" root_id="2" kee="org.struts:struts-db" name="Struts Db" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" scope="PRJ" qualifier="BRC" long_name="Struts Db" deprecated_kee="[null]" description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" created_at="2014-06-18" /> <snapshots id="3" project_id="3" parent_snapshot_id="2" root_project_id="1" root_snapshot_id="1" @@ -48,7 +48,7 @@ <!-- directory not migrated --> <projects long_name="org.struts" id="4" scope="DIR" qualifier="DIR" kee="org.struts:struts-core:src/org/struts" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" name="src/org/struts" root_id="2" description="[null]" deprecated_kee="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" path="src/org/struts" created_at="2014-06-18" /> @@ -64,7 +64,7 @@ <!-- file not migrated --> <projects long_name="org.struts.RequestContext" id="5" scope="FIL" qualifier="FIL" kee="org.struts:struts-core:src/org/struts/RequestContext.java" - uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="[null]" + uuid="[null]" project_uuid="[null]" module_uuid="[null]" module_uuid_path="" name="RequestContext.java" root_id="2" description="[null]" deprecated_kee="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="src/org/struts/RequestContext.java" created_at="2014-06-18" /> 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 b26f6ff465e..26de7532558 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 @@ -158,6 +158,7 @@ public class ResourceDao implements DaoComponent { String uuid = Uuids.create(); resource.setUuid(uuid); resource.setProjectUuid(uuid); + resource.setModuleUuidPath(""); } resource.setCreatedAt(now); resource.setAuthorizationUpdatedAt(now.getTime()); diff --git a/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml b/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml index 025d5f4deb1..310b42e62ad 100644 --- a/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/resource/ResourceMapper.xml @@ -209,9 +209,10 @@ <insert id="insert" parameterType="Resource" keyColumn="id" useGeneratedKeys="true" keyProperty="id" > insert into projects - (uuid, project_uuid, name, long_name, description, scope, qualifier, kee, deprecated_kee, path, language, root_id, copy_resource_id, person_id, enabled, authorization_updated_at, created_at) + (uuid, project_uuid, module_uuid, module_uuid_path, name, long_name, description, scope, qualifier, kee, deprecated_kee, path, language, root_id, copy_resource_id, person_id, + enabled, authorization_updated_at, created_at) values ( - #{uuid}, #{projectUuid}, #{name}, #{longName}, #{description}, #{scope}, #{qualifier}, + #{uuid}, #{projectUuid}, #{moduleUuid}, #{moduleUuidPath}, #{name}, #{longName}, #{description}, #{scope}, #{qualifier}, #{key}, #{deprecatedKey}, #{path}, #{language}, #{rootId}, #{copyResourceId}, #{personId}, #{enabled}, #{authorizationUpdatedAt}, #{createdAt} ) 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 b5fdb0c48ac..a071e054929 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 @@ -251,12 +251,12 @@ public class ResourceDaoTest extends AbstractDaoTestCase { setupData("insert"); ResourceDto file1 = new ResourceDto() - .setUuid("ABCD").setProjectUuid("EFGH") + .setUuid("ABCD").setProjectUuid("EFGH").setModuleUuid("EFGH").setModuleUuidPath("EFGH") .setKey("org.struts:struts:/src/main/java/org/struts/Action.java") .setDeprecatedKey("org.struts:struts:org.struts.Action").setScope(Scopes.FILE).setQualifier(Qualifiers.FILE) .setLanguage("java").setName("Action").setLongName("org.struts.Action").setPath("/foo/bar"); ResourceDto file2 = new ResourceDto() - .setUuid("BCDE").setProjectUuid("FGHI") + .setUuid("BCDE").setProjectUuid("FGHI").setModuleUuid("FGHI").setModuleUuidPath("FGHI") .setKey("org.struts:struts:/src/main/java/org/struts/Filter.java") .setDeprecatedKey("org.struts:struts:org.struts.Filter").setScope(Scopes.FILE).setQualifier(Qualifiers.FILE) .setLanguage("java").setName("Filter").setLongName("org.struts.Filter"); @@ -314,9 +314,11 @@ public class ResourceDaoTest extends AbstractDaoTestCase { assertThat(project.getUuid()).isNotNull(); assertThat(project.getProjectUuid()).isEqualTo(project.getUuid()); + assertThat(project.getModuleUuidPath()).isEmpty(); assertThat(file.getUuid()).isNull(); assertThat(file.getProjectUuid()).isNull(); + assertThat(file.getModuleUuidPath()).isNull(); } @Test diff --git a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml index 08cef5638d4..bbaa53ea1a3 100644 --- a/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/resource/ResourceDaoTest/insert-result.xml @@ -1,12 +1,12 @@ <dataset> - <projects id="1" root_id="[null]" uuid="ABCD" project_uuid="EFGH" module_uuid="[null]" module_uuid_path="[null]" + <projects id="1" root_id="[null]" uuid="ABCD" project_uuid="EFGH" module_uuid="EFGH" module_uuid_path="EFGH" scope="FIL" qualifier="FIL" kee="org.struts:struts:/src/main/java/org/struts/Action.java" name="Action" description="[null]" long_name="org.struts.Action" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="2014-09-03" path="/foo/bar" deprecated_kee="org.struts:struts:org.struts.Action" authorization_updated_at="123456789"/> - <projects id="2" root_id="[null]" uuid="BCDE" project_uuid="FGHI" module_uuid="[null]" module_uuid_path="[null]" + <projects id="2" root_id="[null]" uuid="BCDE" project_uuid="FGHI" module_uuid="FGHI" module_uuid_path="FGHI" scope="FIL" qualifier="FIL" kee="org.struts:struts:/src/main/java/org/struts/Filter.java" name="Filter" description="[null]" long_name="org.struts.Filter" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" created_at="2014-09-03" path="[null]" deprecated_kee="org.struts:struts:org.struts.Filter" |