diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-11-17 11:38:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-17 11:38:24 +0100 |
commit | a8fa19a4065443dc3aee7fad766229e207c1d506 (patch) | |
tree | 3fd88d86c10dad1feb54343b86756289ae4a9fcc /sonar-db/src/test | |
parent | 4bfa8e9c56b484052bb82b0ec617fc682a46c59c (diff) | |
download | sonarqube-a8fa19a4065443dc3aee7fad766229e207c1d506.tar.gz sonarqube-a8fa19a4065443dc3aee7fad766229e207c1d506.zip |
SONAR-8391 fix NPE when id is invalid in SNAPSHOTS.PATH
Diffstat (limited to 'sonar-db/src/test')
-rw-r--r-- | sonar-db/src/test/java/org/sonar/db/version/v60/PopulateUuidPathColumnOnProjectsTest.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/PopulateUuidPathColumnOnProjectsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/PopulateUuidPathColumnOnProjectsTest.java index 717c9d1f8ea..b109bd8c8af 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/v60/PopulateUuidPathColumnOnProjectsTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/v60/PopulateUuidPathColumnOnProjectsTest.java @@ -117,6 +117,19 @@ public class PopulateUuidPathColumnOnProjectsTest { verifyNoNullPath(); } + @Test + public void ignore_snapshots_with_invalid_snapshots_in_path() throws SQLException { + insert(QUALIFIER_PROJECT, A_PROJECT_UUID, A_PROJECT_UUID, new Snapshot(1L, "", true)); + // the ID 999999 is unknown in the path + insert(QUALIFIER_DIR, A_DIR_UUID, A_PROJECT_UUID, new Snapshot(2L, "1.999999.", true)); + + underTest.execute(); + + verifyPath(A_PROJECT_UUID, "."); + // path of orphans is the path to project only + verifyPath(A_DIR_UUID, format(".%s.", A_PROJECT_UUID)); + } + private void insert(String qualifier, String uuid, String rootUuid, Snapshot... snapshots) { db.executeInsert( TABLE_PROJECTS, @@ -144,11 +157,6 @@ public class PopulateUuidPathColumnOnProjectsTest { assertThat(row.get("UUID_PATH")).isEqualTo(expectedUuidPath); } - private void verifyProjectUuid(String componentUuid, String expectedProjectUuid) { - Map<String, Object> row = db.selectFirst("select project_uuid from projects where uuid='" + componentUuid + "'"); - assertThat(row.get("PROJECT_UUID")).isEqualTo(expectedProjectUuid); - } - private void verifyNoNullPath() { assertThat(db.select("select * from projects where uuid_path is null or uuid_path = ''")).isEmpty(); } |