use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class AddProjectActionTest method as_qprofile_editor.
@Test
public void as_qprofile_editor() {
UserDto user = db.users().insertUser();
QProfileDto qualityProfile = db.qualityProfiles().insert(qp -> qp.setLanguage(LANGUAGE_1));
db.qualityProfiles().addUserPermission(qualityProfile, user);
ProjectDto project = db.components().insertPrivateProjectDto();
userSession.logIn(user);
call(project, qualityProfile);
assertProjectIsAssociatedToProfile(project, qualityProfile);
verify(qualityProfileChangeEventService).publishRuleActivationToSonarLintClients(project, qualityProfile, null);
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class AddProjectActionTest method assertProjectIsAssociatedToProfile.
private void assertProjectIsAssociatedToProfile(ProjectDto project, QProfileDto profile) {
QProfileDto loaded = dbClient.qualityProfileDao().selectAssociatedToProjectAndLanguage(db.getSession(), project, profile.getLanguage());
assertThat(loaded.getKee()).isEqualTo(profile.getKee());
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class AddProjectActionTest method changing_association_does_not_change_other_language_associations.
@Test
public void changing_association_does_not_change_other_language_associations() {
logInAsProfileAdmin();
ProjectDto project = db.components().insertPrivateProjectDto();
QProfileDto profile1Language1 = db.qualityProfiles().insert(p -> p.setLanguage(LANGUAGE_1));
QProfileDto profile2Language2 = db.qualityProfiles().insert(p -> p.setLanguage(LANGUAGE_2));
QProfileDto profile3Language1 = db.qualityProfiles().insert(p -> p.setLanguage(LANGUAGE_1));
db.qualityProfiles().associateWithProject(project, profile1Language1, profile2Language2);
call(project, profile3Language1);
assertProjectIsAssociatedToProfile(project, profile3Language1);
assertProjectIsAssociatedToProfile(project, profile2Language2);
verify(qualityProfileChangeEventService).publishRuleActivationToSonarLintClients(project, profile3Language1, profile1Language1);
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class ActivateRuleActionTest method fail_activate_if_built_in_profile.
@Test
public void fail_activate_if_built_in_profile() {
userSession.logIn(db.users().insertUser()).addPermission(GlobalPermission.ADMINISTER_QUALITY_PROFILES);
QProfileDto qualityProfile = db.qualityProfiles().insert(profile -> profile.setIsBuiltIn(true).setName("Xoo profile").setLanguage("xoo"));
TestRequest request = ws.newRequest().setMethod("POST").setParam(PARAM_RULE, RuleTesting.newRule().getKey().toString()).setParam(PARAM_KEY, qualityProfile.getKee());
assertThatThrownBy(() -> request.execute()).isInstanceOf(BadRequestException.class).hasMessage("Operation forbidden for built-in Quality Profile 'Xoo profile' with language 'xoo'");
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class QProfileExportersTest method fail_to_import_xml_on_unknown_importer.
@Test
public void fail_to_import_xml_on_unknown_importer() {
QProfileDto qProfileDto = newQualityProfileDto();
InputStream inputStream = toInputStream("<xml/>", UTF_8);
DbSession dbSession = db.getSession();
assertThatThrownBy(() -> underTest.importXml(qProfileDto, "Unknown", inputStream, dbSession)).isInstanceOf(BadRequestException.class).hasMessage("No such importer : Unknown");
}
Aggregations