From: Léo Geoffroy <99647462+leo-geoffroy-sonarsource@users.noreply.github.com> Date: Mon, 16 May 2022 08:55:00 +0000 (+0200) Subject: SONAR-16302 - Update to add mybatis automapping (#5926) X-Git-Tag: 9.5.0.56709~131 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e4b1356084b1cd0502619c639bf48cbe27d445ed;p=sonarqube.git SONAR-16302 - Update to add mybatis automapping (#5926) --- diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreatorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreatorTest.java index c537404f637..c992f745732 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreatorTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/AdHocRuleCreatorTest.java @@ -103,7 +103,7 @@ public class AdHocRuleCreatorTest { .setEngineId("eslint") .setRuleId("no-cond-assign") .setName(repeat("a", 201)) - .setDescription(repeat("a", 1_000_000)) + .setDescription(repeat("a", 16_777_216)) .setSeverity(Constants.Severity.BLOCKER) .setType(ScannerReport.IssueType.BUG) .build()); @@ -111,7 +111,7 @@ public class AdHocRuleCreatorTest { RuleDto rule = underTest.persistAndIndex(dbSession, addHocRule); assertThat(rule.getMetadata().getAdHocName()).isEqualTo(repeat("a", 200)); - assertThat(rule.getMetadata().getAdHocDescription()).isEqualTo(repeat("a", 1_000_000)); + assertThat(rule.getMetadata().getAdHocDescription()).isEqualTo(repeat("a", 16_777_215)); } @Test 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 261298c4cd3..f96f6862310 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 @@ -9,9 +9,10 @@ + rds.content as "rds_content", rds.uuid as "rds_uuid", rds.kee as "rds_kee", - rds.content as "rds_content", + r.uuid as "r_uuid", r.plugin_rule_key as "ruleKey", r.plugin_name as "repositoryKey", @@ -64,50 +65,12 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + 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 15b4249eace..e859952d32f 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 @@ -130,6 +130,25 @@ public class RuleDaoTest { verifyMetadata(rule.getMetadata(), metadata); } + @Test + public void selectByUuidWithDifferentsValuesOfBooleans() { + for (int i = 0; i < 3; i++) { + int indexBoolean = i; + RuleDto ruleDto = db.rules().insert((ruleDto1 -> { + ruleDto1.setIsTemplate(indexBoolean == 0); + ruleDto1.setIsExternal(indexBoolean == 1); + ruleDto1.setIsAdHoc(indexBoolean == 2); + })); + RuleMetadataDto metadata = newRuleMetadata(ruleDto); + RuleDto expected = db.rules().insertRule(ruleDto, metadata); + + assertThat(underTest.selectByUuid(expected.getUuid() + 500, db.getSession())).isEmpty(); + RuleDto rule = underTest.selectByUuid(expected.getUuid(), db.getSession()).get(); + assertEquals(rule, ruleDto); + verifyMetadata(rule.getMetadata(), metadata); + } + } + @Test public void selectDefinitionByUuid() { RuleDto rule = db.rules().insert(); @@ -251,6 +270,7 @@ public class RuleDaoTest { assertThat(actual.getSeverityString()).isEqualTo(expected.getSeverityString()); assertThat(actual.isExternal()).isEqualTo(expected.isExternal()); assertThat(actual.isTemplate()).isEqualTo(expected.isTemplate()); + assertThat(actual.isCustomRule()).isEqualTo(expected.isCustomRule()); assertThat(actual.getLanguage()).isEqualTo(expected.getLanguage()); assertThat(actual.getTemplateUuid()).isEqualTo(expected.getTemplateUuid()); assertThat(actual.getDefRemediationFunction()).isEqualTo(expected.getDefRemediationFunction()); @@ -851,15 +871,14 @@ public class RuleDaoTest { .containsExactlyInAnyOrder(tuple(r1.getUuid(), r1.getKey()), tuple(r2.getUuid(), r2.getKey())); Iterator it = accumulator.list.iterator(); - assertThat(firstRule.getRepository()).isEqualTo(r1.getRepositoryKey()); assertThat(firstRule.getPluginRuleKey()).isEqualTo(r1.getRuleKey()); assertThat(firstRule.getName()).isEqualTo(r1.getName()); assertThat(firstRule.getRuleDescriptionSectionsDtos().stream() .filter(s -> s.getKey().equals(ruleDescriptionSectionDto.getKey())) .collect(MoreCollectors.onlyElement())) - .usingRecursiveComparison() - .isEqualTo(ruleDescriptionSectionDto); + .usingRecursiveComparison() + .isEqualTo(ruleDescriptionSectionDto); assertThat(firstRule.getDescriptionFormat()).isEqualTo(r1.getDescriptionFormat()); assertThat(firstRule.getSeverity()).isEqualTo(r1.getSeverity()); assertThat(firstRule.getStatus()).isEqualTo(r1.getStatus()); @@ -910,7 +929,6 @@ public class RuleDaoTest { .findFirst().orElseThrow(); } - @Test public void scrollIndexingRulesByKeys() { Accumulator accumulator = new Accumulator<>();