Browse Source

SONAR-12723 remove 'newsbox.dismiss.hotspots' user property

tags/8.2.0.32929
Jacek 4 years ago
parent
commit
0a4354287f
21 changed files with 372 additions and 20 deletions
  1. 1
    1
      server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
  2. 2
    0
      server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java
  3. 1
    3
      server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java
  4. 38
    0
      server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsProperty.java
  5. 33
    0
      server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82.java
  6. 1
    1
      server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatus.java
  7. 1
    1
      server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpots.java
  8. 38
    0
      server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsProperty.java
  9. 1
    1
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/MigrationConfigurationModuleTest.java
  10. 1
    1
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java
  11. 93
    0
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest.java
  12. 42
    0
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82Test.java
  13. 1
    1
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest.java
  14. 1
    1
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java
  15. 93
    0
      server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest.java
  16. 11
    0
      server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql
  17. 0
    0
      server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest/schema.sql
  18. 0
    0
      server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest/schema.sql
  19. 11
    0
      server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql
  20. 1
    1
      server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SetSettingAction.java
  21. 2
    9
      server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/SetSettingActionTest.java

+ 1
- 1
server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java View File

@@ -122,7 +122,7 @@ public class ComputeEngineContainerImplTest {
);
assertThat(picoContainer.getParent().getParent().getComponentAdapters()).hasSize(
CONTAINER_ITSELF
+ 6 // MigrationConfigurationModule
+ 7 // MigrationConfigurationModule
+ 16 // level 2
);
assertThat(picoContainer.getParent().getParent().getParent().getComponentAdapters()).hasSize(

+ 2
- 0
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/MigrationConfigurationModule.java View File

@@ -27,6 +27,7 @@ import org.sonar.server.platform.db.migration.step.MigrationStepsProvider;
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
@@ -36,6 +37,7 @@ public class MigrationConfigurationModule extends Module {
DbVersion00.class,
DbVersion80.class,
DbVersion81.class,
DbVersion82.class,

// migration steps
MigrationStepRegistryImpl.class,

+ 1
- 3
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81.java View File

@@ -42,8 +42,6 @@ public class DbVersion81 implements DbVersion {
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);
}
}

+ 38
- 0
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsProperty.java View File

@@ -0,0 +1,38 @@
/*
* 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();
}
}

+ 33
- 0
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82.java View File

@@ -0,0 +1,33 @@
/*
* 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);
}
}

server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/DropSecurityHotSpotsInReviewStatus.java → server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatus.java View File

@@ -17,7 +17,7 @@
* 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;
package org.sonar.server.platform.db.migration.version.v82;

import java.sql.SQLException;
import org.sonar.api.utils.System2;

server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v81/MigrateManualVulnerabilitiesToSecurityHotSpots.java → server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpots.java View File

@@ -17,7 +17,7 @@
* 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;
package org.sonar.server.platform.db.migration.version.v82;

import java.sql.SQLException;
import org.sonar.api.utils.System2;

+ 38
- 0
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsProperty.java View File

@@ -0,0 +1,38 @@
/*
* 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();
}
}

+ 1
- 1
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/MigrationConfigurationModuleTest.java View File

@@ -37,7 +37,7 @@ public class MigrationConfigurationModuleTest {
assertThat(container.getPicoContainer().getComponentAdapters())
.hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER
// DbVersion classes
+ 3
+ 4
// Others
+ 4);
}

+ 1
- 1
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DbVersion81Test.java View File

@@ -36,7 +36,7 @@ public class DbVersion81Test {

@Test
public void verify_migration_count() {
verifyMigrationCount(underTest, 16);
verifyMigrationCount(underTest, 14);
}

}

+ 93
- 0
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest.java View File

@@ -0,0 +1,93 @@
/*
* 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());
}
}

+ 42
- 0
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DbVersion82Test.java View File

@@ -0,0 +1,42 @@
/*
* 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);
}

}

server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/DropSecurityHotSpotsInReviewStatusTest.java → server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest.java View File

@@ -17,7 +17,7 @@
* 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;
package org.sonar.server.platform.db.migration.version.v82;

import java.sql.SQLException;
import java.util.List;

server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v81/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java → server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java View File

@@ -17,7 +17,7 @@
* 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;
package org.sonar.server.platform.db.migration.version.v82;

import java.sql.SQLException;
import java.util.ArrayList;

+ 93
- 0
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest.java View File

@@ -0,0 +1,93 @@
/*
* 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());
}
}

+ 11
- 0
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql View File

@@ -0,0 +1,11 @@
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");

server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/DropSecurityHotSpotsInReviewStatusTest/schema.sql → server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest/schema.sql View File


server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v81/MigrateManualVulnerabilitiesToSecurityHotSpotsTest/schema.sql → server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest/schema.sql View File


+ 11
- 0
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v82/RemoveNewsboxDismissHotspotsPropertyTest/schema.sql View File

@@ -0,0 +1,11 @@
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");

+ 1
- 1
server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SetSettingAction.java View File

@@ -57,7 +57,7 @@ public class SetSettingAction implements UsersWsAction {
.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)

+ 2
- 9
server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/SetSettingActionTest.java View File

@@ -91,17 +91,11 @@ public class SetSettingActionTest {
.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
@@ -131,8 +125,7 @@ public class SetSettingActionTest {

assertThat(definition.param("key").possibleValues()).containsExactlyInAnyOrder(
"notifications.optOut",
"notifications.readDate",
"newsbox.dismiss.hotspots");
"notifications.readDate");
}

}

Loading…
Cancel
Save