);
assertThat(picoContainer.getParent().getParent().getComponentAdapters()).hasSize(
CONTAINER_ITSELF
- + 6 // MigrationConfigurationModule
+ + 7 // MigrationConfigurationModule
+ 16 // level 2
);
assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize(
import org.sonar.server.platform.db.migration.version.v00.DbVersion00;
import org.sonar.server.platform.db.migration.version.v80.DbVersion80;
import org.sonar.server.platform.db.migration.version.v81.DbVersion81;
+import org.sonar.server.platform.db.migration.version.v82.DbVersion82;
public class MigrationConfigurationModule extends Module {
@Override
DbVersion00.class,
DbVersion80.class,
DbVersion81.class,
+ DbVersion82.class,
// migration steps
MigrationStepRegistryImpl.class,
RenameDaysBeforeDeletingInactiveSLBSetting.class)
.add(3112, "Migrate short and long living branches types to common BRANCH type", MigrateSlbsAndLlbsToCommonType.class)
.add(3113, "Migrate short and long living branches types to common BRANCH type in ce tasks table",
- MigrateSlbsAndLlbsToCommonTypeInCeTasks.class)
- .add(3114, "Drop 'In Review' Security Hotspots status ", DropSecurityHotSpotsInReviewStatus.class)
- .add(3115, "Migrate Manual Vulnerabilities to Security Hotspots ", MigrateManualVulnerabilitiesToSecurityHotSpots.class);
+ MigrateSlbsAndLlbsToCommonTypeInCeTasks.class);
}
}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.db.migration.version.v81;
-
-import java.sql.SQLException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.Database;
-import org.sonar.server.platform.db.migration.step.DataChange;
-import org.sonar.server.platform.db.migration.step.MassUpdate;
-
-public class DropSecurityHotSpotsInReviewStatus extends DataChange {
-
- private System2 system;
-
- public DropSecurityHotSpotsInReviewStatus(Database db, System2 system) {
- super(db);
- this.system = system;
- }
-
- @Override
- protected void execute(Context context) throws SQLException {
- MassUpdate massUpdate = context.prepareMassUpdate();
- massUpdate.select("select id,kee from issues where status = 'IN_REVIEW'");
- massUpdate.update("update issues set status = 'TO_REVIEW' where id = ? and status = 'IN_REVIEW'");
- massUpdate.update("insert into issue_changes(issue_key, change_type, change_data, created_at, updated_at, issue_change_creation_date) " +
- "VALUES(?, 'diff', 'status=IN_REVIEW|TO_REVIEW', ?, ?, ?)");
- massUpdate.execute((row, update, updateIndex) -> {
-
- if (updateIndex == 0) {
- update.setLong(1, row.getLong(1));
- } else if (updateIndex == 1) {
- long currentTime = system.now();
- update.setString(1, row.getString(2))
- .setLong(2, currentTime)
- .setLong(3, currentTime)
- .setLong(4, currentTime);
- }
- return true;
- });
- }
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.db.migration.version.v81;
-
-import java.sql.SQLException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.Database;
-import org.sonar.server.platform.db.migration.step.DataChange;
-import org.sonar.server.platform.db.migration.step.MassUpdate;
-
-import static org.sonar.api.issue.Issue.STATUS_TO_REVIEW;
-import static org.sonar.api.rules.RuleType.VULNERABILITY;
-
-public class MigrateManualVulnerabilitiesToSecurityHotSpots extends DataChange {
- private System2 system;
-
- public MigrateManualVulnerabilitiesToSecurityHotSpots(Database db, System2 system) {
- super(db);
- this.system = system;
- }
-
- @Override
- protected void execute(Context context) throws SQLException {
- MassUpdate updateIssues = context.prepareMassUpdate();
- updateIssues.select("select id, kee, project_uuid, component_uuid from issues where from_hotspot = ? and issue_type = ?")
- .setBoolean(1, true)
- .setInt(2, 3);
- updateIssues.update("update issues set issue_type = ?, status = ? where id = ? and from_hotspot = ? and issue_type = ?");
- updateIssues.update("insert into issue_changes(issue_key, change_type, change_data, created_at, updated_at, issue_change_creation_date) " +
- "VALUES(?, ?, ?, ?, ?, ?)");
-
- updateIssues.execute((row, update, updateIndex) -> {
- if (updateIndex == 0) {
- update.setInt(1, 4)
- .setString(2, STATUS_TO_REVIEW)
- .setLong(3, row.getLong(1))
- .setBoolean(4, true)
- .setInt(5, VULNERABILITY.getDbConstant());
- } else if (updateIndex == 1) {
- long currentTime = system.now();
- update.setString(1, row.getString(2))
- .setString(2, "diff")
- .setString(3, "type=VULNERABILITY|SECURITY_HOTSPOT,status=OPEN|TO_REVIEW")
- .setLong(4, currentTime)
- .setLong(5, currentTime)
- .setLong(6, currentTime);
- }
- return true;
- });
- }
-}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v81;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+public class RemoveNewsboxDismissHotspotsProperty extends DataChange {
+
+ public RemoveNewsboxDismissHotspotsProperty(Database db) {
+ super(db);
+ }
+
+ @Override
+ protected void execute(Context context) throws SQLException {
+ context.prepareUpsert("delete from user_properties where kee='newsbox.dismiss.hotspots'")
+ .execute()
+ .commit();
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v82;
+
+import org.sonar.server.platform.db.migration.step.MigrationStepRegistry;
+import org.sonar.server.platform.db.migration.version.DbVersion;
+
+public class DbVersion82 implements DbVersion {
+ @Override
+ public void addSteps(MigrationStepRegistry registry) {
+ registry
+ .add(3200, "Drop 'In Review' Security Hotspots status ", DropSecurityHotSpotsInReviewStatus.class)
+ .add(3201, "Migrate Manual Vulnerabilities to Security Hotspots ", MigrateManualVulnerabilitiesToSecurityHotSpots.class)
+ .add(3202, "Remove 'newsbox.dismiss.hotspots' user property", RemoveNewsboxDismissHotspotsProperty.class);
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v82;
+
+import java.sql.SQLException;
+import org.sonar.api.utils.System2;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DataChange;
+import org.sonar.server.platform.db.migration.step.MassUpdate;
+
+public class DropSecurityHotSpotsInReviewStatus extends DataChange {
+
+ private System2 system;
+
+ public DropSecurityHotSpotsInReviewStatus(Database db, System2 system) {
+ super(db);
+ this.system = system;
+ }
+
+ @Override
+ protected void execute(Context context) throws SQLException {
+ MassUpdate massUpdate = context.prepareMassUpdate();
+ massUpdate.select("select id,kee from issues where status = 'IN_REVIEW'");
+ massUpdate.update("update issues set status = 'TO_REVIEW' where id = ? and status = 'IN_REVIEW'");
+ massUpdate.update("insert into issue_changes(issue_key, change_type, change_data, created_at, updated_at, issue_change_creation_date) " +
+ "VALUES(?, 'diff', 'status=IN_REVIEW|TO_REVIEW', ?, ?, ?)");
+ massUpdate.execute((row, update, updateIndex) -> {
+
+ if (updateIndex == 0) {
+ update.setLong(1, row.getLong(1));
+ } else if (updateIndex == 1) {
+ long currentTime = system.now();
+ update.setString(1, row.getString(2))
+ .setLong(2, currentTime)
+ .setLong(3, currentTime)
+ .setLong(4, currentTime);
+ }
+ return true;
+ });
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v82;
+
+import java.sql.SQLException;
+import org.sonar.api.utils.System2;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DataChange;
+import org.sonar.server.platform.db.migration.step.MassUpdate;
+
+import static org.sonar.api.issue.Issue.STATUS_TO_REVIEW;
+import static org.sonar.api.rules.RuleType.VULNERABILITY;
+
+public class MigrateManualVulnerabilitiesToSecurityHotSpots extends DataChange {
+ private System2 system;
+
+ public MigrateManualVulnerabilitiesToSecurityHotSpots(Database db, System2 system) {
+ super(db);
+ this.system = system;
+ }
+
+ @Override
+ protected void execute(Context context) throws SQLException {
+ MassUpdate updateIssues = context.prepareMassUpdate();
+ updateIssues.select("select id, kee, project_uuid, component_uuid from issues where from_hotspot = ? and issue_type = ?")
+ .setBoolean(1, true)
+ .setInt(2, 3);
+ updateIssues.update("update issues set issue_type = ?, status = ? where id = ? and from_hotspot = ? and issue_type = ?");
+ updateIssues.update("insert into issue_changes(issue_key, change_type, change_data, created_at, updated_at, issue_change_creation_date) " +
+ "VALUES(?, ?, ?, ?, ?, ?)");
+
+ updateIssues.execute((row, update, updateIndex) -> {
+ if (updateIndex == 0) {
+ update.setInt(1, 4)
+ .setString(2, STATUS_TO_REVIEW)
+ .setLong(3, row.getLong(1))
+ .setBoolean(4, true)
+ .setInt(5, VULNERABILITY.getDbConstant());
+ } else if (updateIndex == 1) {
+ long currentTime = system.now();
+ update.setString(1, row.getString(2))
+ .setString(2, "diff")
+ .setString(3, "type=VULNERABILITY|SECURITY_HOTSPOT,status=OPEN|TO_REVIEW")
+ .setLong(4, currentTime)
+ .setLong(5, currentTime)
+ .setLong(6, currentTime);
+ }
+ return true;
+ });
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v82;
+
+import java.sql.SQLException;
+import org.sonar.db.Database;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+public class RemoveNewsboxDismissHotspotsProperty extends DataChange {
+
+ public RemoveNewsboxDismissHotspotsProperty(Database db) {
+ super(db);
+ }
+
+ @Override
+ protected void execute(Context context) throws SQLException {
+ context.prepareUpsert("delete from user_properties where kee='newsbox.dismiss.hotspots'")
+ .execute()
+ .commit();
+ }
+}
assertThat(container.getPicoContainer().getComponentAdapters())
.hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER
// DbVersion classes
- + 3
+ + 4
// Others
+ 4);
}
@Test
public void verify_migration_count() {
- verifyMigrationCount(underTest, 16);
+ verifyMigrationCount(underTest, 14);
}
}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.db.migration.version.v81;
-
-import java.sql.SQLException;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.CoreDbTester;
-import org.sonar.server.platform.db.migration.step.DataChange;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.api.issue.Issue.STATUSES;
-
-public class DropSecurityHotSpotsInReviewStatusTest {
-
- private final static String ISSUES_TABLE_NAME = "issues";
- private final static int NUMBER_OF_ISSUES_IN_REVIEW = 3;
-
- @Rule
- public CoreDbTester db = CoreDbTester.createForSchema(DropSecurityHotSpotsInReviewStatusTest.class, "schema.sql");
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- private System2 system2 = System2.INSTANCE;
-
- private DataChange underTest = new DropSecurityHotSpotsInReviewStatus(db.database(), system2);
-
- @Test
- public void should_change_IN_REVIEW_statuses_only() throws SQLException {
-
- Map<Integer, String> statuses = IntStream.range(0, STATUSES.size())
- .boxed()
- .collect(Collectors.toMap(Function.identity(), STATUSES::get));
-
- statuses.forEach(this::insertIssue);
-
- int startIndex = STATUSES.size();
- int endIndex = startIndex + NUMBER_OF_ISSUES_IN_REVIEW;
- IntStream.range(startIndex, endIndex).forEach(value -> insertIssue(value, "IN_REVIEW"));
-
- underTest.execute();
-
- IntStream.range(startIndex, endIndex).forEach(this::assertIssueChanged);
-
- statuses.forEach(this::assertIssueNotChanged);
-
- // should not fail if executed twice
- underTest.execute();
- }
-
- @Test
- public void should_not_fail_if_no_issues() throws SQLException {
- underTest.execute();
- assertThat(db.countRowsOfTable("issues")).isEqualTo(0);
- }
-
- private void assertIssueChanged(int issueId) {
- List<Map<String, Object>> row = db.select(String.format("select status from issues where kee = '%s'", "issue-key-" + issueId));
- assertThat(row).hasSize(1);
- assertThat(row.get(0).get("STATUS"))
- .isEqualTo("TO_REVIEW");
-
- List<Map<String, Object>> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" +
- " from issue_changes where issue_key = '%s'", "issue-key-" + issueId));
- assertThat(changelogRows).hasSize(1);
-
- Map<String, Object> changelogRow = changelogRows.get(0);
- assertThat(changelogRow.get("CHANGE_TYPE")).isEqualTo("diff");
- assertThat(changelogRow.get("CHANGE_DATA")).isEqualTo("status=IN_REVIEW|TO_REVIEW");
-
- assertThat(changelogRow.get("CREATED_AT")).isNotNull();
- assertThat(changelogRow.get("UPDATED_AT")).isNotNull();
- assertThat(changelogRow.get("ISSUE_CHANGE_CREATION_DATE")).isNotNull();
- }
-
- private void assertIssueNotChanged(int issueId, String expectedStatus) {
- List<Map<String, Object>> row = db.select(String.format("select status from issues where kee = '%s'", "issue-key-" + issueId));
- assertThat(row).hasSize(1);
- assertThat(row.get(0).get("STATUS"))
- .isEqualTo(expectedStatus);
-
- List<Map<String, Object>> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" +
- " from issue_changes where issue_key = '%s'", "issue-key-" + issueId));
- assertThat(changelogRows).isEmpty();
- }
-
- private void insertIssue(int issueId, String status) {
- db.executeInsert(ISSUES_TABLE_NAME,
- "kee", "issue-key-" + issueId,
- "status", status,
- "manual_severity", false);
- }
-
-}
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2020 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.server.platform.db.migration.version.v81;
-
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.sonar.api.utils.System2;
-import org.sonar.db.CoreDbTester;
-import org.sonar.server.platform.db.migration.step.DataChange;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.api.rules.RuleType.BUG;
-import static org.sonar.api.rules.RuleType.CODE_SMELL;
-import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT;
-import static org.sonar.api.rules.RuleType.VULNERABILITY;
-
-public class MigrateManualVulnerabilitiesToSecurityHotSpotsTest {
-
- private final static String ISSUES_TABLE_NAME = "issues";
- private final static int TOTAL_NUMBER_OF_ISSUES = 9;
-
- @Rule
- public CoreDbTester db = CoreDbTester.createForSchema(MigrateManualVulnerabilitiesToSecurityHotSpotsTest.class, "schema.sql");
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- private System2 system2 = System2.INSTANCE;
-
- private DataChange underTest = new MigrateManualVulnerabilitiesToSecurityHotSpots(db.database(), system2);
-
- @Test
- public void should_migrate_manual_vulnerabilities_only() throws SQLException {
- Random random = new Random();
- List<Integer> range = IntStream.range(0, TOTAL_NUMBER_OF_ISSUES).boxed()
- .collect(Collectors.toCollection(ArrayList::new));
- Collections.shuffle(range);
-
- insertIssue(range.get(0), CODE_SMELL.getDbConstant(), random.nextBoolean());
- insertIssue(range.get(1), BUG.getDbConstant(), random.nextBoolean());
- insertIssue(range.get(2), VULNERABILITY.getDbConstant(), false);
- insertIssue(range.get(3), SECURITY_HOTSPOT.getDbConstant(), random.nextBoolean());
- insertIssue(range.get(4), -1, random.nextBoolean());
-
- insertIssue(range.get(5), VULNERABILITY.getDbConstant(), true);
- insertIssue(range.get(6), VULNERABILITY.getDbConstant(), true);
- insertIssue(range.get(7), VULNERABILITY.getDbConstant(), true);
- insertIssue(range.get(8), VULNERABILITY.getDbConstant(), true);
-
- underTest.execute();
-
- assertIssueNotChanged(range.get(0), CODE_SMELL.getDbConstant());
- assertIssueNotChanged(range.get(1), BUG.getDbConstant());
- assertIssueNotChanged(range.get(2), VULNERABILITY.getDbConstant());
- assertIssueNotChanged(range.get(3), SECURITY_HOTSPOT.getDbConstant());
- assertIssueNotChanged(range.get(4), -1);
-
- assertIssueChanged(range.get(5));
- assertIssueChanged(range.get(6));
- assertIssueChanged(range.get(7));
- assertIssueChanged(range.get(8));
-
- // should not fail if executed twice
- underTest.execute();
- }
-
- @Test
- public void should_not_fail_if_no_issues() throws SQLException {
- underTest.execute();
- assertThat(db.countRowsOfTable("issues")).isEqualTo(0);
- }
-
- private void assertIssueChanged(int issueId) {
- List<Map<String, Object>> row = db.select(String.format("select status from issues where kee = '%s'", "issue-key-" + issueId));
- assertThat(row).hasSize(1);
- assertThat(row.get(0).get("STATUS"))
- .isEqualTo("TO_REVIEW");
-
- List<Map<String, Object>> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" +
- " from issue_changes where issue_key = '%s'", "issue-key-" + issueId));
- assertThat(changelogRows).hasSize(1);
-
- Map<String, Object> changelogRow = changelogRows.get(0);
- assertThat(changelogRow.get("CHANGE_TYPE")).isEqualTo("diff");
- assertThat(changelogRow.get("CHANGE_DATA")).isEqualTo("type=VULNERABILITY|SECURITY_HOTSPOT,status=OPEN|TO_REVIEW");
-
- assertThat(changelogRow.get("CREATED_AT")).isNotNull();
- assertThat(changelogRow.get("UPDATED_AT")).isNotNull();
- assertThat(changelogRow.get("ISSUE_CHANGE_CREATION_DATE")).isNotNull();
- }
-
- private void assertIssueNotChanged(int issueId, int expectedType) {
- List<Map<String, Object>> row = db.select(String.format("select issue_type, status from issues where kee = '%s'", "issue-key-" + issueId));
- assertThat(row).hasSize(1);
-
- Map<String, Object> issueData = row.get(0);
- assertThat(issueData.get("STATUS"))
- .isNull();
- assertThat(issueData.get("ISSUE_TYPE"))
- .isEqualTo(expectedType);
-
- List<Map<String, Object>> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" +
- " from issue_changes where issue_key = '%s'", "issue-key-" + issueId));
- assertThat(changelogRows).isEmpty();
- }
-
- private void insertIssue(int issueId, int issueType, boolean fromHotspot) {
- db.executeInsert(ISSUES_TABLE_NAME,
- "kee", "issue-key-" + issueId,
- "issue_type", issueType,
- "from_hotspot", fromHotspot,
- "manual_severity", false);
- }
-
-}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v81;
+
+import java.sql.SQLException;
+import java.time.Instant;
+import java.util.Random;
+import java.util.UUID;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.db.CoreDbTester;
+
+import static java.lang.String.format;
+import static org.junit.Assert.assertEquals;
+
+public class RemoveNewsboxDismissHotspotsPropertyTest {
+
+ private static final String USER_PROPERTIES_TABLE_NAME = "user_properties";
+ private static final int TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES = 10;
+
+ @Rule
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveNewsboxDismissHotspotsPropertyTest.class, "schema.sql");
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private Random random = new Random();
+
+ private RemoveNewsboxDismissHotspotsProperty underTest = new RemoveNewsboxDismissHotspotsProperty(dbTester.database());
+
+ @Before
+ public void setup() {
+ insertUserProperty("some-user-uuid", "some-property", random.nextBoolean());
+
+ for (int i = 1; i <= TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES; i++) {
+ insertUserProperty(format("user-uuid-%s", i), "newsbox.dismiss.hotspots", random.nextBoolean());
+ }
+
+ int propertiesCount = dbTester.countRowsOfTable(USER_PROPERTIES_TABLE_NAME);
+ assertEquals(TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES + 1, propertiesCount);
+ }
+
+ @Test
+ public void remove_newsbox_dismiss_hotspot_property() throws SQLException {
+ underTest.execute();
+
+ verifyResult();
+ }
+
+ @Test
+ public void migration_is_re_entrant() throws SQLException {
+ underTest.execute();
+ underTest.execute();
+
+ verifyResult();
+ }
+
+ private void verifyResult() {
+ int hotspotDismissPropertiesCount = dbTester.countSql("select count(uuid) from user_properties where kee = 'newsbox.dismiss.hotspots'");
+ assertEquals(0, hotspotDismissPropertiesCount);
+ int otherPropertiesCount = dbTester.countSql("select count(uuid) from user_properties where kee != 'newsbox.dismiss.hotspots'");
+ assertEquals(1, otherPropertiesCount);
+ }
+
+ private void insertUserProperty(String userUuid, String key, boolean value) {
+ dbTester.executeInsert(USER_PROPERTIES_TABLE_NAME,
+ "uuid", UUID.randomUUID().toString(),
+ "kee", key,
+ "user_uuid", userUuid,
+ "text_value", value,
+ "created_at", Instant.now().toEpochMilli(),
+ "updated_at", Instant.now().toEpochMilli());
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v82;
+
+import org.junit.Test;
+import org.sonar.server.platform.db.migration.version.DbVersion;
+
+import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMigrationCount;
+import static org.sonar.server.platform.db.migration.version.DbVersionTestUtils.verifyMinimumMigrationNumber;
+
+public class DbVersion82Test {
+
+ private DbVersion underTest = new DbVersion82();
+
+ @Test
+ public void migrationNumber_starts_at_3000() {
+ verifyMinimumMigrationNumber(underTest, 3200);
+ }
+
+ @Test
+ public void verify_migration_count() {
+ verifyMigrationCount(underTest, 3);
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v82;
+
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.utils.System2;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.api.issue.Issue.STATUSES;
+
+public class DropSecurityHotSpotsInReviewStatusTest {
+
+ private final static String ISSUES_TABLE_NAME = "issues";
+ private final static int NUMBER_OF_ISSUES_IN_REVIEW = 3;
+
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(DropSecurityHotSpotsInReviewStatusTest.class, "schema.sql");
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private System2 system2 = System2.INSTANCE;
+
+ private DataChange underTest = new DropSecurityHotSpotsInReviewStatus(db.database(), system2);
+
+ @Test
+ public void should_change_IN_REVIEW_statuses_only() throws SQLException {
+
+ Map<Integer, String> statuses = IntStream.range(0, STATUSES.size())
+ .boxed()
+ .collect(Collectors.toMap(Function.identity(), STATUSES::get));
+
+ statuses.forEach(this::insertIssue);
+
+ int startIndex = STATUSES.size();
+ int endIndex = startIndex + NUMBER_OF_ISSUES_IN_REVIEW;
+ IntStream.range(startIndex, endIndex).forEach(value -> insertIssue(value, "IN_REVIEW"));
+
+ underTest.execute();
+
+ IntStream.range(startIndex, endIndex).forEach(this::assertIssueChanged);
+
+ statuses.forEach(this::assertIssueNotChanged);
+
+ // should not fail if executed twice
+ underTest.execute();
+ }
+
+ @Test
+ public void should_not_fail_if_no_issues() throws SQLException {
+ underTest.execute();
+ assertThat(db.countRowsOfTable("issues")).isEqualTo(0);
+ }
+
+ private void assertIssueChanged(int issueId) {
+ List<Map<String, Object>> row = db.select(String.format("select status from issues where kee = '%s'", "issue-key-" + issueId));
+ assertThat(row).hasSize(1);
+ assertThat(row.get(0).get("STATUS"))
+ .isEqualTo("TO_REVIEW");
+
+ List<Map<String, Object>> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" +
+ " from issue_changes where issue_key = '%s'", "issue-key-" + issueId));
+ assertThat(changelogRows).hasSize(1);
+
+ Map<String, Object> changelogRow = changelogRows.get(0);
+ assertThat(changelogRow.get("CHANGE_TYPE")).isEqualTo("diff");
+ assertThat(changelogRow.get("CHANGE_DATA")).isEqualTo("status=IN_REVIEW|TO_REVIEW");
+
+ assertThat(changelogRow.get("CREATED_AT")).isNotNull();
+ assertThat(changelogRow.get("UPDATED_AT")).isNotNull();
+ assertThat(changelogRow.get("ISSUE_CHANGE_CREATION_DATE")).isNotNull();
+ }
+
+ private void assertIssueNotChanged(int issueId, String expectedStatus) {
+ List<Map<String, Object>> row = db.select(String.format("select status from issues where kee = '%s'", "issue-key-" + issueId));
+ assertThat(row).hasSize(1);
+ assertThat(row.get(0).get("STATUS"))
+ .isEqualTo(expectedStatus);
+
+ List<Map<String, Object>> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" +
+ " from issue_changes where issue_key = '%s'", "issue-key-" + issueId));
+ assertThat(changelogRows).isEmpty();
+ }
+
+ private void insertIssue(int issueId, String status) {
+ db.executeInsert(ISSUES_TABLE_NAME,
+ "kee", "issue-key-" + issueId,
+ "status", status,
+ "manual_severity", false);
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v82;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.api.utils.System2;
+import org.sonar.db.CoreDbTester;
+import org.sonar.server.platform.db.migration.step.DataChange;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.api.rules.RuleType.BUG;
+import static org.sonar.api.rules.RuleType.CODE_SMELL;
+import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT;
+import static org.sonar.api.rules.RuleType.VULNERABILITY;
+
+public class MigrateManualVulnerabilitiesToSecurityHotSpotsTest {
+
+ private final static String ISSUES_TABLE_NAME = "issues";
+ private final static int TOTAL_NUMBER_OF_ISSUES = 9;
+
+ @Rule
+ public CoreDbTester db = CoreDbTester.createForSchema(MigrateManualVulnerabilitiesToSecurityHotSpotsTest.class, "schema.sql");
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private System2 system2 = System2.INSTANCE;
+
+ private DataChange underTest = new MigrateManualVulnerabilitiesToSecurityHotSpots(db.database(), system2);
+
+ @Test
+ public void should_migrate_manual_vulnerabilities_only() throws SQLException {
+ Random random = new Random();
+ List<Integer> range = IntStream.range(0, TOTAL_NUMBER_OF_ISSUES).boxed()
+ .collect(Collectors.toCollection(ArrayList::new));
+ Collections.shuffle(range);
+
+ insertIssue(range.get(0), CODE_SMELL.getDbConstant(), random.nextBoolean());
+ insertIssue(range.get(1), BUG.getDbConstant(), random.nextBoolean());
+ insertIssue(range.get(2), VULNERABILITY.getDbConstant(), false);
+ insertIssue(range.get(3), SECURITY_HOTSPOT.getDbConstant(), random.nextBoolean());
+ insertIssue(range.get(4), -1, random.nextBoolean());
+
+ insertIssue(range.get(5), VULNERABILITY.getDbConstant(), true);
+ insertIssue(range.get(6), VULNERABILITY.getDbConstant(), true);
+ insertIssue(range.get(7), VULNERABILITY.getDbConstant(), true);
+ insertIssue(range.get(8), VULNERABILITY.getDbConstant(), true);
+
+ underTest.execute();
+
+ assertIssueNotChanged(range.get(0), CODE_SMELL.getDbConstant());
+ assertIssueNotChanged(range.get(1), BUG.getDbConstant());
+ assertIssueNotChanged(range.get(2), VULNERABILITY.getDbConstant());
+ assertIssueNotChanged(range.get(3), SECURITY_HOTSPOT.getDbConstant());
+ assertIssueNotChanged(range.get(4), -1);
+
+ assertIssueChanged(range.get(5));
+ assertIssueChanged(range.get(6));
+ assertIssueChanged(range.get(7));
+ assertIssueChanged(range.get(8));
+
+ // should not fail if executed twice
+ underTest.execute();
+ }
+
+ @Test
+ public void should_not_fail_if_no_issues() throws SQLException {
+ underTest.execute();
+ assertThat(db.countRowsOfTable("issues")).isEqualTo(0);
+ }
+
+ private void assertIssueChanged(int issueId) {
+ List<Map<String, Object>> row = db.select(String.format("select status from issues where kee = '%s'", "issue-key-" + issueId));
+ assertThat(row).hasSize(1);
+ assertThat(row.get(0).get("STATUS"))
+ .isEqualTo("TO_REVIEW");
+
+ List<Map<String, Object>> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" +
+ " from issue_changes where issue_key = '%s'", "issue-key-" + issueId));
+ assertThat(changelogRows).hasSize(1);
+
+ Map<String, Object> changelogRow = changelogRows.get(0);
+ assertThat(changelogRow.get("CHANGE_TYPE")).isEqualTo("diff");
+ assertThat(changelogRow.get("CHANGE_DATA")).isEqualTo("type=VULNERABILITY|SECURITY_HOTSPOT,status=OPEN|TO_REVIEW");
+
+ assertThat(changelogRow.get("CREATED_AT")).isNotNull();
+ assertThat(changelogRow.get("UPDATED_AT")).isNotNull();
+ assertThat(changelogRow.get("ISSUE_CHANGE_CREATION_DATE")).isNotNull();
+ }
+
+ private void assertIssueNotChanged(int issueId, int expectedType) {
+ List<Map<String, Object>> row = db.select(String.format("select issue_type, status from issues where kee = '%s'", "issue-key-" + issueId));
+ assertThat(row).hasSize(1);
+
+ Map<String, Object> issueData = row.get(0);
+ assertThat(issueData.get("STATUS"))
+ .isNull();
+ assertThat(issueData.get("ISSUE_TYPE"))
+ .isEqualTo(expectedType);
+
+ List<Map<String, Object>> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" +
+ " from issue_changes where issue_key = '%s'", "issue-key-" + issueId));
+ assertThat(changelogRows).isEmpty();
+ }
+
+ private void insertIssue(int issueId, int issueType, boolean fromHotspot) {
+ db.executeInsert(ISSUES_TABLE_NAME,
+ "kee", "issue-key-" + issueId,
+ "issue_type", issueType,
+ "from_hotspot", fromHotspot,
+ "manual_severity", false);
+ }
+
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.platform.db.migration.version.v82;
+
+import java.sql.SQLException;
+import java.time.Instant;
+import java.util.Random;
+import java.util.UUID;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.sonar.db.CoreDbTester;
+
+import static java.lang.String.format;
+import static org.junit.Assert.assertEquals;
+
+public class RemoveNewsboxDismissHotspotsPropertyTest {
+
+ private static final String USER_PROPERTIES_TABLE_NAME = "user_properties";
+ private static final int TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES = 10;
+
+ @Rule
+ public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveNewsboxDismissHotspotsPropertyTest.class, "schema.sql");
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private Random random = new Random();
+
+ private RemoveNewsboxDismissHotspotsProperty underTest = new RemoveNewsboxDismissHotspotsProperty(dbTester.database());
+
+ @Before
+ public void setup() {
+ insertUserProperty("some-user-uuid", "some-property", random.nextBoolean());
+
+ for (int i = 1; i <= TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES; i++) {
+ insertUserProperty(format("user-uuid-%s", i), "newsbox.dismiss.hotspots", random.nextBoolean());
+ }
+
+ int propertiesCount = dbTester.countRowsOfTable(USER_PROPERTIES_TABLE_NAME);
+ assertEquals(TOTAL_NUMBER_OF_HOTSPOTS_DISMISS_USER_PROPERTIES + 1, propertiesCount);
+ }
+
+ @Test
+ public void remove_newsbox_dismiss_hotspot_property() throws SQLException {
+ underTest.execute();
+
+ verifyResult();
+ }
+
+ @Test
+ public void migration_is_re_entrant() throws SQLException {
+ underTest.execute();
+ underTest.execute();
+
+ verifyResult();
+ }
+
+ private void verifyResult() {
+ int hotspotDismissPropertiesCount = dbTester.countSql("select count(uuid) from user_properties where kee = 'newsbox.dismiss.hotspots'");
+ assertEquals(0, hotspotDismissPropertiesCount);
+ int otherPropertiesCount = dbTester.countSql("select count(uuid) from user_properties where kee != 'newsbox.dismiss.hotspots'");
+ assertEquals(1, otherPropertiesCount);
+ }
+
+ private void insertUserProperty(String userUuid, String key, boolean value) {
+ dbTester.executeInsert(USER_PROPERTIES_TABLE_NAME,
+ "uuid", UUID.randomUUID().toString(),
+ "kee", key,
+ "user_uuid", userUuid,
+ "text_value", value,
+ "created_at", Instant.now().toEpochMilli(),
+ "updated_at", Instant.now().toEpochMilli());
+ }
+}
+++ /dev/null
-CREATE TABLE "ISSUES"(
- "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1),
- "KEE" VARCHAR(50) NOT NULL,
- "RULE_ID" INTEGER,
- "SEVERITY" VARCHAR(10),
- "MANUAL_SEVERITY" BOOLEAN NOT NULL,
- "MESSAGE" VARCHAR(4000),
- "LINE" INTEGER,
- "GAP" DOUBLE,
- "STATUS" VARCHAR(20),
- "RESOLUTION" VARCHAR(20),
- "CHECKSUM" VARCHAR(1000),
- "REPORTER" VARCHAR(255),
- "ASSIGNEE" VARCHAR(255),
- "AUTHOR_LOGIN" VARCHAR(255),
- "ACTION_PLAN_KEY" VARCHAR(50),
- "ISSUE_ATTRIBUTES" VARCHAR(4000),
- "EFFORT" INTEGER,
- "CREATED_AT" BIGINT,
- "UPDATED_AT" BIGINT,
- "ISSUE_CREATION_DATE" BIGINT,
- "ISSUE_UPDATE_DATE" BIGINT,
- "ISSUE_CLOSE_DATE" BIGINT,
- "TAGS" VARCHAR(4000),
- "COMPONENT_UUID" VARCHAR(50),
- "PROJECT_UUID" VARCHAR(50),
- "LOCATIONS" BLOB,
- "ISSUE_TYPE" TINYINT,
- "FROM_HOTSPOT" BOOLEAN
-);
-ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("ID");
-CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE");
-CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID");
-CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE");
-CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE");
-CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID");
-CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION");
-CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID");
-CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT");
-
-CREATE TABLE "ISSUE_CHANGES"(
- "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1),
- "KEE" VARCHAR(50),
- "ISSUE_KEY" VARCHAR(50) NOT NULL,
- "USER_LOGIN" VARCHAR(255),
- "CHANGE_TYPE" VARCHAR(20),
- "CHANGE_DATA" CLOB(2147483647),
- "CREATED_AT" BIGINT,
- "UPDATED_AT" BIGINT,
- "ISSUE_CHANGE_CREATION_DATE" BIGINT
-);
-ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID");
-CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY");
-CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE");
+++ /dev/null
-CREATE TABLE "ISSUES"(
- "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1),
- "KEE" VARCHAR(50) NOT NULL,
- "RULE_ID" INTEGER,
- "SEVERITY" VARCHAR(10),
- "MANUAL_SEVERITY" BOOLEAN NOT NULL,
- "MESSAGE" VARCHAR(4000),
- "LINE" INTEGER,
- "GAP" DOUBLE,
- "STATUS" VARCHAR(20),
- "RESOLUTION" VARCHAR(20),
- "CHECKSUM" VARCHAR(1000),
- "REPORTER" VARCHAR(255),
- "ASSIGNEE" VARCHAR(255),
- "AUTHOR_LOGIN" VARCHAR(255),
- "ACTION_PLAN_KEY" VARCHAR(50),
- "ISSUE_ATTRIBUTES" VARCHAR(4000),
- "EFFORT" INTEGER,
- "CREATED_AT" BIGINT,
- "UPDATED_AT" BIGINT,
- "ISSUE_CREATION_DATE" BIGINT,
- "ISSUE_UPDATE_DATE" BIGINT,
- "ISSUE_CLOSE_DATE" BIGINT,
- "TAGS" VARCHAR(4000),
- "COMPONENT_UUID" VARCHAR(50),
- "PROJECT_UUID" VARCHAR(50),
- "LOCATIONS" BLOB,
- "ISSUE_TYPE" TINYINT,
- "FROM_HOTSPOT" BOOLEAN
-);
-ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("ID");
-CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE");
-CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID");
-CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE");
-CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE");
-CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID");
-CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION");
-CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID");
-CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT");
-
-CREATE TABLE "ISSUE_CHANGES"(
- "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1),
- "KEE" VARCHAR(50),
- "ISSUE_KEY" VARCHAR(50) NOT NULL,
- "USER_LOGIN" VARCHAR(255),
- "CHANGE_TYPE" VARCHAR(20),
- "CHANGE_DATA" CLOB(2147483647),
- "CREATED_AT" BIGINT,
- "UPDATED_AT" BIGINT,
- "ISSUE_CHANGE_CREATION_DATE" BIGINT
-);
-ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID");
-CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY");
-CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE");
--- /dev/null
+CREATE TABLE "USER_PROPERTIES" (
+ "UUID" VARCHAR(40) NOT NULL,
+ "USER_UUID" VARCHAR(255) NOT NULL,
+ "KEE" VARCHAR(100) NOT NULL,
+ "TEXT_VALUE" VARCHAR(4000) NOT NULL,
+ "CREATED_AT" BIGINT NOT NULL,
+ "UPDATED_AT" BIGINT NOT NULL,
+
+ CONSTRAINT "PK_USER_PROPERTIES" PRIMARY KEY ("UUID")
+);
+CREATE UNIQUE INDEX "USER_PROPERTIES_USER_UUID_KEE" ON "USER_PROPERTIES" ("USER_UUID", "KEE");
--- /dev/null
+CREATE TABLE "ISSUES"(
+ "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1),
+ "KEE" VARCHAR(50) NOT NULL,
+ "RULE_ID" INTEGER,
+ "SEVERITY" VARCHAR(10),
+ "MANUAL_SEVERITY" BOOLEAN NOT NULL,
+ "MESSAGE" VARCHAR(4000),
+ "LINE" INTEGER,
+ "GAP" DOUBLE,
+ "STATUS" VARCHAR(20),
+ "RESOLUTION" VARCHAR(20),
+ "CHECKSUM" VARCHAR(1000),
+ "REPORTER" VARCHAR(255),
+ "ASSIGNEE" VARCHAR(255),
+ "AUTHOR_LOGIN" VARCHAR(255),
+ "ACTION_PLAN_KEY" VARCHAR(50),
+ "ISSUE_ATTRIBUTES" VARCHAR(4000),
+ "EFFORT" INTEGER,
+ "CREATED_AT" BIGINT,
+ "UPDATED_AT" BIGINT,
+ "ISSUE_CREATION_DATE" BIGINT,
+ "ISSUE_UPDATE_DATE" BIGINT,
+ "ISSUE_CLOSE_DATE" BIGINT,
+ "TAGS" VARCHAR(4000),
+ "COMPONENT_UUID" VARCHAR(50),
+ "PROJECT_UUID" VARCHAR(50),
+ "LOCATIONS" BLOB,
+ "ISSUE_TYPE" TINYINT,
+ "FROM_HOTSPOT" BOOLEAN
+);
+ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("ID");
+CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE");
+CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID");
+CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE");
+CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE");
+CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID");
+CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION");
+CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID");
+CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT");
+
+CREATE TABLE "ISSUE_CHANGES"(
+ "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1),
+ "KEE" VARCHAR(50),
+ "ISSUE_KEY" VARCHAR(50) NOT NULL,
+ "USER_LOGIN" VARCHAR(255),
+ "CHANGE_TYPE" VARCHAR(20),
+ "CHANGE_DATA" CLOB(2147483647),
+ "CREATED_AT" BIGINT,
+ "UPDATED_AT" BIGINT,
+ "ISSUE_CHANGE_CREATION_DATE" BIGINT
+);
+ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID");
+CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY");
+CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE");
--- /dev/null
+CREATE TABLE "ISSUES"(
+ "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1),
+ "KEE" VARCHAR(50) NOT NULL,
+ "RULE_ID" INTEGER,
+ "SEVERITY" VARCHAR(10),
+ "MANUAL_SEVERITY" BOOLEAN NOT NULL,
+ "MESSAGE" VARCHAR(4000),
+ "LINE" INTEGER,
+ "GAP" DOUBLE,
+ "STATUS" VARCHAR(20),
+ "RESOLUTION" VARCHAR(20),
+ "CHECKSUM" VARCHAR(1000),
+ "REPORTER" VARCHAR(255),
+ "ASSIGNEE" VARCHAR(255),
+ "AUTHOR_LOGIN" VARCHAR(255),
+ "ACTION_PLAN_KEY" VARCHAR(50),
+ "ISSUE_ATTRIBUTES" VARCHAR(4000),
+ "EFFORT" INTEGER,
+ "CREATED_AT" BIGINT,
+ "UPDATED_AT" BIGINT,
+ "ISSUE_CREATION_DATE" BIGINT,
+ "ISSUE_UPDATE_DATE" BIGINT,
+ "ISSUE_CLOSE_DATE" BIGINT,
+ "TAGS" VARCHAR(4000),
+ "COMPONENT_UUID" VARCHAR(50),
+ "PROJECT_UUID" VARCHAR(50),
+ "LOCATIONS" BLOB,
+ "ISSUE_TYPE" TINYINT,
+ "FROM_HOTSPOT" BOOLEAN
+);
+ALTER TABLE "ISSUES" ADD CONSTRAINT "PK_ISSUES" PRIMARY KEY("ID");
+CREATE INDEX "ISSUES_ASSIGNEE" ON "ISSUES"("ASSIGNEE");
+CREATE INDEX "ISSUES_COMPONENT_UUID" ON "ISSUES"("COMPONENT_UUID");
+CREATE INDEX "ISSUES_CREATION_DATE" ON "ISSUES"("ISSUE_CREATION_DATE");
+CREATE UNIQUE INDEX "ISSUES_KEE" ON "ISSUES"("KEE");
+CREATE INDEX "ISSUES_PROJECT_UUID" ON "ISSUES"("PROJECT_UUID");
+CREATE INDEX "ISSUES_RESOLUTION" ON "ISSUES"("RESOLUTION");
+CREATE INDEX "ISSUES_RULE_ID" ON "ISSUES"("RULE_ID");
+CREATE INDEX "ISSUES_UPDATED_AT" ON "ISSUES"("UPDATED_AT");
+
+CREATE TABLE "ISSUE_CHANGES"(
+ "ID" BIGINT NOT NULL AUTO_INCREMENT (1,1),
+ "KEE" VARCHAR(50),
+ "ISSUE_KEY" VARCHAR(50) NOT NULL,
+ "USER_LOGIN" VARCHAR(255),
+ "CHANGE_TYPE" VARCHAR(20),
+ "CHANGE_DATA" CLOB(2147483647),
+ "CREATED_AT" BIGINT,
+ "UPDATED_AT" BIGINT,
+ "ISSUE_CHANGE_CREATION_DATE" BIGINT
+);
+ALTER TABLE "ISSUE_CHANGES" ADD CONSTRAINT "PK_ISSUE_CHANGES" PRIMARY KEY("ID");
+CREATE INDEX "ISSUE_CHANGES_ISSUE_KEY" ON "ISSUE_CHANGES"("ISSUE_KEY");
+CREATE INDEX "ISSUE_CHANGES_KEE" ON "ISSUE_CHANGES"("KEE");
--- /dev/null
+CREATE TABLE "USER_PROPERTIES" (
+ "UUID" VARCHAR(40) NOT NULL,
+ "USER_UUID" VARCHAR(255) NOT NULL,
+ "KEE" VARCHAR(100) NOT NULL,
+ "TEXT_VALUE" VARCHAR(4000) NOT NULL,
+ "CREATED_AT" BIGINT NOT NULL,
+ "UPDATED_AT" BIGINT NOT NULL,
+
+ CONSTRAINT "PK_USER_PROPERTIES" PRIMARY KEY ("UUID")
+);
+CREATE UNIQUE INDEX "USER_PROPERTIES_USER_UUID_KEE" ON "USER_PROPERTIES" ("USER_UUID", "KEE");
.setRequired(true)
.setMaximumLength(100)
.setDescription("Setting key")
- .setPossibleValues("notifications.optOut", UserUpdater.NOTIFICATIONS_READ_DATE, "newsbox.dismiss.hotspots");
+ .setPossibleValues("notifications.optOut", UserUpdater.NOTIFICATIONS_READ_DATE);
action.createParam(PARAM_VALUE)
.setRequired(true)
.setParam("value", "true")
.execute();
- ws.newRequest()
- .setParam("key", "newsbox.dismiss.hotspots")
- .setParam("value", "true")
- .execute();
-
assertThat(db.getDbClient().userPropertiesDao().selectByUser(db.getSession(), user))
.extracting(UserPropertyDto::getKey, UserPropertyDto::getValue)
.containsExactlyInAnyOrder(
tuple("notifications.readDate", "1234"),
- tuple("notifications.optOut", "true"),
- tuple("newsbox.dismiss.hotspots", "true"));
+ tuple("notifications.optOut", "true"));
}
@Test
assertThat(definition.param("key").possibleValues()).containsExactlyInAnyOrder(
"notifications.optOut",
- "notifications.readDate",
- "newsbox.dismiss.hotspots");
+ "notifications.readDate");
}
}