From: Julien Lancelot Date: Fri, 1 Sep 2017 11:46:51 +0000 (+0200) Subject: SONAR-9616 Component name is set to public key when empty X-Git-Tag: 6.6-RC1~380^2~21 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4f4c33f79d27c198d86e105637387c58ca91c166;p=sonarqube.git SONAR-9616 Component name is set to public key when empty --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilder.java index ec277ceac4f..275bc96e7b7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilder.java @@ -93,10 +93,11 @@ public class ComponentTreeBuilder { case PROJECT: String projectKey = keyGenerator.generateKey(component, null); String uuid = uuidSupplier.apply(projectKey); + String projectPublicKey = publicKeyGenerator.generateKey(component, null); return ComponentImpl.builder(Component.Type.PROJECT) .setUuid(uuid) .setKey(projectKey) - .setPublicKey(publicKeyGenerator.generateKey(component, null)) + .setPublicKey(projectPublicKey) .setName(nameOfProject(component)) .setStatus(convertStatus(component.getStatus())) .setDescription(trimToNull(component.getDescription())) @@ -108,11 +109,12 @@ public class ComponentTreeBuilder { case MODULE: String moduleKey = keyGenerator.generateKey(component, null); + String modulePublicKey = publicKeyGenerator.generateKey(component, null); return ComponentImpl.builder(Component.Type.MODULE) .setUuid(uuidSupplier.apply(moduleKey)) .setKey(moduleKey) - .setPublicKey(publicKeyGenerator.generateKey(component, null)) - .setName(nameOfOthers(component, moduleKey)) + .setPublicKey(modulePublicKey) + .setName(nameOfOthers(component, modulePublicKey)) .setStatus(convertStatus(component.getStatus())) .setDescription(trimToNull(component.getDescription())) .setReportAttributes(createAttributesBuilder(component).build()) @@ -122,11 +124,12 @@ public class ComponentTreeBuilder { case DIRECTORY: case FILE: String key = keyGenerator.generateKey(closestModule, component); + String publicKey = publicKeyGenerator.generateKey(closestModule, component); return ComponentImpl.builder(convertDirOrFileType(component.getType())) .setUuid(uuidSupplier.apply(key)) .setKey(key) - .setPublicKey(publicKeyGenerator.generateKey(closestModule, component)) - .setName(nameOfOthers(component, key)) + .setPublicKey(publicKey) + .setName(nameOfOthers(component, publicKey)) .setStatus(convertStatus(component.getStatus())) .setDescription(trimToNull(component.getDescription())) .setReportAttributes(createAttributesBuilder(component).build()) diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilderTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilderTest.java index ce41606865c..663125a229e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/component/ComponentTreeBuilderTest.java @@ -225,17 +225,17 @@ public class ComponentTreeBuilderTest { Component root = call(project); Component module = root.getChildren().iterator().next(); - assertThat(module.getName()).isEqualTo("generated_M"); + assertThat(module.getName()).isEqualTo("public_M"); Component directory = module.getChildren().iterator().next(); - assertThat(directory.getName()).isEqualTo("generated_M:src/js"); + assertThat(directory.getName()).isEqualTo("public_M:src/js"); Component file = directory.getChildren().iterator().next(); - assertThat(file.getName()).isEqualTo("generated_M:src/js/Foo.js"); + assertThat(file.getName()).isEqualTo("public_M:src/js/Foo.js"); } @Test - public void names_of_module_directory_and_file_are_keys_if_names_are_empty_in_report() { + public void names_of_module_directory_and_file_are_public_keys_if_names_are_empty_in_report() { ScannerReport.Component project = newBuilder() .setType(PROJECT) .setKey(projectInDb.getKey()) @@ -264,13 +264,13 @@ public class ComponentTreeBuilderTest { Component root = call(project); Component module = root.getChildren().iterator().next(); - assertThat(module.getName()).isEqualTo("generated_M"); + assertThat(module.getName()).isEqualTo("public_M"); Component directory = module.getChildren().iterator().next(); - assertThat(directory.getName()).isEqualTo("generated_M:src/js"); + assertThat(directory.getName()).isEqualTo("public_M:src/js"); Component file = directory.getChildren().iterator().next(); - assertThat(file.getName()).isEqualTo("generated_M:src/js/Foo.js"); + assertThat(file.getName()).isEqualTo("public_M:src/js/Foo.js"); } private void assertThatFileAttributesAreNotSet(Component root) {