From 201d5326c5e4471a1a77243cd2bd4ac71c9d4ada Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 8 Jul 2022 16:28:19 +0200 Subject: SONAR-16598 Rename generic concept to education principles --- build.gradle | 2 +- .../org/sonar/xoo/rule/XooRulesDefinition.java | 2 +- .../src/main/java/org/sonar/db/rule/RuleDto.java | 10 ++-- .../resources/org/sonar/db/rule/RuleMapper.xml | 8 ++-- server/sonar-db-dao/src/schema/schema-sq.ddl | 2 +- .../test/java/org/sonar/db/rule/RuleDaoTest.java | 2 +- .../java/org/sonar/db/rule/RuleTesting.java | 2 +- .../AddEducationPrinciplesColumnToRuleTable.java | 52 ++++++++++++++++++++ .../v96/AddGenericConceptsColumnToRuleTable.java | 52 -------------------- .../db/migration/version/v96/DbVersion96.java | 2 +- ...ddEducationPrinciplesColumnToRuleTableTest.java | 56 ++++++++++++++++++++++ .../AddGenericConceptsColumnToRuleTableTest.java | 56 ---------------------- .../schema.sql | 40 ++++++++++++++++ .../schema.sql | 40 ---------------- .../java/org/sonar/server/rule/RegisterRules.java | 14 +++--- .../org/sonar/server/rule/RegisterRulesTest.java | 10 ++-- .../java/org/sonar/server/rule/ws/RuleMapper.java | 10 ++-- .../sonar/server/rule/ws/RulesWsParameters.java | 4 +- .../org/sonar/server/rule/ws/SearchAction.java | 2 +- .../java/org/sonar/server/rule/ws/ShowAction.java | 2 +- .../org/sonar/server/user/ws/CurrentAction.java | 4 +- .../sonar/server/user/ws/DismissNoticeAction.java | 6 +-- .../org/sonar/server/rule/ws/SearchActionTest.java | 4 +- .../org/sonar/server/rule/ws/ShowActionTest.java | 2 +- .../sonar/server/user/ws/CurrentActionTest.java | 10 ++-- .../server/user/ws/DismissNoticeActionTest.java | 14 +++--- sonar-ws/src/main/protobuf/ws-rules.proto | 6 +-- 27 files changed, 207 insertions(+), 207 deletions(-) create mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/AddEducationPrinciplesColumnToRuleTable.java delete mode 100644 server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTable.java create mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/AddEducationPrinciplesColumnToRuleTableTest.java delete mode 100644 server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest.java create mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/AddEducationPrinciplesColumnToRuleTableTest/schema.sql delete mode 100644 server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest/schema.sql diff --git a/build.gradle b/build.gradle index eb7be4f63b3..9339b64e526 100644 --- a/build.gradle +++ b/build.gradle @@ -178,7 +178,7 @@ subprojects { dependency 'org.sonarsource.kotlin:sonar-kotlin-plugin:2.9.0.1147' dependency 'org.sonarsource.slang:sonar-ruby-plugin:1.9.0.3429' dependency 'org.sonarsource.slang:sonar-scala-plugin:1.9.0.3429' - dependency 'org.sonarsource.api.plugin:sonar-plugin-api:9.8.0.196' + dependency 'org.sonarsource.api.plugin:sonar-plugin-api:9.8.0.203' dependency 'org.sonarsource.xml:sonar-xml-plugin:2.5.0.3376' dependency 'org.sonarsource.iac:sonar-iac-plugin:1.7.0.2012' dependency 'org.sonarsource.text:sonar-text-plugin:1.1.0.282' diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java index 17860487d38..24547887632 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java @@ -120,7 +120,7 @@ public class XooRulesDefinition implements RulesDefinition { oneIssuePerLine .setDebtRemediationFunction(oneIssuePerLine.debtRemediationFunctions().linear("1min")) .setGapDescription("It takes about 1 minute to an experienced software craftsman to remove a line of code") - .addGenericConceptKeys("defense_in_depth", "least_trust_principle"); + .addEducationPrincipleKeys("defense_in_depth", "least_trust_principle"); NewRule oneQuickFixPerLine = repo.createRule(OneQuickFixPerLineSensor.RULE_KEY).setName("One Quick Fix Per Line") .setTags("line"); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDto.java index c3809c2ded6..79446dc84b6 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/rule/RuleDto.java @@ -60,7 +60,7 @@ public class RuleDto { private String ruleKey = null; private final Set ruleDescriptionSectionDtos = new HashSet<>(); - private String genericConceptsField = null; + private String educationPrinciplesField = null; /** * Description format can be null on external rule, otherwise it should never be null @@ -237,12 +237,12 @@ public class RuleDto { return Objects.equals(contextKey, otherContextKey); } - public Set getGenericConcepts() { - return deserializeStringSet(genericConceptsField); + public Set getEducationPrinciples() { + return deserializeStringSet(educationPrinciplesField); } - public RuleDto setGenericConcepts(Set genericConcepts){ - this.genericConceptsField = serializeStringSet(genericConcepts); + public RuleDto setEducationPrinciples(Set educationPrinciples){ + this.educationPrinciplesField = serializeStringSet(educationPrinciples); return this; } diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml index 4ccbfe93651..fcd120cd8b5 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/rule/RuleMapper.xml @@ -39,7 +39,7 @@ r.ad_hoc_description as "adHocDescription", r.ad_hoc_severity as "adHocSeverity", r.ad_hoc_type as "adHocType", - r.generic_concepts as "genericConceptsField" + r.education_principles as "educationPrinciplesField" @@ -273,7 +273,7 @@ ad_hoc_description, ad_hoc_severity, ad_hoc_type, - generic_concepts, + education_principles, created_at, updated_at ) @@ -312,7 +312,7 @@ #{adHocDescription,jdbcType=CLOB}, #{adHocSeverity,jdbcType=VARCHAR}, #{adHocType,jdbcType=TINYINT}, - #{genericConceptsField,jdbcType=VARCHAR}, + #{educationPrinciplesField,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT} ) @@ -353,7 +353,7 @@ ad_hoc_description=#{adHocDescription,jdbcType=CLOB}, ad_hoc_severity=#{adHocSeverity,jdbcType=VARCHAR}, ad_hoc_type=#{adHocType,jdbcType=TINYINT}, - generic_concepts=#{genericConceptsField,jdbcType=VARCHAR}, + education_principles=#{educationPrinciplesField,jdbcType=VARCHAR}, updated_at=#{updatedAt,jdbcType=BIGINT} where uuid=#{uuid,jdbcType=VARCHAR} diff --git a/server/sonar-db-dao/src/schema/schema-sq.ddl b/server/sonar-db-dao/src/schema/schema-sq.ddl index 4c236994232..a9cfa3c66ad 100644 --- a/server/sonar-db-dao/src/schema/schema-sq.ddl +++ b/server/sonar-db-dao/src/schema/schema-sq.ddl @@ -865,7 +865,7 @@ CREATE TABLE "RULES"( "AD_HOC_DESCRIPTION" CHARACTER LARGE OBJECT, "AD_HOC_SEVERITY" CHARACTER VARYING(10), "AD_HOC_TYPE" TINYINT, - "GENERIC_CONCEPTS" CHARACTER VARYING(255) + "EDUCATION_PRINCIPLES" CHARACTER VARYING(255) ); ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("UUID"); CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY" NULLS FIRST, "PLUGIN_NAME" NULLS FIRST); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java index c26aea06e57..706fefe8adf 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java @@ -237,7 +237,7 @@ public class RuleDaoTest { assertThat(actual.getAdHocType()).isEqualTo(expected.getAdHocType()); assertThat(actual.getRuleDescriptionSectionDtos()).usingRecursiveFieldByFieldElementComparator() .containsExactlyInAnyOrderElementsOf(expected.getRuleDescriptionSectionDtos()); - assertThat(actual.getGenericConcepts()).isEqualTo(expected.getGenericConcepts()); + assertThat(actual.getEducationPrinciples()).isEqualTo(expected.getEducationPrinciples()); } @Test diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java index 87e7ed0dde5..9fd58793de7 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java @@ -119,7 +119,7 @@ public class RuleTesting { .setCreatedAt(currentTimeMillis) .setUpdatedAt(currentTimeMillis + 5) .setScope(Scope.MAIN) - .setGenericConcepts(Set.of(randomAlphanumeric(5), randomAlphanumeric(5))); + .setEducationPrinciples(Set.of(randomAlphanumeric(5), randomAlphanumeric(5))); } public static RuleParamDto newRuleParam(RuleDto rule) { diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/AddEducationPrinciplesColumnToRuleTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/AddEducationPrinciplesColumnToRuleTable.java new file mode 100644 index 00000000000..fccc0491eb2 --- /dev/null +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/AddEducationPrinciplesColumnToRuleTable.java @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 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.v96; + +import java.sql.Connection; +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.DatabaseUtils; +import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; +import org.sonar.server.platform.db.migration.step.DdlChange; + +import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddEducationPrinciplesColumnToRuleTable extends DdlChange { + + static final String COLUMN_EDUCATION_PRINCIPLES_KEY = "education_principles"; + + static final String RULE_TABLE = "rules"; + + public AddEducationPrinciplesColumnToRuleTable(Database db) { + super(db); + } + + @Override + public void execute(DdlChange.Context context) throws SQLException { + try (Connection connection = getDatabase().getDataSource().getConnection()) { + if (!DatabaseUtils.tableColumnExists(connection, RULE_TABLE, COLUMN_EDUCATION_PRINCIPLES_KEY)) { + context.execute(new AddColumnsBuilder(getDialect(), RULE_TABLE) + .addColumn(newVarcharColumnDefBuilder().setColumnName(COLUMN_EDUCATION_PRINCIPLES_KEY).setIsNullable(true).setLimit(255).build()) + .build()); + } + } + } + +} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTable.java deleted file mode 100644 index 5011ca61b20..00000000000 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTable.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2022 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.v96; - -import java.sql.Connection; -import java.sql.SQLException; -import org.sonar.db.Database; -import org.sonar.db.DatabaseUtils; -import org.sonar.server.platform.db.migration.sql.AddColumnsBuilder; -import org.sonar.server.platform.db.migration.step.DdlChange; - -import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; - -public class AddGenericConceptsColumnToRuleTable extends DdlChange { - - static final String COLUMN_GENERIC_CONCEPTS_KEY = "generic_concepts"; - - static final String RULE_TABLE = "rules"; - - public AddGenericConceptsColumnToRuleTable(Database db) { - super(db); - } - - @Override - public void execute(DdlChange.Context context) throws SQLException { - try (Connection connection = getDatabase().getDataSource().getConnection()) { - if (!DatabaseUtils.tableColumnExists(connection, RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY)) { - context.execute(new AddColumnsBuilder(getDialect(), RULE_TABLE) - .addColumn(newVarcharColumnDefBuilder().setColumnName(COLUMN_GENERIC_CONCEPTS_KEY).setIsNullable(true).setLimit(255).build()) - .build()); - } - } - } - -} diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/DbVersion96.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/DbVersion96.java index faa531201a4..5a473258ad5 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/DbVersion96.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v96/DbVersion96.java @@ -33,7 +33,7 @@ public class DbVersion96 implements DbVersion { .add(6503, "Create unique uniq_rule_desc_sections", CreateIndexForRuleDescSections.class) .add(6504, "Add column 'expiration_date' to 'user_tokens'", AddExpirationDateColumnToUserTokens.class) .add(6505, "Add column 'rule_description_context_key' to 'issues'", AddRuleDescriptionContextKeyInIssuesTable.class) - .add(6506, "Add column 'generic_concepts' to 'rules'", AddGenericConceptsColumnToRuleTable.class) + .add(6506, "Add column 'education_principles' to 'rules'", AddEducationPrinciplesColumnToRuleTable.class) ; } } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/AddEducationPrinciplesColumnToRuleTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/AddEducationPrinciplesColumnToRuleTableTest.java new file mode 100644 index 00000000000..e296073a4e9 --- /dev/null +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/AddEducationPrinciplesColumnToRuleTableTest.java @@ -0,0 +1,56 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 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.v96; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.db.CoreDbTester; + +import static org.sonar.db.CoreDbTester.createForSchema; +import static org.sonar.server.platform.db.migration.version.v96.AddEducationPrinciplesColumnToRuleTable.COLUMN_EDUCATION_PRINCIPLES_KEY; +import static org.sonar.server.platform.db.migration.version.v96.AddEducationPrinciplesColumnToRuleTable.RULE_TABLE; + +public class AddEducationPrinciplesColumnToRuleTableTest { + @Rule + public final CoreDbTester db = createForSchema(AddEducationPrinciplesColumnToRuleTableTest.class, "schema.sql"); + + private final AddEducationPrinciplesColumnToRuleTable addEducationPrinciplesColumnToRuleTable = new AddEducationPrinciplesColumnToRuleTable(db.database()); + + @Test + public void column_education_principles_should_be_added() throws SQLException { + db.assertColumnDoesNotExist(RULE_TABLE, COLUMN_EDUCATION_PRINCIPLES_KEY); + + addEducationPrinciplesColumnToRuleTable.execute(); + + db.assertColumnDefinition(RULE_TABLE, COLUMN_EDUCATION_PRINCIPLES_KEY, Types.VARCHAR, 255, true); + } + + @Test + public void migration_should_be_reentrant() throws SQLException { + db.assertColumnDoesNotExist(RULE_TABLE, COLUMN_EDUCATION_PRINCIPLES_KEY); + + addEducationPrinciplesColumnToRuleTable.execute(); + addEducationPrinciplesColumnToRuleTable.execute(); + + db.assertColumnDefinition(RULE_TABLE, COLUMN_EDUCATION_PRINCIPLES_KEY, Types.VARCHAR, 255, true); + } +} diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest.java deleted file mode 100644 index 4bcc490f6ce..00000000000 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2022 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.v96; - -import java.sql.SQLException; -import java.sql.Types; -import org.junit.Rule; -import org.junit.Test; -import org.sonar.db.CoreDbTester; - -import static org.sonar.db.CoreDbTester.createForSchema; -import static org.sonar.server.platform.db.migration.version.v96.AddGenericConceptsColumnToRuleTable.COLUMN_GENERIC_CONCEPTS_KEY; -import static org.sonar.server.platform.db.migration.version.v96.AddGenericConceptsColumnToRuleTable.RULE_TABLE; - -public class AddGenericConceptsColumnToRuleTableTest { - @Rule - public final CoreDbTester db = createForSchema(AddGenericConceptsColumnToRuleTableTest.class, "schema.sql"); - - private final AddGenericConceptsColumnToRuleTable addGenericConceptsColumnToRuleTable = new AddGenericConceptsColumnToRuleTable(db.database()); - - @Test - public void column_generic_concepts_should_be_added() throws SQLException { - db.assertColumnDoesNotExist(RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY); - - addGenericConceptsColumnToRuleTable.execute(); - - db.assertColumnDefinition(RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY, Types.VARCHAR, 255, true); - } - - @Test - public void migration_should_be_reentrant() throws SQLException { - db.assertColumnDoesNotExist(RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY); - - addGenericConceptsColumnToRuleTable.execute(); - addGenericConceptsColumnToRuleTable.execute(); - - db.assertColumnDefinition(RULE_TABLE, COLUMN_GENERIC_CONCEPTS_KEY, Types.VARCHAR, 255, true); - } -} diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/AddEducationPrinciplesColumnToRuleTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/AddEducationPrinciplesColumnToRuleTableTest/schema.sql new file mode 100644 index 00000000000..8346f94d192 --- /dev/null +++ b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/AddEducationPrinciplesColumnToRuleTableTest/schema.sql @@ -0,0 +1,40 @@ +CREATE TABLE "RULES"( + "UUID" CHARACTER VARYING(40) NOT NULL, + "NAME" CHARACTER VARYING(200), + "PLUGIN_RULE_KEY" CHARACTER VARYING(200) NOT NULL, + "PLUGIN_KEY" CHARACTER VARYING(200), + "PLUGIN_CONFIG_KEY" CHARACTER VARYING(200), + "PLUGIN_NAME" CHARACTER VARYING(255) NOT NULL, + "SCOPE" CHARACTER VARYING(20) NOT NULL, + "PRIORITY" INTEGER, + "STATUS" CHARACTER VARYING(40), + "LANGUAGE" CHARACTER VARYING(20), + "DEF_REMEDIATION_FUNCTION" CHARACTER VARYING(20), + "DEF_REMEDIATION_GAP_MULT" CHARACTER VARYING(20), + "DEF_REMEDIATION_BASE_EFFORT" CHARACTER VARYING(20), + "GAP_DESCRIPTION" CHARACTER VARYING(4000), + "SYSTEM_TAGS" CHARACTER VARYING(4000), + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, + "DESCRIPTION_FORMAT" CHARACTER VARYING(20), + "RULE_TYPE" TINYINT, + "SECURITY_STANDARDS" CHARACTER VARYING(4000), + "IS_AD_HOC" BOOLEAN NOT NULL, + "IS_EXTERNAL" BOOLEAN NOT NULL, + "CREATED_AT" BIGINT, + "UPDATED_AT" BIGINT, + "TEMPLATE_UUID" CHARACTER VARYING(40), + "NOTE_DATA" CHARACTER LARGE OBJECT, + "NOTE_USER_UUID" CHARACTER VARYING(255), + "NOTE_CREATED_AT" BIGINT, + "NOTE_UPDATED_AT" BIGINT, + "REMEDIATION_FUNCTION" CHARACTER VARYING(20), + "REMEDIATION_GAP_MULT" CHARACTER VARYING(20), + "REMEDIATION_BASE_EFFORT" CHARACTER VARYING(20), + "TAGS" CHARACTER VARYING(4000), + "AD_HOC_NAME" CHARACTER VARYING(200), + "AD_HOC_DESCRIPTION" CHARACTER LARGE OBJECT, + "AD_HOC_SEVERITY" CHARACTER VARYING(10), + "AD_HOC_TYPE" TINYINT +); +ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("UUID"); +CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY" NULLS FIRST, "PLUGIN_NAME" NULLS FIRST); diff --git a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest/schema.sql b/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest/schema.sql deleted file mode 100644 index 8346f94d192..00000000000 --- a/server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v96/AddGenericConceptsColumnToRuleTableTest/schema.sql +++ /dev/null @@ -1,40 +0,0 @@ -CREATE TABLE "RULES"( - "UUID" CHARACTER VARYING(40) NOT NULL, - "NAME" CHARACTER VARYING(200), - "PLUGIN_RULE_KEY" CHARACTER VARYING(200) NOT NULL, - "PLUGIN_KEY" CHARACTER VARYING(200), - "PLUGIN_CONFIG_KEY" CHARACTER VARYING(200), - "PLUGIN_NAME" CHARACTER VARYING(255) NOT NULL, - "SCOPE" CHARACTER VARYING(20) NOT NULL, - "PRIORITY" INTEGER, - "STATUS" CHARACTER VARYING(40), - "LANGUAGE" CHARACTER VARYING(20), - "DEF_REMEDIATION_FUNCTION" CHARACTER VARYING(20), - "DEF_REMEDIATION_GAP_MULT" CHARACTER VARYING(20), - "DEF_REMEDIATION_BASE_EFFORT" CHARACTER VARYING(20), - "GAP_DESCRIPTION" CHARACTER VARYING(4000), - "SYSTEM_TAGS" CHARACTER VARYING(4000), - "IS_TEMPLATE" BOOLEAN DEFAULT FALSE NOT NULL, - "DESCRIPTION_FORMAT" CHARACTER VARYING(20), - "RULE_TYPE" TINYINT, - "SECURITY_STANDARDS" CHARACTER VARYING(4000), - "IS_AD_HOC" BOOLEAN NOT NULL, - "IS_EXTERNAL" BOOLEAN NOT NULL, - "CREATED_AT" BIGINT, - "UPDATED_AT" BIGINT, - "TEMPLATE_UUID" CHARACTER VARYING(40), - "NOTE_DATA" CHARACTER LARGE OBJECT, - "NOTE_USER_UUID" CHARACTER VARYING(255), - "NOTE_CREATED_AT" BIGINT, - "NOTE_UPDATED_AT" BIGINT, - "REMEDIATION_FUNCTION" CHARACTER VARYING(20), - "REMEDIATION_GAP_MULT" CHARACTER VARYING(20), - "REMEDIATION_BASE_EFFORT" CHARACTER VARYING(20), - "TAGS" CHARACTER VARYING(4000), - "AD_HOC_NAME" CHARACTER VARYING(200), - "AD_HOC_DESCRIPTION" CHARACTER LARGE OBJECT, - "AD_HOC_SEVERITY" CHARACTER VARYING(10), - "AD_HOC_TYPE" TINYINT -); -ALTER TABLE "RULES" ADD CONSTRAINT "PK_RULES" PRIMARY KEY("UUID"); -CREATE UNIQUE INDEX "RULES_REPO_KEY" ON "RULES"("PLUGIN_RULE_KEY" NULLS FIRST, "PLUGIN_NAME" NULLS FIRST); diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java index b7324ab3a3a..d5898eb455d 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java @@ -397,7 +397,7 @@ public class RegisterRules implements Startable { .setIsAdHoc(false) .setCreatedAt(system2.now()) .setUpdatedAt(system2.now()) - .setGenericConcepts(ruleDef.genericConceptKeys()); + .setEducationPrinciples(ruleDef.educationPrincipleKeys()); if (isNotEmpty(ruleDef.htmlDescription())) { ruleDto.setDescriptionFormat(Format.HTML); @@ -443,8 +443,8 @@ public class RegisterRules implements Startable { boolean debtDefinitionsMerged = mergeDebtDefinitions(ruleDef, ruleDto); boolean tagsMerged = mergeTags(ruleDef, ruleDto); boolean securityStandardsMerged = mergeSecurityStandards(ruleDef, ruleDto); - boolean genericConceptsMerged = mergeGenericConcepts(ruleDef, ruleDto); - return ruleMerged || debtDefinitionsMerged || tagsMerged || securityStandardsMerged || genericConceptsMerged; + boolean educationPrinciplesMerged = mergeEducationPrinciples(ruleDef, ruleDto); + return ruleMerged || debtDefinitionsMerged || tagsMerged || securityStandardsMerged || educationPrinciplesMerged; } private boolean mergeRule(RulesDefinition.Rule def, RuleDto dto) { @@ -683,11 +683,11 @@ public class RegisterRules implements Startable { return changed; } - private static boolean mergeGenericConcepts(RulesDefinition.Rule ruleDef, RuleDto dto) { + private static boolean mergeEducationPrinciples(RulesDefinition.Rule ruleDef, RuleDto dto) { boolean changed = false; - if (dto.getGenericConcepts().size() != ruleDef.genericConceptKeys().size() || - !dto.getGenericConcepts().containsAll(ruleDef.genericConceptKeys())) { - dto.setGenericConcepts(ruleDef.genericConceptKeys()); + if (dto.getEducationPrinciples().size() != ruleDef.educationPrincipleKeys().size() || + !dto.getEducationPrinciples().containsAll(ruleDef.educationPrincipleKeys())) { + dto.setEducationPrinciples(ruleDef.educationPrincipleKeys()); changed = true; } return changed; diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java index 164949cb9e4..58e48f4d2cc 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/rule/RegisterRulesTest.java @@ -244,7 +244,7 @@ public class RegisterRulesTest { assertThat(rule.getType()).isEqualTo(RuleType.CODE_SMELL.getDbConstant()); assertThat(rule.getPluginKey()).isEqualTo(FAKE_PLUGIN_KEY); assertThat(rule.isAdHoc()).isFalse(); - assertThat(rule.getGenericConcepts()).containsOnly("concept1", "concept2", "concept3"); + assertThat(rule.getEducationPrinciples()).containsOnly("concept1", "concept2", "concept3"); } @Test @@ -414,7 +414,7 @@ public class RegisterRulesTest { assertThat(rule1.getType()).isEqualTo(RuleType.BUG.getDbConstant()); assertThat(rule1.getCreatedAt()).isEqualTo(DATE1.getTime()); assertThat(rule1.getUpdatedAt()).isEqualTo(DATE2.getTime()); - assertThat(rule1.getGenericConcepts()).containsOnly("concept1","concept4"); + assertThat(rule1.getEducationPrinciples()).containsOnly("concept1","concept4"); } @Test @@ -1209,7 +1209,7 @@ public class RegisterRulesTest { .setType(RuleType.CODE_SMELL) .setStatus(RuleStatus.BETA) .setGapDescription("java.S115.effortToFix") - .addGenericConceptKeys("concept1", "concept2", "concept3"); + .addEducationPrincipleKeys("concept1", "concept2", "concept3"); rule1.setDebtRemediationFunction(rule1.debtRemediationFunctions().linearWithOffset("5d", "10h")); rule1.createParam("param1").setDescription("parameter one").setDefaultValue("default1"); @@ -1248,7 +1248,7 @@ public class RegisterRulesTest { .setType(RuleType.BUG) .setStatus(READY) .setGapDescription("java.S115.effortToFix.v2") - .addGenericConceptKeys("concept1", "concept4"); + .addEducationPrincipleKeys("concept1", "concept4"); rule1.setDebtRemediationFunction(rule1.debtRemediationFunctions().linearWithOffset("6d", "2h")); rule1.createParam("param1").setDescription("parameter one v2").setDefaultValue("default1 v2"); rule1.createParam("param2").setDescription("parameter two v2").setDefaultValue("default2 v2"); @@ -1288,7 +1288,7 @@ public class RegisterRulesTest { .setScope(RuleScope.ALL) .setType(RuleType.CODE_SMELL) .setStatus(RuleStatus.BETA) - .addGenericConceptKeys("concept1", "concept2", "concept3"); + .addEducationPrincipleKeys("concept1", "concept2", "concept3"); repo.createRule(EXTERNAL_HOTSPOT_RULE_KEY.rule()) .setName("Hotspot") diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleMapper.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleMapper.java index 856833ccf52..fa8f88e5382 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleMapper.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleMapper.java @@ -59,9 +59,9 @@ import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_DEFAULT_DEBT_REM_ import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_DEFAULT_REM_FUNCTION; import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_DEPRECATED_KEYS; import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_DESCRIPTION_SECTIONS; +import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_EDUCATION_PRINCIPLES; import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_EFFORT_TO_FIX_DESCRIPTION; import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_GAP_DESCRIPTION; -import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_GENERIC_CONCEPTS; import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_HTML_DESCRIPTION; import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_INTERNAL_KEY; import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_IS_EXTERNAL; @@ -148,7 +148,7 @@ public class RuleMapper { setAdHocSeverity(ruleResponse, ruleDto, fieldsToReturn); setAdHocType(ruleResponse, ruleDto); } - setGenericConcepts(ruleResponse, ruleDto, fieldsToReturn); + setEducationPrinciples(ruleResponse, ruleDto, fieldsToReturn); return ruleResponse; } @@ -199,9 +199,9 @@ public class RuleMapper { } } - private static void setGenericConcepts(Rules.Rule.Builder ruleResponse, RuleDto ruleDto, Set fieldsToReturn) { - if (shouldReturnField(fieldsToReturn, FIELD_GENERIC_CONCEPTS)) { - ruleResponse.getGenericConceptsBuilder().addAllGenericConcepts((ruleDto.getGenericConcepts())); + private static void setEducationPrinciples(Rules.Rule.Builder ruleResponse, RuleDto ruleDto, Set fieldsToReturn) { + if (shouldReturnField(fieldsToReturn, FIELD_EDUCATION_PRINCIPLES)) { + ruleResponse.getEducationPrinciplesBuilder().addAllEducationPrinciples((ruleDto.getEducationPrinciples())); } } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RulesWsParameters.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RulesWsParameters.java index 4f4af555c87..4177350ac28 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RulesWsParameters.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RulesWsParameters.java @@ -62,7 +62,7 @@ public class RulesWsParameters { public static final String FIELD_MARKDOWN_DESCRIPTION = "mdDesc"; public static final String FIELD_DESCRIPTION_SECTIONS = "descriptionSections"; - public static final String FIELD_GENERIC_CONCEPTS = "genericConcepts"; + public static final String FIELD_EDUCATION_PRINCIPLES = "educationPrinciples"; public static final String FIELD_NOTE_LOGIN = "noteLogin"; public static final String FIELD_MARKDOWN_NOTE = "mdNote"; public static final String FIELD_HTML_NOTE = "htmlNote"; @@ -110,7 +110,7 @@ public class RulesWsParameters { FIELD_MARKDOWN_DESCRIPTION, FIELD_DESCRIPTION_SECTIONS, FIELD_NOTE_LOGIN, FIELD_MARKDOWN_NOTE, FIELD_HTML_NOTE, FIELD_DEFAULT_DEBT_REM_FUNCTION, FIELD_EFFORT_TO_FIX_DESCRIPTION, FIELD_DEBT_OVERLOADED, FIELD_DEBT_REM_FUNCTION, FIELD_DEFAULT_REM_FUNCTION, FIELD_GAP_DESCRIPTION, FIELD_REM_FUNCTION_OVERLOADED, FIELD_REM_FUNCTION, - FIELD_PARAMS, FIELD_ACTIVES, FIELD_SCOPE, FIELD_DEPRECATED_KEYS, FIELD_GENERIC_CONCEPTS); + FIELD_PARAMS, FIELD_ACTIVES, FIELD_SCOPE, FIELD_DEPRECATED_KEYS, FIELD_EDUCATION_PRINCIPLES); private RulesWsParameters() { // prevent instantiation diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java index 31db2ae17a7..016d1da1236 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java @@ -152,7 +152,7 @@ public class SearchAction implements RulesWsAction { new Change("9.5", "The field 'descriptionSections' has been added to the payload"), new Change("9.5", "The field 'descriptionSections' has been added to the 'f' parameter"), new Change("9.6", "'descriptionSections' can optionally embed a context field"), - new Change("9.6", "The field 'genericConcepts' has been added to the 'f' parameter") + new Change("9.6", "The field 'educationPrinciples' has been added to the 'f' parameter") ); action.createParam(FACETS) diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/ShowAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/ShowAction.java index 1e5afdb58f9..ab44840e7f7 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/ShowAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/ShowAction.java @@ -80,7 +80,7 @@ public class ShowAction implements RulesWsAction { new Change("9.5", "The field 'descriptionSections' has been added to the payload"), new Change("9.5", "The field 'descriptionSections' has been added to the 'f' parameter"), new Change("9.6", "'descriptionSections' can optionally embed a context field"), - new Change("9.6", "'genericConcepts' has been added") + new Change("9.6", "'educationPrinciples' has been added") ); action diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/CurrentAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/CurrentAction.java index 4b956f4d894..9721fad2277 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/CurrentAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/CurrentAction.java @@ -50,7 +50,7 @@ import static java.util.Optional.ofNullable; import static java.util.stream.Collectors.toList; import static org.apache.commons.lang.StringUtils.EMPTY; import static org.sonar.api.web.UserRole.USER; -import static org.sonar.server.user.ws.DismissNoticeAction.GENERIC_CONCEPTS; +import static org.sonar.server.user.ws.DismissNoticeAction.EDUCATION_PRINCIPLES; import static org.sonar.server.ws.WsUtils.writeProtobuf; import static org.sonarqube.ws.Users.CurrentWsResponse.HomepageType.APPLICATION; import static org.sonarqube.ws.Users.CurrentWsResponse.HomepageType.PORTFOLIO; @@ -123,7 +123,7 @@ public class CurrentAction implements UsersWsAction { .setHomepage(buildHomepage(dbSession, user)) .setUsingSonarLintConnectedMode(user.getLastSonarlintConnectionDate() != null) .setSonarLintAdSeen(user.isSonarlintAdSeen()) - .putDismissedNotices(GENERIC_CONCEPTS, isNoticeDismissed(user, GENERIC_CONCEPTS)); + .putDismissedNotices(EDUCATION_PRINCIPLES, isNoticeDismissed(user, EDUCATION_PRINCIPLES)); ofNullable(emptyToNull(user.getEmail())).ifPresent(builder::setEmail); ofNullable(emptyToNull(user.getEmail())).ifPresent(u -> builder.setAvatar(avatarResolver.create(user))); ofNullable(user.getExternalLogin()).ifPresent(builder::setExternalIdentity); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DismissNoticeAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DismissNoticeAction.java index 57b14f59024..d4625ffb21e 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DismissNoticeAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/DismissNoticeAction.java @@ -32,7 +32,7 @@ import static com.google.common.base.Preconditions.checkState; public class DismissNoticeAction implements UsersWsAction { - public static final String GENERIC_CONCEPTS = "genericConcepts"; + public static final String EDUCATION_PRINCIPLES = "educationPrinciples"; public static final String USER_DISMISS_CONSTANT = "user.dismissedNotices."; private final UserSession userSession; @@ -54,8 +54,8 @@ public class DismissNoticeAction implements UsersWsAction { action.createParam("notice") .setDescription("notice key to dismiss") - .setExampleValue(GENERIC_CONCEPTS) - .setPossibleValues(GENERIC_CONCEPTS); + .setExampleValue(EDUCATION_PRINCIPLES) + .setPossibleValues(EDUCATION_PRINCIPLES); } @Override diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java index bdc2bf3c09a..12de1415f02 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java @@ -309,7 +309,7 @@ public class SearchActionTest { indexRules(); Rules.SearchResponse response = ws.newRequest() - .setParam(WebService.Param.FIELDS, "createdAt,langName,genericConcepts") + .setParam(WebService.Param.FIELDS, "createdAt,langName,educationPrinciples") .executeProtobuf(Rules.SearchResponse.class); Rules.Rule result = response.getRules(0); @@ -320,7 +320,7 @@ public class SearchActionTest { // selected fields assertThat(result.getCreatedAt()).isNotEmpty(); assertThat(result.getLangName()).isNotEmpty(); - assertThat(result.getGenericConcepts().getGenericConceptsList()).containsExactlyElementsOf(rule.getGenericConcepts()); + assertThat(result.getEducationPrinciples().getEducationPrinciplesList()).containsExactlyElementsOf(rule.getEducationPrinciples()); // not returned fields assertThat(result.hasEffortToFixDescription()).isFalse(); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/ShowActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/ShowActionTest.java index 8e6590dee74..2cfd6cbe501 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/ShowActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/rule/ws/ShowActionTest.java @@ -130,7 +130,7 @@ public class ShowActionTest { assertThat(resultRule.getParams().getParamsList()) .extracting(Rule.Param::getKey, Rule.Param::getHtmlDesc, Rule.Param::getDefaultValue) .containsExactlyInAnyOrder(tuple(ruleParam.getName(), ruleParam.getDescription(), ruleParam.getDefaultValue())); - assertThat(resultRule.getGenericConcepts().getGenericConceptsList()).containsExactlyElementsOf(rule.getGenericConcepts()); + assertThat(resultRule.getEducationPrinciples().getEducationPrinciplesList()).containsExactlyElementsOf(rule.getEducationPrinciples()); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionTest.java index 7e0c5f134cf..a46493caee5 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CurrentActionTest.java @@ -88,22 +88,22 @@ public class CurrentActionTest { } @Test - public void return_generic_concepts_seen() { + public void return_educationPrinciples_dismiss_notice() { UserDto user = db.users().insertUser(); userSession.logIn(user); - PropertyDto property = new PropertyDto().setUserUuid(user.getUuid()).setKey("user.dismissedNotices.genericConcepts"); + PropertyDto property = new PropertyDto().setUserUuid(user.getUuid()).setKey("user.dismissedNotices.educationPrinciples"); db.properties().insertProperties(userSession.getLogin(), null, null, null, property); CurrentWsResponse response = call(); assertThat(response.getDismissedNoticesMap().entrySet()) .extracting(Map.Entry::getKey, Map.Entry::getValue) - .contains(Tuple.tuple("genericConcepts", true)); + .contains(Tuple.tuple("educationPrinciples", true)); } @Test - public void return_generic_concepts_not_seen() { + public void return_educationPrinciples_not_dismissed() { UserDto user = db.users().insertUser(); userSession.logIn(user); @@ -111,7 +111,7 @@ public class CurrentActionTest { assertThat(response.getDismissedNoticesMap().entrySet()) .extracting(Map.Entry::getKey, Map.Entry::getValue) - .contains(Tuple.tuple("genericConcepts", false)); + .contains(Tuple.tuple("educationPrinciples", false)); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DismissNoticeActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DismissNoticeActionTest.java index 06457e7fc32..d20d7eeb301 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DismissNoticeActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DismissNoticeActionTest.java @@ -44,16 +44,16 @@ public class DismissNoticeActionTest { private final WsActionTester tester = new WsActionTester(new DismissNoticeAction(userSessionRule, db.getDbClient())); @Test - public void dismiss_genericConcepts() { + public void dismiss_educationPrinciples() { userSessionRule.logIn(); TestResponse testResponse = tester.newRequest() - .setParam("notice", "genericConcepts") + .setParam("notice", "educationPrinciples") .execute(); assertThat(testResponse.getStatus()).isEqualTo(204); - Optional propertyDto = db.properties().findFirstUserProperty(userSessionRule.getUuid(), "user.dismissedNotices.genericConcepts"); + Optional propertyDto = db.properties().findFirstUserProperty(userSessionRule.getUuid(), "user.dismissedNotices.educationPrinciples"); assertThat(propertyDto).isPresent(); } @@ -88,22 +88,22 @@ public class DismissNoticeActionTest { assertThatThrownBy(testRequest::execute) .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Value of parameter 'notice' (not_supported_value) must be one of: [genericConcepts]"); + .hasMessage("Value of parameter 'notice' (not_supported_value) must be one of: [educationPrinciples]"); } @Test public void notice_already_exist() { userSessionRule.logIn(); - PropertyDto property = new PropertyDto().setKey("user.dismissedNotices.genericConcepts").setUserUuid(userSessionRule.getUuid()); + PropertyDto property = new PropertyDto().setKey("user.dismissedNotices.educationPrinciples").setUserUuid(userSessionRule.getUuid()); db.properties().insertProperties(userSessionRule.getLogin(), null, null, null, property); TestRequest testRequest = tester.newRequest() - .setParam("notice", "genericConcepts"); + .setParam("notice", "educationPrinciples"); assertThatThrownBy(testRequest::execute) .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Notice genericConcepts is already dismissed"); + .hasMessage("Notice educationPrinciples is already dismissed"); } diff --git a/sonar-ws/src/main/protobuf/ws-rules.proto b/sonar-ws/src/main/protobuf/ws-rules.proto index ec2ee250624..7ec1c827f9f 100644 --- a/sonar-ws/src/main/protobuf/ws-rules.proto +++ b/sonar-ws/src/main/protobuf/ws-rules.proto @@ -123,7 +123,7 @@ message Rule { optional bool isExternal = 47; optional DeprecatedKeys deprecatedKeys = 48; optional DescriptionSections descriptionSections = 49; - optional GenericConcepts genericConcepts = 50; + optional EducationPrinciples educationPrinciples = 50; message DescriptionSections { repeated DescriptionSection descriptionSections = 1; @@ -164,8 +164,8 @@ message Tags { repeated string tags = 1; } -message GenericConcepts { - repeated string genericConcepts = 1; +message EducationPrinciples { + repeated string educationPrinciples = 1; } message Actives { -- cgit v1.2.3