aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-07-01 16:31:22 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-07-04 10:25:07 +0200
commit5112fc0bc1bc9c1725235ffcf3031060a44e3567 (patch)
treef93ddb6ab59fdc2bb528e3a55f2bada8bb2fdfeb /sonar-db/src
parent479c7533db672c2e4b96e8fdcc41142570c39069 (diff)
downloadsonarqube-5112fc0bc1bc9c1725235ffcf3031060a44e3567.tar.gz
sonarqube-5112fc0bc1bc9c1725235ffcf3031060a44e3567.zip
SONAR-7780 Apply feedback
Diffstat (limited to 'sonar-db/src')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/measure/MeasureQuery.java7
-rw-r--r--sonar-db/src/main/java/org/sonar/db/measure/PastMeasureDto.java6
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java4
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjects.java (renamed from sonar-db/src/main/java/org/sonar/db/version/v60/FixProjectUuidOfDevelopers.java)12
-rw-r--r--sonar-db/src/test/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest.java (renamed from sonar-db/src/test/java/org/sonar/db/version/v60/FixProjectUuidOfDevelopersTest.java)6
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest/in_progress_projects.sql (renamed from sonar-db/src/test/resources/org/sonar/db/version/v60/FixProjectUuidOfDevelopersTest/in_progress_projects.sql)0
6 files changed, 18 insertions, 17 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureQuery.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureQuery.java
index 7dd1b1daa8c..dcb534a1ef4 100644
--- a/sonar-db/src/main/java/org/sonar/db/measure/MeasureQuery.java
+++ b/sonar-db/src/main/java/org/sonar/db/measure/MeasureQuery.java
@@ -45,9 +45,9 @@ public class MeasureQuery {
}
private MeasureQuery(List<String> componentUuids,
- @Nullable Collection<Integer> metricIds,
- @Nullable Collection<String> metricKeys,
- @Nullable Long personId) {
+ @Nullable Collection<Integer> metricIds,
+ @Nullable Collection<String> metricKeys,
+ @Nullable Long personId) {
checkState(componentUuids != null, "Component UUIDs must be set");
checkState(metricIds == null || metricKeys == null, "Metric IDs and keys must not be set both");
this.componentUuids = componentUuids;
@@ -96,6 +96,7 @@ public class MeasureQuery {
private Long personId;
private Builder() {
+ // see MeasureQuery#builder()
}
public Builder setComponentUuids(List<String> componentUuids) {
diff --git a/sonar-db/src/main/java/org/sonar/db/measure/PastMeasureDto.java b/sonar-db/src/main/java/org/sonar/db/measure/PastMeasureDto.java
index f4a48cfa4a5..cdc90361b19 100644
--- a/sonar-db/src/main/java/org/sonar/db/measure/PastMeasureDto.java
+++ b/sonar-db/src/main/java/org/sonar/db/measure/PastMeasureDto.java
@@ -39,7 +39,7 @@ public class PastMeasureDto {
return value;
}
- public PastMeasureDto setValue(@Nullable Double value) {
+ PastMeasureDto setValue(@Nullable Double value) {
this.value = value;
return this;
}
@@ -52,7 +52,7 @@ public class PastMeasureDto {
return metricId;
}
- public PastMeasureDto setMetricId(int i) {
+ PastMeasureDto setMetricId(int i) {
this.metricId = i;
return this;
}
@@ -62,7 +62,7 @@ public class PastMeasureDto {
return personId;
}
- public PastMeasureDto setPersonId(@Nullable Long l) {
+ PastMeasureDto setPersonId(@Nullable Long l) {
this.personId = l;
return this;
}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
index 7047aed0917..2490c9f0298 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java
@@ -115,7 +115,7 @@ import org.sonar.db.version.v60.DropSnapshotIdColumnFromCeActivity;
import org.sonar.db.version.v60.DropSnapshotIdColumnFromEvents;
import org.sonar.db.version.v60.DropSnapshotIdColumnsFromDuplicationsIndex;
import org.sonar.db.version.v60.DropUnusedMeasuresColumns;
-import org.sonar.db.version.v60.FixProjectUuidOfDevelopers;
+import org.sonar.db.version.v60.FixProjectUuidOfDeveloperProjects;
import org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnDuplicationsIndex;
import org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnEvents;
import org.sonar.db.version.v60.MakeAnalysisUuidNotNullOnMeasures;
@@ -288,7 +288,7 @@ public class MigrationStepModule extends Module {
MakeAnalysisUuidNotNullOnEvents.class,
DropSnapshotIdColumnFromEvents.class,
- FixProjectUuidOfDevelopers.class,
+ FixProjectUuidOfDeveloperProjects.class,
// PROJECTS.UUID_PATH
AddUuidPathColumnToProjects.class,
PopulateUuidPathColumnOnProjects.class,
diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/FixProjectUuidOfDevelopers.java b/sonar-db/src/main/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjects.java
index 3e042c03f3a..2952a9fa5ff 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/v60/FixProjectUuidOfDevelopers.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjects.java
@@ -26,22 +26,22 @@ import org.sonar.db.version.MassUpdate;
import org.sonar.db.version.Select;
import org.sonar.db.version.SqlStatement;
-public class FixProjectUuidOfDevelopers extends BaseDataChange {
+public class FixProjectUuidOfDeveloperProjects extends BaseDataChange {
- public FixProjectUuidOfDevelopers(Database db) {
+ public FixProjectUuidOfDeveloperProjects(Database db) {
super(db);
}
@Override
public void execute(Context context) throws SQLException {
MassUpdate massUpdate = context.prepareMassUpdate();
- massUpdate.select("select distinct developer_uuid from projects where qualifier = 'DEV_PRJ'");
- massUpdate.update("update projects set project_uuid = developer_uuid where developer_uuid = ? and qualifier = 'DEV_PRJ'");
+ massUpdate.select("select distinct developer_uuid from projects where qualifier = 'DEV_PRJ' and project_uuid != developer_uuid");
+ massUpdate.update("update projects set project_uuid = developer_uuid where developer_uuid = ? and qualifier = 'DEV_PRJ' and project_uuid != developer_uuid");
massUpdate.rowPluralName("developers in project");
- massUpdate.execute((row, update) -> handleComponent(row, update));
+ massUpdate.execute(FixProjectUuidOfDeveloperProjects::handleComponent);
}
- private boolean handleComponent(Select.Row row, SqlStatement update) throws SQLException {
+ private static boolean handleComponent(Select.Row row, SqlStatement update) throws SQLException {
String developerUuid = row.getString(1);
update.setString(1, developerUuid);
diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/FixProjectUuidOfDevelopersTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest.java
index c1d82346580..ea09dcc0838 100644
--- a/sonar-db/src/test/java/org/sonar/db/version/v60/FixProjectUuidOfDevelopersTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest.java
@@ -29,7 +29,7 @@ import org.sonar.db.DbTester;
import static org.assertj.core.api.Assertions.assertThat;
-public class FixProjectUuidOfDevelopersTest {
+public class FixProjectUuidOfDeveloperProjectsTest {
private static final String TABLE_PROJECTS = "projects";
private static final String PROJECT_UUID = "U1";
@@ -39,10 +39,10 @@ public class FixProjectUuidOfDevelopersTest {
private static final String DEV2_IN_PROJECT_UUID = "U5";
@Rule
- public DbTester db = DbTester.createForSchema(System2.INSTANCE, FixProjectUuidOfDevelopersTest.class,
+ public DbTester db = DbTester.createForSchema(System2.INSTANCE, FixProjectUuidOfDeveloperProjectsTest.class,
"in_progress_projects.sql");
- private FixProjectUuidOfDevelopers underTest = new FixProjectUuidOfDevelopers(db.database());
+ private FixProjectUuidOfDeveloperProjects underTest = new FixProjectUuidOfDeveloperProjects(db.database());
@Test
public void migration_has_no_effect_on_empty_tables() throws SQLException {
diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/FixProjectUuidOfDevelopersTest/in_progress_projects.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest/in_progress_projects.sql
index 760728a8dc3..760728a8dc3 100644
--- a/sonar-db/src/test/resources/org/sonar/db/version/v60/FixProjectUuidOfDevelopersTest/in_progress_projects.sql
+++ b/sonar-db/src/test/resources/org/sonar/db/version/v60/FixProjectUuidOfDeveloperProjectsTest/in_progress_projects.sql