]> source.dussan.org Git - sonarqube.git/commitdiff
Fix creation of component key
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 20 May 2015 08:31:54 +0000 (10:31 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 20 May 2015 08:32:04 +0000 (10:32 +0200)
server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistDuplicationsStepTest.java
sonar-core/src/main/java/org/sonar/core/component/ComponentKeys.java
sonar-core/src/test/java/org/sonar/core/component/ComponentKeysTest.java

index e93deaf797aa3bf80fe2857eaa49487b2c1c7ca2..ebd7c15b209aba764c6d97a918164764a1d34ac1 100644 (file)
@@ -344,7 +344,7 @@ public class PersistDuplicationsStepTest extends BaseStepTest {
     Map<String, Object> dto = dbTester.selectFirst("select snapshot_id as \"snapshotId\", text_value as \"textValue\" from project_measures");
     assertThat(dto.get("snapshotId")).isEqualTo(11L);
     assertThat(dto.get("textValue")).isEqualTo(
-      "<duplications><g><b s=\"1\" l=\"5\" r=\"PROJECT_KEY:file:origin/master\"/><b s=\"6\" l=\"5\" r=\"PROJECT_KEY:file:origin/master\"/></g></duplications>");
+      "<duplications><g><b s=\"1\" l=\"5\" r=\"PROJECT_KEY:origin/master:file\"/><b s=\"6\" l=\"5\" r=\"PROJECT_KEY:origin/master:file\"/></g></duplications>");
   }
 
   @Test
index 8378da72d253c9fc6f903c3590c86089cebfad2a..c9dd6d1e78ef304d549a08cdd93dca57ddc820ec 100644 (file)
@@ -131,11 +131,7 @@ public final class ComponentKeys {
   }
 
   public static String createKey(String moduleKey, @Nullable String path, @Nullable String branch) {
-    String effectiveKey = createEffectiveKey(moduleKey, path);
-    if (StringUtils.isNotBlank(branch)) {
-      return String.format(KEY_WITH_BRANCH_FORMAT, effectiveKey, branch);
-    } else {
-      return effectiveKey;
-    }
+    String key = createKey(moduleKey, branch);
+    return createEffectiveKey(key, path);
   }
 }
index 37fd8d457778027e5f6b44d3db083eec5d2cfdc3..85d6483684629a3a25dd44087db70e5ddc229984 100644 (file)
@@ -43,7 +43,7 @@ public class ComponentKeysTest {
 
   @Test
   public void create_key_from_module_key_path_and_branch() {
-    assertThat(ComponentKeys.createKey("module_key", "file", "origin/master")).isEqualTo("module_key:file:origin/master");
+    assertThat(ComponentKeys.createKey("module_key", "file", "origin/master")).isEqualTo("module_key:origin/master:file");
     assertThat(ComponentKeys.createKey("module_key", "file", null)).isEqualTo("module_key:file");
     assertThat(ComponentKeys.createKey("module_key", null, null)).isEqualTo("module_key");
   }