]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7129 Fix snapshot path builder for Oracle
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 23 Dec 2015 13:06:12 +0000 (14:06 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Wed, 23 Dec 2015 13:06:12 +0000 (14:06 +0100)
server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java
sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java

index bdde220e428bc3eb90aa25db13fa14fd6b64b793..cffa000bc2ff479706817f3fe268cb34963b4892 100644 (file)
@@ -361,15 +361,15 @@ public class TreeActionTest {
     for (JsonElement componentAsJsonElement : components) {
       JsonObject componentAsJsonObject = componentAsJsonElement.getAsJsonObject();
       componentDb.insertComponentAndSnapshot(new ComponentDto()
-          .setUuid(getJsonField(componentAsJsonObject, "id"))
-          .setKey(getJsonField(componentAsJsonObject, "key"))
-          .setName(getJsonField(componentAsJsonObject, "name"))
-          .setPath(getJsonField(componentAsJsonObject, "path"))
-          .setProjectUuid(project.projectUuid())
-          .setQualifier(getJsonField(componentAsJsonObject, "qualifier"))
-          .setDescription(getJsonField(componentAsJsonObject, "description"))
-          .setEnabled(true)
-          .setCreatedAt(now),
+        .setUuid(getJsonField(componentAsJsonObject, "id"))
+        .setKey(getJsonField(componentAsJsonObject, "key"))
+        .setName(getJsonField(componentAsJsonObject, "name"))
+        .setPath(getJsonField(componentAsJsonObject, "path"))
+        .setProjectUuid(project.projectUuid())
+        .setQualifier(getJsonField(componentAsJsonObject, "qualifier"))
+        .setDescription(getJsonField(componentAsJsonObject, "description"))
+        .setEnabled(true)
+        .setCreatedAt(now),
         projectSnapshot);
     }
     db.commit();
index 749c21e3aff40913e02c20a3b4f3adbc94c816b4..7fe84cd77c1ce82d2f02a9abb09eee394a19cb7b 100644 (file)
@@ -54,7 +54,7 @@ public class ComponentTreeQuery {
     this.page = builder.page;
     this.pageSize = builder.pageSize;
     this.baseSnapshot = builder.baseSnapshot;
-    this.baseSnapshotPath = buildLikeValue(baseSnapshot.getPath() + baseSnapshot.getId() + ".", WildcardPosition.AFTER);
+    this.baseSnapshotPath = buildBaseSnapshotPath(baseSnapshot);
     this.direction = builder.asc ? "ASC" : "DESC";
     this.sqlSort = sortFieldsToSqlSort(builder.sortFields, direction);
   }
@@ -112,6 +112,11 @@ public class ComponentTreeQuery {
     return Joiner.on(", ").join(sqlSortFields);
   }
 
+  private String buildBaseSnapshotPath(SnapshotDto baseSnapshot) {
+    String existingSnapshotPath = baseSnapshot.getPath() == null ? "" : baseSnapshot.getPath();
+    return buildLikeValue(existingSnapshotPath + baseSnapshot.getId() + ".", WildcardPosition.AFTER);
+  }
+
   public static class Builder {
     @CheckForNull
     private String nameOrKeyQuery;