use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class BuiltInQProfileInsertImplTest method existing_default_profile_must_not_be_changed.
@Test
public void existing_default_profile_must_not_be_changed() {
BuiltInQualityProfilesDefinition.Context context = new BuiltInQualityProfilesDefinition.Context();
NewBuiltInQualityProfile newQp = context.createBuiltInQualityProfile("the name", "xoo").setDefault(true);
newQp.done();
BuiltInQProfile builtIn = builtInQProfileRepository.create(context.profile("xoo", "the name"));
QProfileDto currentDefault = db.qualityProfiles().insert(p -> p.setLanguage("xoo"));
db.qualityProfiles().setAsDefault(currentDefault);
call(builtIn);
QProfileDto defaultProfile = db.getDbClient().qualityProfileDao().selectDefaultProfile(dbSession, "xoo");
assertThat(defaultProfile.getKee()).isEqualTo(currentDefault.getKee());
verifyTableSize("rules_profiles", 2);
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class BuiltInQProfileInsertImplTest method verifyProfileInDb.
private QProfileDto verifyProfileInDb(BuiltInQProfile builtIn) {
QProfileDto profileOnOrg1 = db.getDbClient().qualityProfileDao().selectByNameAndLanguage(dbSession, builtIn.getName(), builtIn.getLanguage());
assertThat(profileOnOrg1.getLanguage()).isEqualTo(builtIn.getLanguage());
assertThat(profileOnOrg1.getName()).isEqualTo(builtIn.getName());
assertThat(profileOnOrg1.getParentKee()).isNull();
assertThat(profileOnOrg1.getLastUsed()).isNull();
assertThat(profileOnOrg1.getUserUpdatedAt()).isNull();
assertThat(profileOnOrg1.getRulesUpdatedAt()).isNotEmpty();
assertThat(profileOnOrg1.getKee()).isNotEqualTo(profileOnOrg1.getRulesProfileUuid());
assertThat(profileOnOrg1.getRulesProfileUuid()).isNotNull();
return profileOnOrg1;
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class ActivateRulesActionTest method fail_if_built_in_profile.
@Test
public void fail_if_built_in_profile() {
userSession.logIn().addPermission(ADMINISTER_QUALITY_PROFILES);
QProfileDto qualityProfile = db.qualityProfiles().insert(p -> p.setIsBuiltIn(true));
TestRequest request = ws.newRequest().setMethod("POST").setParam(PARAM_TARGET_KEY, qualityProfile.getKee());
assertThatThrownBy(() -> request.execute()).isInstanceOf(BadRequestException.class);
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class ActivateRulesActionTest method as_qprofile_editor.
@Test
public void as_qprofile_editor() {
UserDto user = db.users().insertUser();
GroupDto group = db.users().insertGroup();
QProfileDto qualityProfile = db.qualityProfiles().insert();
db.qualityProfiles().addGroupPermission(qualityProfile, group);
userSession.logIn(user).setGroups(group);
ws.newRequest().setMethod("POST").setParam(PARAM_TARGET_KEY, qualityProfile.getKee()).execute();
verify(qProfileRules).bulkActivateAndCommit(any(), any(), any(), any());
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class ActivateRulesActionTest method as_global_qprofile_admin.
@Test
public void as_global_qprofile_admin() {
userSession.logIn(db.users().insertUser()).addPermission(ADMINISTER_QUALITY_PROFILES);
QProfileDto qualityProfile = db.qualityProfiles().insert();
ws.newRequest().setMethod("POST").setParam(PARAM_TARGET_KEY, qualityProfile.getKee()).execute();
verify(qProfileRules).bulkActivateAndCommit(any(), any(), any(), any());
}
Aggregations