Search in sources :

Example 1 with NewAdHocRule

use of org.sonar.api.batch.sensor.rule.NewAdHocRule in project sonarqube by SonarSource.

the class DefaultAdHocRuleTest method fail_to_store_if_no_name.

@Test
public void fail_to_store_if_no_name() {
    SensorStorage storage = mock(SensorStorage.class);
    NewAdHocRule rule = new DefaultAdHocRule(storage).engineId("engine").ruleId("ruleId").name("  ").description("desc").severity(Severity.BLOCKER).type(RuleType.CODE_SMELL);
    assertThatThrownBy(() -> rule.save()).isInstanceOf(IllegalStateException.class).hasMessageContaining("Name is mandatory");
}
Also used : NewAdHocRule(org.sonar.api.batch.sensor.rule.NewAdHocRule) SensorStorage(org.sonar.api.batch.sensor.internal.SensorStorage) Test(org.junit.Test)

Example 2 with NewAdHocRule

use of org.sonar.api.batch.sensor.rule.NewAdHocRule in project sonarqube by SonarSource.

the class DefaultAdHocRuleTest method fail_to_store_if_no_engine_id.

@Test
public void fail_to_store_if_no_engine_id() {
    SensorStorage storage = mock(SensorStorage.class);
    NewAdHocRule rule = new DefaultAdHocRule(storage).engineId(" ").ruleId("ruleId").name("name").description("desc").severity(Severity.BLOCKER).type(RuleType.CODE_SMELL);
    assertThatThrownBy(() -> rule.save()).isInstanceOf(IllegalStateException.class).hasMessageContaining("Engine id is mandatory");
}
Also used : NewAdHocRule(org.sonar.api.batch.sensor.rule.NewAdHocRule) SensorStorage(org.sonar.api.batch.sensor.internal.SensorStorage) Test(org.junit.Test)

Example 3 with NewAdHocRule

use of org.sonar.api.batch.sensor.rule.NewAdHocRule in project sonarqube by SonarSource.

the class DefaultAdHocRuleTest method fail_to_store_if_no_rule_id.

@Test
public void fail_to_store_if_no_rule_id() {
    SensorStorage storage = mock(SensorStorage.class);
    NewAdHocRule rule = new DefaultAdHocRule(storage).engineId("engine").ruleId("  ").name("name").description("desc").severity(Severity.BLOCKER).type(RuleType.CODE_SMELL);
    assertThatThrownBy(() -> rule.save()).isInstanceOf(IllegalStateException.class).hasMessageContaining("Rule id is mandatory");
}
Also used : NewAdHocRule(org.sonar.api.batch.sensor.rule.NewAdHocRule) SensorStorage(org.sonar.api.batch.sensor.internal.SensorStorage) Test(org.junit.Test)

Example 4 with NewAdHocRule

use of org.sonar.api.batch.sensor.rule.NewAdHocRule in project sonarqube by SonarSource.

the class DefaultAdHocRuleTest method fail_to_store_if_no_type.

@Test
public void fail_to_store_if_no_type() {
    SensorStorage storage = mock(SensorStorage.class);
    NewAdHocRule rule = new DefaultAdHocRule(storage).engineId("engine").ruleId("ruleId").name("name").description("desc").severity(Severity.BLOCKER);
    assertThatThrownBy(() -> rule.save()).isInstanceOf(IllegalStateException.class).hasMessageContaining("Type is mandatory");
}
Also used : NewAdHocRule(org.sonar.api.batch.sensor.rule.NewAdHocRule) SensorStorage(org.sonar.api.batch.sensor.internal.SensorStorage) Test(org.junit.Test)

Example 5 with NewAdHocRule

use of org.sonar.api.batch.sensor.rule.NewAdHocRule in project sonarqube by SonarSource.

the class DefaultAdHocRuleTest method fail_to_store_if_no_severity.

@Test
public void fail_to_store_if_no_severity() {
    SensorStorage storage = mock(SensorStorage.class);
    NewAdHocRule rule = new DefaultAdHocRule(storage).engineId("engine").ruleId("ruleId").name("name").description("desc").type(RuleType.CODE_SMELL);
    assertThatThrownBy(() -> rule.save()).isInstanceOf(IllegalStateException.class).hasMessageContaining("Severity is mandatory");
}
Also used : NewAdHocRule(org.sonar.api.batch.sensor.rule.NewAdHocRule) SensorStorage(org.sonar.api.batch.sensor.internal.SensorStorage) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 SensorStorage (org.sonar.api.batch.sensor.internal.SensorStorage)5 NewAdHocRule (org.sonar.api.batch.sensor.rule.NewAdHocRule)5