.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());
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
</sql>
<sql id="selectJoinedTablesColumns">
+ 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",
<include refid="leftOuterJoinRulesDescriptionSections"/>
</select>
- <resultMap id="ruleResultMap" type="org.sonar.db.rule.RuleDto">
+ <resultMap id="ruleResultMap" type="org.sonar.db.rule.RuleDto" autoMapping="true">
<id property="uuid" column="r_uuid"/>
- <result property="createdAt" column="createdAt"/>
- <result property="updatedAt" column="updatedAt"/>
- <result property="noteData" column="noteData" typeHandler="org.apache.ibatis.type.StringTypeHandler"/>
- <result property="noteUserUuid" column="noteUserUuid"/>
- <result property="noteCreatedAt" column="noteCreatedAt"/>
- <result property="noteUpdatedAt" column="noteUpdatedAt"/>
- <result property="remediationFunction" column="remediationFunction"/>
- <result property="remediationGapMultiplier" column="remediationGapMultiplier"/>
- <result property="remediationBaseEffort" column="remediationBaseEffort"/>
- <result property="tagsField" column="tagsField"/>
- <result property="adHocName" column="adHocName"/>
- <result property="adHocDescription" column="adHocDescription" typeHandler="org.apache.ibatis.type.StringTypeHandler"/>
- <result property="adHocSeverity" column="adHocSeverity"/>
- <result property="adHocType" column="adHocType"/>
-
- <result property="ruleKey" column="ruleKey"/>
- <result property="repositoryKey" column="repositoryKey"/>
- <result property="descriptionFormat" column="descriptionFormat"/>
- <result property="status" column="status"/>
- <result property="name" column="name"/>
- <result property="configKey" column="configKey"/>
- <result property="severity" column="severity"/>
- <result property="isTemplate" column="isTemplate"/>
- <result property="isExternal" column="isExternal"/>
- <result property="isAdHoc" column="isAdHoc"/>
- <result property="language" column="language"/>
- <result property="templateUuid" column="templateUuid"/>
- <result property="defRemediationFunction" column="defRemediationFunction"/>
- <result property="defRemediationGapMultiplier" column="defRemediationGapMultiplier"/>
- <result property="defRemediationBaseEffort" column="defRemediationBaseEffort"/>
- <result property="gapDescription" column="gapDescription"/>
- <result property="systemTagsField" column="systemTagsField"/>
- <result property="securityStandardsField" column="securityStandardsField"/>
- <result property="type" column="type"/>
- <result property="pluginKey" column="pluginKey"/>
- <result property="scope" column="scope"/>
-
- <collection property="ruleDescriptionSectionDtos" ofType="org.sonar.db.rule.RuleDescriptionSectionDto">
- <id property="uuid" column="rds_uuid"/>
- <result property="key" column="rds_kee"/>
- <result property="content" column="rds_content" typeHandler="org.apache.ibatis.type.StringTypeHandler"/>
+ <collection property="ruleDescriptionSectionDtos" ofType="org.sonar.db.rule.RuleDescriptionSectionDto" autoMapping="true"
+ columnPrefix="rds_">
+ <result property="key" column="kee"/>
</collection>
</resultMap>
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();
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());
.containsExactlyInAnyOrder(tuple(r1.getUuid(), r1.getKey()), tuple(r2.getUuid(), r2.getKey()));
Iterator<RuleForIndexingDto> 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());
.findFirst().orElseThrow();
}
-
@Test
public void scrollIndexingRulesByKeys() {
Accumulator<RuleForIndexingDto> accumulator = new Accumulator<>();