aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-08-09 14:54:09 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-08-10 18:17:07 +0200
commit6322127612a3430304f6073a8d430d2bcbea0e66 (patch)
tree0d72b9266c91b92cf74b8c82d905ef15b930141f
parentfd96c6fd9bbaca53c0e8cb914525f3e043bc23ee (diff)
downloadsonarqube-6322127612a3430304f6073a8d430d2bcbea0e66.tar.gz
sonarqube-6322127612a3430304f6073a8d430d2bcbea0e66.zip
SONAR-7958 populate PROJECTS.B_UUID_PATH in PersistComponentsStep
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistComponentsStep.java7
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistComponentsStepTest.java60
-rw-r--r--sonar-db/src/main/java/org/sonar/db/component/ComponentUpdateDto.java11
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml3
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java30
5 files changed, 81 insertions, 30 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistComponentsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistComponentsStep.java
index 71d9ac9affb..c29c1d21327 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistComponentsStep.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/step/PersistComponentsStep.java
@@ -49,6 +49,7 @@ import org.sonar.server.computation.task.projectanalysis.component.TreeRootHolde
import org.sonar.server.computation.task.step.ComputationStep;
import static com.google.common.collect.FluentIterable.from;
+import static org.sonar.db.component.ComponentDto.UUID_PATH_OF_ROOT;
import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR;
import static org.sonar.db.component.ComponentDto.formatUuidPathFromParent;
import static org.sonar.server.computation.task.projectanalysis.component.ComponentVisitor.Order.PRE_ORDER;
@@ -216,6 +217,7 @@ public class PersistComponentsStep implements ComputationStep {
existingComponent.setCopyComponentUuid(updateDto.getBCopyComponentUuid());
existingComponent.setDescription(updateDto.getBDescription());
existingComponent.setEnabled(updateDto.isBEnabled());
+ existingComponent.setUuidPath(updateDto.getBUuidPath());
existingComponent.setLanguage(updateDto.getBLanguage());
existingComponent.setLongName(updateDto.getBLongName());
existingComponent.setModuleUuid(updateDto.getBModuleUuid());
@@ -243,7 +245,7 @@ public class PersistComponentsStep implements ComputationStep {
res.setProjectUuid(res.uuid());
res.setRootUuid(res.uuid());
- res.setUuidPath(ComponentDto.UUID_PATH_OF_ROOT);
+ res.setUuidPath(UUID_PATH_OF_ROOT);
res.setModuleUuidPath(UUID_PATH_SEPARATOR + res.uuid() + UUID_PATH_SEPARATOR);
return res;
@@ -304,7 +306,7 @@ public class PersistComponentsStep implements ComputationStep {
res.setProjectUuid(res.uuid());
res.setRootUuid(res.uuid());
- res.setUuidPath(ComponentDto.UUID_PATH_OF_ROOT);
+ res.setUuidPath(UUID_PATH_OF_ROOT);
res.setModuleUuidPath(UUID_PATH_SEPARATOR + res.uuid() + UUID_PATH_SEPARATOR);
return res;
@@ -387,6 +389,7 @@ public class PersistComponentsStep implements ComputationStep {
boolean hasDifferences = !StringUtils.equals(existing.getCopyResourceUuid(), target.getCopyResourceUuid()) ||
!StringUtils.equals(existing.description(), target.description()) ||
!existing.isEnabled() ||
+ !StringUtils.equals(existing.getUuidPath(), target.getUuidPath()) ||
!StringUtils.equals(existing.language(), target.language()) ||
!StringUtils.equals(existing.longName(), target.longName()) ||
!StringUtils.equals(existing.moduleUuid(), target.moduleUuid()) ||
diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistComponentsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistComponentsStepTest.java
index 75b59ea40e1..32074d055ce 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistComponentsStepTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/step/ReportPersistComponentsStepTest.java
@@ -43,6 +43,9 @@ import static org.assertj.guava.api.Assertions.assertThat;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.sonar.db.component.ComponentDto.UUID_PATH_OF_ROOT;
+import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR;
+import static org.sonar.db.component.ComponentDto.formatUuidPathFromParent;
import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.DIRECTORY;
import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.FILE;
import static org.sonar.server.computation.task.projectanalysis.component.Component.Type.PROJECT;
@@ -112,6 +115,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
assertThat(projectDto.description()).isEqualTo("Project description");
assertThat(projectDto.path()).isNull();
assertThat(projectDto.uuid()).isEqualTo("ABCD");
+ assertThat(projectDto.getUuidPath()).isEqualTo(UUID_PATH_OF_ROOT);
assertThat(projectDto.moduleUuid()).isNull();
assertThat(projectDto.moduleUuidPath()).isEqualTo("." + projectDto.uuid() + ".");
assertThat(projectDto.projectUuid()).isEqualTo(projectDto.uuid());
@@ -125,6 +129,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
assertThat(moduleDto.description()).isEqualTo("Module description");
assertThat(moduleDto.path()).isEqualTo("module");
assertThat(moduleDto.uuid()).isEqualTo("BCDE");
+ assertThat(moduleDto.getUuidPath()).isEqualTo(projectDto.getUuidPath() + projectDto.uuid() + UUID_PATH_SEPARATOR);
assertThat(moduleDto.moduleUuid()).isEqualTo(projectDto.uuid());
assertThat(moduleDto.moduleUuidPath()).isEqualTo(projectDto.moduleUuidPath() + moduleDto.uuid() + ".");
assertThat(moduleDto.projectUuid()).isEqualTo(projectDto.uuid());
@@ -138,6 +143,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
assertThat(directoryDto.description()).isNull();
assertThat(directoryDto.path()).isEqualTo("src/main/java/dir");
assertThat(directoryDto.uuid()).isEqualTo("CDEF");
+ assertThat(directoryDto.getUuidPath()).isEqualTo(moduleDto.getUuidPath() + moduleDto.uuid() + UUID_PATH_SEPARATOR);
assertThat(directoryDto.moduleUuid()).isEqualTo(moduleDto.uuid());
assertThat(directoryDto.moduleUuidPath()).isEqualTo(moduleDto.moduleUuidPath());
assertThat(directoryDto.projectUuid()).isEqualTo(projectDto.uuid());
@@ -152,6 +158,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
assertThat(fileDto.path()).isEqualTo("src/main/java/dir/Foo.java");
assertThat(fileDto.language()).isEqualTo("java");
assertThat(fileDto.uuid()).isEqualTo("DEFG");
+ assertThat(fileDto.getUuidPath()).isEqualTo(directoryDto.getUuidPath() + directoryDto.uuid() + UUID_PATH_SEPARATOR);
assertThat(fileDto.moduleUuid()).isEqualTo(moduleDto.uuid());
assertThat(fileDto.moduleUuidPath()).isEqualTo(moduleDto.moduleUuidPath());
assertThat(fileDto.projectUuid()).isEqualTo(projectDto.uuid());
@@ -233,9 +240,9 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir")
.setPath("src/main/java/dir")
.addChildren(
- builder(FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java")
- .setPath("src/main/java/dir/Foo.java")
- .build())
+ builder(FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java")
+ .setPath("src/main/java/dir/Foo.java")
+ .build())
.build())
.build())
.build());
@@ -247,22 +254,26 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
ComponentDto projectReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get();
assertThat(projectReloaded.getId()).isEqualTo(project.getId());
assertThat(projectReloaded.uuid()).isEqualTo(project.uuid());
+ assertThat(projectReloaded.getUuidPath()).isEqualTo(UUID_PATH_OF_ROOT);
ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY).get();
assertThat(moduleReloaded.getId()).isEqualTo(module.getId());
assertThat(moduleReloaded.uuid()).isEqualTo(module.uuid());
+ assertThat(moduleReloaded.getUuidPath()).isEqualTo(module.getUuidPath());
assertThat(moduleReloaded.moduleUuid()).isEqualTo(module.moduleUuid());
assertThat(moduleReloaded.moduleUuidPath()).isEqualTo(module.moduleUuidPath());
assertThat(moduleReloaded.projectUuid()).isEqualTo(module.projectUuid());
assertThat(moduleReloaded.getRootUuid()).isEqualTo(module.getRootUuid());
ComponentDto directory = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get();
+ assertThat(directory.getUuidPath()).isEqualTo(directory.getUuidPath());
assertThat(directory.moduleUuid()).isEqualTo(module.uuid());
assertThat(directory.moduleUuidPath()).isEqualTo(module.moduleUuidPath());
assertThat(directory.projectUuid()).isEqualTo(project.uuid());
assertThat(directory.getRootUuid()).isEqualTo(module.uuid());
ComponentDto file = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get();
+ assertThat(file.getUuidPath()).isEqualTo(file.getUuidPath());
assertThat(file.moduleUuid()).isEqualTo(module.uuid());
assertThat(file.moduleUuidPath()).isEqualTo(module.moduleUuidPath());
assertThat(file.projectUuid()).isEqualTo(project.uuid());
@@ -281,13 +292,13 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
builder(Component.Type.MODULE, 3).setUuid("CDEF").setKey("SUB_MODULE_1_KEY")
.setName("Sub Module 1")
.addChildren(
- builder(Component.Type.MODULE, 4).setUuid("DEFG").setKey("SUB_MODULE_2_KEY")
- .setName("Sub Module 2")
- .addChildren(
- builder(DIRECTORY, 5).setUuid("EFGH").setKey("SUB_MODULE_2_KEY:src/main/java/dir")
- .setPath("src/main/java/dir")
+ builder(Component.Type.MODULE, 4).setUuid("DEFG").setKey("SUB_MODULE_2_KEY")
+ .setName("Sub Module 2")
+ .addChildren(
+ builder(DIRECTORY, 5).setUuid("EFGH").setKey("SUB_MODULE_2_KEY:src/main/java/dir")
+ .setPath("src/main/java/dir")
+ .build())
.build())
- .build())
.build())
.build())
.build());
@@ -299,6 +310,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
Optional<ComponentDto> project = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY);
assertThat(project).isPresent();
assertThat(project.get().getRootUuid()).isEqualTo("ABCD");
+ assertThat(project.get().getUuidPath()).isEqualTo(UUID_PATH_OF_ROOT);
Optional<ComponentDto> module = dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY);
assertThat(module).isPresent();
@@ -340,21 +352,25 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(4);
ComponentDto project = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get();
+ assertThat(project.getUuidPath()).isEqualTo(UUID_PATH_OF_ROOT);
assertThat(project.moduleUuid()).isNull();
assertThat(project.moduleUuidPath()).isEqualTo("." + project.uuid() + ".");
assertThat(project.getRootUuid()).isEqualTo("ABCD");
ComponentDto moduleA = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_A").get();
+ assertThat(moduleA.getUuidPath()).isEqualTo(project.getUuidPath() + project.uuid() + UUID_PATH_SEPARATOR);
assertThat(moduleA.moduleUuid()).isEqualTo(project.uuid());
assertThat(moduleA.moduleUuidPath()).isEqualTo(project.moduleUuidPath() + moduleA.uuid() + ".");
assertThat(moduleA.getRootUuid()).isEqualTo(project.uuid());
ComponentDto subModuleA = dbClient.componentDao().selectByKey(dbTester.getSession(), "SUB_MODULE_A").get();
+ assertThat(subModuleA.getUuidPath()).isEqualTo(moduleA.getUuidPath() + moduleA.uuid() + UUID_PATH_SEPARATOR);
assertThat(subModuleA.moduleUuid()).isEqualTo(moduleA.uuid());
assertThat(subModuleA.moduleUuidPath()).isEqualTo(moduleA.moduleUuidPath() + subModuleA.uuid() + ".");
assertThat(subModuleA.getRootUuid()).isEqualTo(project.uuid());
ComponentDto moduleB = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_B").get();
+ assertThat(moduleB.getUuidPath()).isEqualTo(project.getUuidPath() + project.uuid() + UUID_PATH_SEPARATOR);
assertThat(moduleB.moduleUuid()).isEqualTo(project.uuid());
assertThat(moduleB.moduleUuidPath()).isEqualTo(project.moduleUuidPath() + moduleB.uuid() + ".");
assertThat(moduleB.getRootUuid()).isEqualTo(project.uuid());
@@ -381,9 +397,9 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir")
.setPath("src/main/java/dir")
.addChildren(
- builder(FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java")
- .setPath("src/main/java/dir/Foo.java")
- .build())
+ builder(FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java")
+ .setPath("src/main/java/dir/Foo.java")
+ .build())
.build())
.build())
.build());
@@ -407,6 +423,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY).get();
assertThat(moduleReloaded.getId()).isEqualTo(module.getId());
assertThat(moduleReloaded.uuid()).isEqualTo(module.uuid());
+ assertThat(moduleReloaded.getUuidPath()).isEqualTo(module.getUuidPath());
assertThat(moduleReloaded.moduleUuid()).isEqualTo(module.moduleUuid());
assertThat(moduleReloaded.moduleUuidPath()).isEqualTo(module.moduleUuidPath());
assertThat(moduleReloaded.projectUuid()).isEqualTo(module.projectUuid());
@@ -414,6 +431,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get();
assertThat(directoryReloaded.uuid()).isEqualTo(directory.uuid());
+ assertThat(directoryReloaded.getUuidPath()).isEqualTo(directory.getUuidPath());
assertThat(directoryReloaded.moduleUuid()).isEqualTo(directory.moduleUuid());
assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(directory.moduleUuidPath());
assertThat(directoryReloaded.projectUuid()).isEqualTo(directory.projectUuid());
@@ -423,6 +441,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
ComponentDto fileReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get();
assertThat(fileReloaded.uuid()).isEqualTo(file.uuid());
+ assertThat(fileReloaded.getUuidPath()).isEqualTo(file.getUuidPath());
assertThat(fileReloaded.moduleUuid()).isEqualTo(file.moduleUuid());
assertThat(fileReloaded.moduleUuidPath()).isEqualTo(file.moduleUuidPath());
assertThat(fileReloaded.projectUuid()).isEqualTo(file.projectUuid());
@@ -547,6 +566,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
ComponentDto moduleBReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_B").get();
assertThat(moduleBReloaded).isNotNull();
assertThat(moduleBReloaded.uuid()).isEqualTo(moduleB.uuid());
+ assertThat(moduleBReloaded.getUuidPath()).isEqualTo(moduleBReloaded.getUuidPath());
assertThat(moduleBReloaded.moduleUuid()).isEqualTo(moduleAreloaded.uuid());
assertThat(moduleBReloaded.moduleUuidPath()).isEqualTo(moduleAreloaded.moduleUuidPath() + moduleBReloaded.uuid() + ".");
assertThat(moduleBReloaded.projectUuid()).isEqualTo(project.uuid());
@@ -555,6 +575,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_B:src/main/java/dir").get();
assertThat(directoryReloaded).isNotNull();
assertThat(directoryReloaded.uuid()).isEqualTo(directory.uuid());
+ assertThat(directoryReloaded.getUuidPath()).isEqualTo(directoryReloaded.getUuidPath());
assertThat(directoryReloaded.moduleUuid()).isEqualTo(moduleBReloaded.uuid());
assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(moduleBReloaded.moduleUuidPath());
assertThat(directoryReloaded.projectUuid()).isEqualTo(project.uuid());
@@ -563,6 +584,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
ComponentDto fileReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_B:src/main/java/dir/Foo.java").get();
assertThat(fileReloaded).isNotNull();
assertThat(fileReloaded.uuid()).isEqualTo(file.uuid());
+ assertThat(fileReloaded.getUuidPath()).isEqualTo(fileReloaded.getUuidPath());
assertThat(fileReloaded.moduleUuid()).isEqualTo(moduleBReloaded.uuid());
assertThat(fileReloaded.moduleUuidPath()).isEqualTo(moduleBReloaded.moduleUuidPath());
assertThat(fileReloaded.projectUuid()).isEqualTo(project.uuid());
@@ -602,6 +624,9 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
.setKey("MODULE_KEY:src/main/java/dir")
.setEnabled(false);
ComponentDto removedFile = ComponentTesting.newFileDto(removedModule, "DEFG")
+ // method ComponentTesting.newFileDto is buggy because it only takes the module/project and assumes it is the parent of the file,
+ // which is wrong here (and most of the time), it is the directory
+ .setUuidPath(formatUuidPathFromParent(removedDirectory))
.setPath("src/main/java/dir/Foo.java")
.setName("Foo.java")
.setKey("MODULE_KEY:src/main/java/dir/Foo.java")
@@ -619,9 +644,9 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir")
.setPath("src/main/java/dir")
.addChildren(
- builder(FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java")
- .setPath("src/main/java/dir/Foo.java")
- .build())
+ builder(FILE, 4).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java")
+ .setPath("src/main/java/dir/Foo.java")
+ .build())
.build())
.build())
.build());
@@ -641,6 +666,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
ComponentDto projectReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get();
assertThat(projectReloaded.getId()).isEqualTo(project.getId());
assertThat(projectReloaded.uuid()).isEqualTo(project.uuid());
+ assertThat(projectReloaded.getUuidPath()).isEqualTo(project.getUuidPath());
assertThat(projectReloaded.moduleUuid()).isEqualTo(project.moduleUuid());
assertThat(projectReloaded.moduleUuidPath()).isEqualTo(project.moduleUuidPath());
assertThat(projectReloaded.projectUuid()).isEqualTo(project.projectUuid());
@@ -650,6 +676,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY).get();
assertThat(moduleReloaded.getId()).isEqualTo(removedModule.getId());
assertThat(moduleReloaded.uuid()).isEqualTo(removedModule.uuid());
+ assertThat(moduleReloaded.getUuidPath()).isEqualTo(removedModule.getUuidPath());
assertThat(moduleReloaded.moduleUuid()).isEqualTo(removedModule.moduleUuid());
assertThat(moduleReloaded.moduleUuidPath()).isEqualTo(removedModule.moduleUuidPath());
assertThat(moduleReloaded.projectUuid()).isEqualTo(removedModule.projectUuid());
@@ -659,6 +686,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get();
assertThat(directoryReloaded.getId()).isEqualTo(removedDirectory.getId());
assertThat(directoryReloaded.uuid()).isEqualTo(removedDirectory.uuid());
+ assertThat(directoryReloaded.getUuidPath()).isEqualTo(removedDirectory.getUuidPath());
assertThat(directoryReloaded.moduleUuid()).isEqualTo(removedDirectory.moduleUuid());
assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(removedDirectory.moduleUuidPath());
assertThat(directoryReloaded.projectUuid()).isEqualTo(removedDirectory.projectUuid());
@@ -670,6 +698,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
ComponentDto fileReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get();
assertThat(fileReloaded.getId()).isEqualTo(fileReloaded.getId());
assertThat(fileReloaded.uuid()).isEqualTo(removedFile.uuid());
+ assertThat(fileReloaded.getUuidPath()).isEqualTo(removedFile.getUuidPath());
assertThat(fileReloaded.moduleUuid()).isEqualTo(removedFile.moduleUuid());
assertThat(fileReloaded.moduleUuidPath()).isEqualTo(removedFile.moduleUuidPath());
assertThat(fileReloaded.projectUuid()).isEqualTo(removedFile.projectUuid());
@@ -731,6 +760,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
ComponentDto fileReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get();
assertThat(fileReloaded.getId()).isEqualTo(removedFile.getId());
assertThat(fileReloaded.uuid()).isEqualTo(removedFile.uuid());
+ assertThat(fileReloaded.getUuidPath()).isEqualTo(fileReloaded.getUuidPath());
assertThat(fileReloaded.moduleUuid()).isEqualTo(moduleReloaded.uuid());
assertThat(fileReloaded.moduleUuidPath()).isEqualTo(moduleReloaded.moduleUuidPath());
assertThat(fileReloaded.projectUuid()).isEqualTo(moduleReloaded.projectUuid());
diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentUpdateDto.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentUpdateDto.java
index 7f9af5ab723..54f2b9bd6b6 100644
--- a/sonar-db/src/main/java/org/sonar/db/component/ComponentUpdateDto.java
+++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentUpdateDto.java
@@ -33,6 +33,7 @@ public class ComponentUpdateDto {
private String bCopyComponentUuid;
private String bDescription;
private boolean bEnabled;
+ private String bUuidPath;
private String bLanguage;
private String bLongName;
private String bModuleUuid;
@@ -68,6 +69,10 @@ public class ComponentUpdateDto {
return bEnabled;
}
+ public String getBUuidPath() {
+ return bUuidPath;
+ }
+
@CheckForNull
public String getBLanguage() {
return bLanguage;
@@ -118,6 +123,11 @@ public class ComponentUpdateDto {
return this;
}
+ public ComponentUpdateDto setBUuidPath(String bUuidPath) {
+ this.bUuidPath = bUuidPath;
+ return this;
+ }
+
public ComponentUpdateDto setBName(@Nullable String s) {
this.bName = s;
return this;
@@ -168,6 +178,7 @@ public class ComponentUpdateDto {
.setBCopyComponentUuid(from.getCopyResourceUuid())
.setBDescription(from.description())
.setBEnabled(from.isEnabled())
+ .setBUuidPath(from.getUuidPath())
.setBLanguage(from.language())
.setBLongName(from.longName())
.setBModuleUuid(from.moduleUuid())
diff --git a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
index c1dece9ad81..383175c492e 100644
--- a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
@@ -597,6 +597,7 @@
b_copy_component_uuid = #{bCopyComponentUuid,jdbcType=VARCHAR},
b_description = #{bDescription,jdbcType=VARCHAR},
b_enabled = #{bEnabled,jdbcType=BOOLEAN},
+ b_uuid_path = #{bUuidPath,jdbcType=VARCHAR},
b_language = #{bLanguage,jdbcType=VARCHAR},
b_long_name = #{bLongName,jdbcType=VARCHAR},
b_module_uuid = #{bModuleUuid,jdbcType=VARCHAR},
@@ -614,6 +615,7 @@
b_copy_component_uuid = copy_component_uuid,
b_description = description,
b_enabled = ${_false},
+ b_uuid_path = uuid_path,
b_language = language,
b_long_name = long_name,
b_module_uuid = module_uuid,
@@ -631,6 +633,7 @@
copy_component_uuid = b_copy_component_uuid,
description = b_description,
enabled = b_enabled,
+ uuid_path = b_uuid_path,
language = b_language,
long_name = b_long_name,
module_uuid = b_module_uuid,
diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
index f54b6165162..70a3f9f2ddf 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java
@@ -670,6 +670,7 @@ public class ComponentDaoTest {
.setBChanged(true)
.setBDescription("desc")
.setBEnabled(true)
+ .setBUuidPath("uuid_path")
.setBLanguage("lang")
.setBLongName("longName")
.setBModuleUuid("moduleUuid")
@@ -677,14 +678,15 @@ public class ComponentDaoTest {
.setBName("name")
.setBPath("path")
.setBQualifier("qualifier")
- );
+ );
dbSession.commit();
Map<String, Object> row = selectBColumnsForUuid("U1");
- assertThat(row.get("bChanged")).isIn(true, /* for Oracle */ 1L, 1);
+ assertThat(row.get("bChanged")).isIn(true, /* for Oracle */1L, 1);
assertThat(row.get("bCopyComponentUuid")).isEqualTo("copy");
assertThat(row.get("bDescription")).isEqualTo("desc");
- assertThat(row.get("bEnabled")).isIn(true, /* for Oracle */ 1L, 1);
+ assertThat(row.get("bEnabled")).isIn(true, /* for Oracle */1L, 1);
+ assertThat(row.get("bUuidPath")).isEqualTo("uuid_path");
assertThat(row.get("bLanguage")).isEqualTo("lang");
assertThat(row.get("bLongName")).isEqualTo("longName");
assertThat(row.get("bModuleUuid")).isEqualTo("moduleUuid");
@@ -705,10 +707,11 @@ public class ComponentDaoTest {
dbSession.commit();
Map<String, Object> row1 = selectBColumnsForUuid("U1");
- assertThat(row1.get("bChanged")).isIn(true, /* for Oracle */ 1L, 1);
+ assertThat(row1.get("bChanged")).isIn(true, /* for Oracle */1L, 1);
assertThat(row1.get("bCopyComponentUuid")).isEqualTo(dto1.getCopyResourceUuid());
assertThat(row1.get("bDescription")).isEqualTo(dto1.description());
- assertThat(row1.get("bEnabled")).isIn(false, /* for Oracle */ 0L, 0);
+ assertThat(row1.get("bEnabled")).isIn(false, /* for Oracle */0L, 0);
+ assertThat(row1.get("bUuidPath")).isEqualTo(dto1.getUuidPath());
assertThat(row1.get("bLanguage")).isEqualTo(dto1.language());
assertThat(row1.get("bLongName")).isEqualTo(dto1.longName());
assertThat(row1.get("bModuleUuid")).isEqualTo(dto1.moduleUuid());
@@ -718,10 +721,11 @@ public class ComponentDaoTest {
assertThat(row1.get("bQualifier")).isEqualTo(dto1.qualifier());
Map<String, Object> row2 = selectBColumnsForUuid("U2");
- assertThat(row2.get("bChanged")).isIn(true, /* for Oracle */ 1L, 1);
+ assertThat(row2.get("bChanged")).isIn(true, /* for Oracle */1L, 1);
assertThat(row2.get("bCopyComponentUuid")).isEqualTo(dto2.getCopyResourceUuid());
assertThat(row2.get("bDescription")).isEqualTo(dto2.description());
- assertThat(row2.get("bEnabled")).isIn(false, /* for Oracle */ 0L, 0);
+ assertThat(row2.get("bEnabled")).isIn(false, /* for Oracle */0L, 0);
+ assertThat(row2.get("bUuidPath")).isEqualTo(dto2.getUuidPath());
assertThat(row2.get("bLanguage")).isEqualTo(dto2.language());
assertThat(row2.get("bLongName")).isEqualTo(dto2.longName());
assertThat(row2.get("bModuleUuid")).isEqualTo(dto2.moduleUuid());
@@ -731,16 +735,16 @@ public class ComponentDaoTest {
assertThat(row2.get("bQualifier")).isEqualTo(dto2.qualifier());
Map<String, Object> row3 = selectBColumnsForUuid("U3");
- assertThat(row3.get("bChanged")).isIn(false, /* for Oracle */ 0L, 0);
+ assertThat(row3.get("bChanged")).isIn(false, /* for Oracle */0L, 0);
}
private Map<String, Object> selectBColumnsForUuid(String uuid) {
return db.selectFirst(
- "select b_changed as \"bChanged\", b_copy_component_uuid as \"bCopyComponentUuid\", b_description as \"bDescription\", " +
- "b_enabled as \"bEnabled\", b_language as \"bLanguage\", b_long_name as \"bLongName\"," +
- "b_module_uuid as \"bModuleUuid\", b_module_uuid_path as \"bModuleUuidPath\", b_name as \"bName\", " +
- "b_path as \"bPath\", b_qualifier as \"bQualifier\" " +
- "from projects where uuid='" + uuid + "'");
+ "select b_changed as \"bChanged\", b_copy_component_uuid as \"bCopyComponentUuid\", b_description as \"bDescription\", " +
+ "b_enabled as \"bEnabled\", b_uuid_path as \"bUuidPath\", b_language as \"bLanguage\", b_long_name as \"bLongName\"," +
+ "b_module_uuid as \"bModuleUuid\", b_module_uuid_path as \"bModuleUuidPath\", b_name as \"bName\", " +
+ "b_path as \"bPath\", b_qualifier as \"bQualifier\" " +
+ "from projects where uuid='" + uuid + "'");
}
@Test