use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class QProfileFactoryTest method find_profile_by_name.
@Test
public void find_profile_by_name() {
QualityProfileDto profile = underTest.find(dbSession, QProfileRef.fromName("js", "Sonar way"));
assertThat(profile.getKey()).isEqualTo("sw");
assertThat(profile.getLanguage()).isEqualTo("js");
assertThat(profile.getName()).isEqualTo("Sonar way");
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class QProfilesWsMediumTest method bulk_activate_rule_not_all.
@Test
public void bulk_activate_rule_not_all() throws Exception {
QualityProfileDto java = createProfile("java");
QualityProfileDto php = createProfile("php");
createRule(java.getLanguage(), "toto");
createRule(java.getLanguage(), "tata");
createRule(php.getLanguage(), "hello");
createRule(php.getLanguage(), "world");
session.commit();
ruIndexer.index();
// 0. Assert No Active Rule for profile
assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).isEmpty();
// 1. Activate Rule
WsTester.TestRequest request = wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_ACTIVATE_ACTION);
request.setParam(RuleActivationActions.PROFILE_KEY, php.getKey());
request.setParam(PARAM_LANGUAGES, "php");
request.execute().assertJson(getClass(), "bulk_activate_rule_not_all.json");
session.clearCache();
// 2. Assert ActiveRule in DAO
assertThat(db.activeRuleDao().selectByProfileKey(session, php.getKey())).hasSize(2);
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class RulesWsMediumTest method show_rule.
@Test
public void show_rule() throws Exception {
QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
tester.get(QualityProfileDao.class).insert(session, profile);
RuleDto rule = RuleTesting.newXooX1();
ruleDao.insert(session, rule);
ActiveRuleDto activeRuleDto = ActiveRuleDto.createFor(profile, rule).setSeverity("BLOCKER");
tester.get(ActiveRuleDao.class).insert(session, activeRuleDto);
session.commit();
session.clearCache();
ruleIndexer.index();
activeRuleIndexer.index();
// 1. With Activation
WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SHOW_METHOD);
request.setParam(ShowAction.PARAM_KEY, rule.getKey().toString());
request.setParam(ShowAction.PARAM_ACTIVES, "true");
WsTester.Result result = request.execute();
result.assertJson(this.getClass(), "show_rule_active.json");
// 1. Default Activation (defaults to false)
request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SHOW_METHOD);
request.setParam(ShowAction.PARAM_KEY, rule.getKey().toString());
result = request.execute();
result.assertJson(this.getClass(), "show_rule_no_active.json");
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class SearchActionMediumTest method search_profile_active_rules_with_inheritance.
@Test
public void search_profile_active_rules_with_inheritance() throws Exception {
QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
tester.get(QualityProfileDao.class).insert(dbSession, profile);
QualityProfileDto profile2 = QProfileTesting.newXooP2("org-123").setParentKee(profile.getKee());
tester.get(QualityProfileDao.class).insert(dbSession, profile2);
dbSession.commit();
RuleDto rule = RuleTesting.newXooX1();
ruleDao.insert(dbSession, rule);
ActiveRuleDto activeRule = newActiveRule(profile, rule);
tester.get(ActiveRuleDao.class).insert(dbSession, activeRule);
ActiveRuleDto activeRule2 = newActiveRule(profile2, rule).setInheritance(ActiveRuleDto.OVERRIDES).setSeverity(Severity.CRITICAL);
tester.get(ActiveRuleDao.class).insert(dbSession, activeRule2);
dbSession.commit();
ruleIndexer.index();
activeRuleIndexer.index();
WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD);
request.setParam(WebService.Param.TEXT_QUERY, "x1");
request.setParam(PARAM_ACTIVATION, "true");
request.setParam(PARAM_QPROFILE, profile2.getKey());
request.setParam(WebService.Param.FIELDS, "actives");
WsTester.Result result = request.execute();
result.assertJson(this.getClass(), "search_profile_active_rules_inheritance.json");
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class SearchActionMediumTest method search_all_active_rules.
@Test
public void search_all_active_rules() throws Exception {
QualityProfileDto profile = QProfileTesting.newXooP1("org-123");
tester.get(QualityProfileDao.class).insert(dbSession, profile);
RuleDto rule = RuleTesting.newXooX1();
ruleDao.insert(dbSession, rule);
ActiveRuleDto activeRule = newActiveRule(profile, rule);
tester.get(ActiveRuleDao.class).insert(dbSession, activeRule);
dbSession.commit();
ruleIndexer.index();
activeRuleIndexer.index();
WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD);
request.setParam(WebService.Param.TEXT_QUERY, "x1");
request.setParam(PARAM_ACTIVATION, "true");
request.setParam(WebService.Param.FIELDS, "");
WsTester.Result result = request.execute();
result.assertJson(this.getClass(), "search_active_rules.json");
}
Aggregations