org.sonar.api.rules.Rule.getTags()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.sonar.api.rules.Rule.getTags方法的一些代码示例,展示了Rule.getTags的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rule.getTags方法的具体详情如下:
包路径:org.sonar.api.rules.Rule
类名称:Rule
方法名:getTags

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());

相关文章