use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class ExportActionTest method does_not_fail_when_no_exporters.
@Test
public void does_not_fail_when_no_exporters() throws Exception {
QualityProfileDto profile = db.qualityProfiles().insertQualityProfile(QProfileTesting.newXooP1("org-123"));
newWsActionTester().newRequest().setParam("language", "xoo").setParam("name", profile.getName()).execute();
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class ExportActionTest method export_without_format.
@Test
public void export_without_format() throws Exception {
QualityProfileDto profile = db.qualityProfiles().insertQualityProfile(QProfileTesting.newXooP1("org-123"));
doAnswer(invocation -> {
invocation.getArgumentAt(2, Writer.class).write("As exported by SQ !");
return null;
}).when(backuper).backup(any(DbSession.class), any(QualityProfileDto.class), any(Writer.class));
String result = newWsActionTester().newRequest().setParam("language", profile.getLanguage()).setParam("name", profile.getName()).execute().getInput();
assertThat(result).isEqualTo("As exported by SQ !");
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class InheritanceActionMediumTest method createProfile.
private QualityProfileDto createProfile(String lang, String name, String key) {
QualityProfileDto profile = QProfileTesting.newQProfileDto("org-123", new QProfileName(lang, name), key);
db.qualityProfileDao().insert(session, profile);
session.commit();
return profile;
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class ChangeParentActionMediumTest method change_parent_with_no_parent_before.
@Test
public void change_parent_with_no_parent_before() throws Exception {
QualityProfileDto parent1 = createProfile("xoo", "Parent 1");
QualityProfileDto child = createProfile("xoo", "Child");
RuleDto rule1 = createRule("xoo", "rule1");
createActiveRule(rule1, parent1);
session.commit();
ruleIndexer.index();
activeRuleIndexer.index();
assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
// Set parent
wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent").setParam(QProfileRef.PARAM_PROFILE_KEY, child.getKey()).setParam("parentKey", parent1.getKey()).execute();
session.clearCache();
// Check rule 1 enabled
List<ActiveRuleDto> activeRules1 = db.activeRuleDao().selectByProfileKey(session, child.getKey());
assertThat(activeRules1).hasSize(1);
assertThat(activeRules1.get(0).getKey().ruleKey().rule()).isEqualTo("rule1");
assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKey()), new SearchOptions()).getIds()).hasSize(1);
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class ChangeParentActionMediumTest method remove_parent_with_empty_key.
@Test
public void remove_parent_with_empty_key() throws Exception {
QualityProfileDto parent = createProfile("xoo", "Parent 1");
QualityProfileDto child = createProfile("xoo", "Child");
RuleDto rule1 = createRule("xoo", "rule1");
createActiveRule(rule1, parent);
session.commit();
ruleIndexer.index();
activeRuleIndexer.index();
assertThat(db.activeRuleDao().selectByProfileKey(session, child.getKey())).isEmpty();
// Set parent
tester.get(RuleActivator.class).setParent(session, child.getKey(), parent.getKey());
session.clearCache();
// Remove parent
wsTester.newPostRequest(QProfilesWs.API_ENDPOINT, "change_parent").setParam(QProfileRef.PARAM_PROFILE_KEY, child.getKey()).setParam("parentKey", "").execute();
session.clearCache();
// Check no rule enabled
List<ActiveRuleDto> activeRules = db.activeRuleDao().selectByProfileKey(session, child.getKey());
assertThat(activeRules).isEmpty();
assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfileKey(child.getKey()), new SearchOptions()).getIds()).isEmpty();
}
Aggregations