本文整理了Java中org.sonar.api.rules.Rule.getTags
方法的一些代码示例,展示了Rule.getTags
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rule.getTags
方法的具体详情如下:
包路径:org.sonar.api.rules.Rule
类名称:Rule
方法名:getTags
[英]For definition of rule only
[中]仅适用于规则的定义
代码示例来源:origin: SonarSource/sonarqube
@Test
public void testTags() {
Rule rule = Rule.create();
assertThat(rule.getTags()).isEmpty();
assertThat(rule.getSystemTags()).isEmpty();
rule.setTags(new String[] {"tag1", "tag2"});
assertThat(rule.getTags()).containsOnly("tag1", "tag2");
assertThat(rule.getSystemTags()).isEmpty();
}
代码示例来源:origin: SonarSource/sonarqube
private void verifyRule(Rule rule, RuleDefinitionDto ruleDefinition, RuleParamDto ruleParam) {
assertThat(rule).isNotNull();
assertThat(rule.getName()).isEqualTo(ruleDefinition.getName());
assertThat(rule.getLanguage()).isEqualTo(ruleDefinition.getLanguage());
assertThat(rule.getKey()).isEqualTo(ruleDefinition.getRuleKey());
assertThat(rule.getConfigKey()).isEqualTo(ruleDefinition.getConfigKey());
assertThat(rule.isTemplate()).isEqualTo(ruleDefinition.isTemplate());
assertThat(rule.getCreatedAt().getTime()).isEqualTo(ruleDefinition.getCreatedAt());
assertThat(rule.getUpdatedAt().getTime()).isEqualTo(ruleDefinition.getUpdatedAt());
assertThat(rule.getRepositoryKey()).isEqualTo(ruleDefinition.getRepositoryKey());
assertThat(rule.getSeverity().name()).isEqualTo(ruleDefinition.getSeverityString());
assertThat(rule.getSystemTags()).isEqualTo(ruleDefinition.getSystemTags().stream().toArray(String[]::new));
assertThat(rule.getTags()).isEmpty();
assertThat(rule.getId()).isEqualTo(ruleDefinition.getId());
assertThat(rule.getDescription()).isEqualTo(ruleDefinition.getDescription());
assertThat(rule.getParams()).hasSize(1);
org.sonar.api.rules.RuleParam param = rule.getParams().iterator().next();
assertThat(param.getRule()).isSameAs(rule);
assertThat(param.getKey()).isEqualTo(ruleParam.getName());
assertThat(param.getDescription()).isEqualTo(ruleParam.getDescription());
assertThat(param.getType()).isEqualTo(ruleParam.getType());
assertThat(param.getDefaultValue()).isEqualTo(ruleParam.getDefaultValue());
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void findByKey_populates_system_tags_but_not_tags() {
RuleDefinitionDto ruleDefinition = dbTester.rules()
.insert(t -> t.setSystemTags(ImmutableSet.of(randomAlphanumeric(5), randomAlphanumeric(6))));
OrganizationDto organization = dbTester.organizations().insert();
dbTester.rules().insertRule(organization);
Rule rule = underTest.findByKey(ruleDefinition.getKey());
assertThat(rule.getSystemTags())
.containsOnlyElementsOf(ruleDefinition.getSystemTags());
assertThat(rule.getTags()).isEmpty();
rule = underTest.findByKey(ruleDefinition.getRepositoryKey(), ruleDefinition.getRuleKey());
assertThat(rule.getSystemTags())
.containsOnlyElementsOf(ruleDefinition.getSystemTags());
assertThat(rule.getTags()).isEmpty();
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void findById_populates_system_tags_but_not_tags() {
RuleDefinitionDto ruleDefinition = dbTester.rules()
.insert(t -> t.setSystemTags(ImmutableSet.of(randomAlphanumeric(5), randomAlphanumeric(6))));
OrganizationDto organization = dbTester.organizations().insert();
dbTester.rules().insertRule(organization);
Rule rule = underTest.findById(ruleDefinition.getId());
assertThat(rule.getSystemTags())
.containsOnlyElementsOf(ruleDefinition.getSystemTags());
assertThat(rule.getTags()).isEmpty();
}
代码示例来源:origin: SonarSource/sonarqube
newRule.setSeverity(rule.getSeverity().toString());
newRule.setStatus(rule.getStatus() == null ? RuleStatus.defaultStatus() : RuleStatus.valueOf(rule.getStatus()));
newRule.setTags(rule.getTags());
for (RuleParam param : rule.getParams()) {
RulesDefinition.NewParam newParam = newRule.createParam(param.getKey());
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
newRule.setSeverity(rule.getSeverity().toString());
newRule.setStatus(rule.getStatus() == null ? RuleStatus.defaultStatus() : RuleStatus.valueOf(rule.getStatus()));
newRule.setTags(rule.getTags());
for (RuleParam param : rule.getParams()) {
RulesDefinition.NewParam newParam = newRule.createParam(param.getKey());
内容来源于网络,如有侵权,请联系作者删除!