use of org.sonar.api.batch.rule.internal.NewActiveRule in project sonarqube by SonarSource.
the class NewActiveRuleTest method severity_should_have_default_value.
@Test
public void severity_should_have_default_value() {
NewActiveRule rule = builder.build();
assertThat(rule.severity).isEqualTo(Severity.defaultSeverity());
}
use of org.sonar.api.batch.rule.internal.NewActiveRule in project sonarqube by SonarSource.
the class NewActiveRuleTest method set_param_remove_param_if_value_is_null.
@Test
public void set_param_remove_param_if_value_is_null() {
NewActiveRule rule = builder.setParam("foo", "bar").setParam("removed", "value").setParam("removed", null).build();
assertThat(rule.params).isEqualTo(ImmutableMap.of("foo", "bar"));
}
use of org.sonar.api.batch.rule.internal.NewActiveRule in project sonarqube by SonarSource.
the class SensorContextTesterTest method testActiveRules.
@Test
public void testActiveRules() {
NewActiveRule activeRule = new NewActiveRule.Builder().setRuleKey(RuleKey.of("foo", "bar")).build();
ActiveRules activeRules = new ActiveRulesBuilder().addRule(activeRule).build();
tester.setActiveRules(activeRules);
assertThat(tester.activeRules().findAll()).hasSize(1);
}
use of org.sonar.api.batch.rule.internal.NewActiveRule in project sonarqube by SonarSource.
the class CheckFactoryTest method class_name_as_check_key.
@Test
public void class_name_as_check_key() {
RuleKey ruleKey = RuleKey.of("squid", "org.sonar.api.batch.rule.CheckWithoutProperties");
NewActiveRule rule = new NewActiveRule.Builder().setRuleKey(ruleKey).build();
builder.addRule(rule);
CheckFactory checkFactory = new CheckFactory(builder.build());
Checks checks = checkFactory.create("squid").addAnnotatedChecks(CheckWithoutProperties.class);
Object check = checks.of(ruleKey);
assertThat(check).isInstanceOf(CheckWithoutProperties.class);
assertThat(checks.all()).containsOnly(check);
assertThat(checks.ruleKey(check)).isEqualTo(ruleKey);
}
use of org.sonar.api.batch.rule.internal.NewActiveRule in project sonarqube by SonarSource.
the class CheckFactoryTest method fail_if_field_type_is_not_supported.
@Test
public void fail_if_field_type_is_not_supported() {
RuleKey ruleKey = RuleKey.of("squid", "org.sonar.api.batch.rule.CheckWithUnsupportedPropertyType");
NewActiveRule rule = new NewActiveRule.Builder().setRuleKey(ruleKey).setParam("max", "300").build();
builder.addRule(rule);
CheckFactory checkFactory = new CheckFactory(builder.build());
assertThatThrownBy(() -> checkFactory.create("squid").addAnnotatedChecks(CheckWithUnsupportedPropertyType.class)).isInstanceOf(SonarException.class);
}
Aggregations