Search in sources :

Example 16 with BadRequestException

use of org.sonar.server.exceptions.BadRequestException in project sonarqube by SonarSource.

the class RuleActivatorMediumTest method deactivation_fails_if_rule_not_found.

@Test
public void deactivation_fails_if_rule_not_found() {
    ActiveRuleKey key = ActiveRuleKey.of(XOO_P1_KEY, RuleKey.of("xoo", "x3"));
    try {
        ruleActivator.deactivate(key);
        fail();
    } catch (BadRequestException e) {
        assertThat(e).hasMessage("Rule not found: xoo:x3");
        verifyZeroActiveRules(XOO_P1_KEY);
    }
}
Also used : BadRequestException(org.sonar.server.exceptions.BadRequestException) ActiveRuleKey(org.sonar.db.qualityprofile.ActiveRuleKey) Test(org.junit.Test)

Aggregations

BadRequestException (org.sonar.server.exceptions.BadRequestException)16 Test (org.junit.Test)11 ActiveRuleKey (org.sonar.db.qualityprofile.ActiveRuleKey)5 ActiveRuleDto (org.sonar.db.qualityprofile.ActiveRuleDto)4 QualityProfileDto (org.sonar.db.qualityprofile.QualityProfileDto)4 RuleDto (org.sonar.db.rule.RuleDto)4 ArrayList (java.util.ArrayList)3 RuleKey (org.sonar.api.rule.RuleKey)3 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)2 DbSession (org.sonar.db.DbSession)2 EmailException (org.apache.commons.mail.EmailException)1 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)1 ComponentDto (org.sonar.db.component.ComponentDto)1 OrganizationDto (org.sonar.db.organization.OrganizationDto)1 RuleParamDto (org.sonar.db.rule.RuleParamDto)1 WsTester (org.sonar.server.ws.WsTester)1