use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class QProfileExportersTest method import_xml_return_messages.
@Test
public void import_xml_return_messages() {
QProfileDto profile = createProfile();
QProfileResult result = underTest.importXml(profile, "XooProfileImporterWithMessages", toInputStream("<xml/>", UTF_8), db.getSession());
assertThat(result.infos()).containsOnly("an info");
assertThat(result.warnings()).containsOnly("a warning");
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class QProfileExportersTest method export_empty_profile.
@Test
public void export_empty_profile() {
QProfileDto profile = createProfile();
StringWriter writer = new StringWriter();
underTest.export(db.getSession(), profile, "standard", writer);
assertThat(writer.toString()).isEqualTo("standard -> " + profile.getName() + " -> 0");
writer = new StringWriter();
underTest.export(db.getSession(), profile, "xootool", writer);
assertThat(writer.toString()).isEqualTo("xoo -> " + profile.getName() + " -> 0");
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class AddGroupActionTest method uses_global_permission.
@Test
public void uses_global_permission() {
QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO));
GroupDto group = db.users().insertGroup();
userSession.logIn().addPermission(GlobalPermission.ADMINISTER_QUALITY_PROFILES);
ws.newRequest().setParam(PARAM_QUALITY_PROFILE, profile.getName()).setParam(PARAM_LANGUAGE, XOO).setParam(PARAM_GROUP, group.getName()).execute();
assertThat(db.getDbClient().qProfileEditGroupsDao().exists(db.getSession(), profile, group)).isTrue();
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class AddGroupActionTest method does_nothing_when_group_can_already_edit_profile.
@Test
public void does_nothing_when_group_can_already_edit_profile() {
QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage(XOO));
GroupDto group = db.users().insertGroup();
db.qualityProfiles().addGroupPermission(profile, group);
assertThat(db.getDbClient().qProfileEditGroupsDao().exists(db.getSession(), profile, group)).isTrue();
userSession.logIn().addPermission(GlobalPermission.ADMINISTER_QUALITY_PROFILES);
ws.newRequest().setParam(PARAM_QUALITY_PROFILE, profile.getName()).setParam(PARAM_LANGUAGE, XOO).setParam(PARAM_GROUP, group.getName()).execute();
assertThat(db.getDbClient().qProfileEditGroupsDao().exists(db.getSession(), profile, group)).isTrue();
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class AddGroupActionTest method fail_when_wrong_language.
@Test
public void fail_when_wrong_language() {
QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage("unknown"));
UserDto user = db.users().insertUser();
userSession.logIn().addPermission(GlobalPermission.ADMINISTER_QUALITY_PROFILES);
assertThatThrownBy(() -> {
ws.newRequest().setParam(PARAM_QUALITY_PROFILE, profile.getName()).setParam(PARAM_LANGUAGE, XOO).setParam(PARAM_GROUP, user.getLogin()).execute();
}).isInstanceOf(NotFoundException.class).hasMessage(format("Quality Profile for language 'xoo' and name '%s' does not exist", profile.getName()));
}
Aggregations