use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class QProfileFactoryImplTest method delete_removes_qprofile_edit_permissions.
@Test
public void delete_removes_qprofile_edit_permissions() {
QProfileDto profile = db.qualityProfiles().insert();
UserDto user = db.users().insertUser();
db.qualityProfiles().addUserPermission(profile, user);
GroupDto group = db.users().insertGroup();
db.qualityProfiles().addGroupPermission(profile, group);
underTest.delete(dbSession, asList(profile));
assertThat(db.countRowsOfTable(dbSession, "qprofile_edit_users")).isZero();
assertThat(db.countRowsOfTable(dbSession, "qprofile_edit_groups")).isZero();
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class QProfileFactoryImplTest method delete_accepts_empty_list_of_keys.
@Test
public void delete_accepts_empty_list_of_keys() {
QProfileDto profile = createCustomProfile();
underTest.delete(dbSession, Collections.emptyList());
verifyZeroInteractions(activeRuleIndexer);
assertQualityProfileFromDb(profile).isNotNull();
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class QProfileFactoryImplTest method createCustomProfile.
private QProfileDto createCustomProfile() {
QProfileDto profile = db.qualityProfiles().insert(p -> p.setLanguage("xoo").setIsBuiltIn(false));
ActiveRuleDto activeRuleDto = db.qualityProfiles().activateRule(profile, rule);
ActiveRuleParamDto activeRuleParam = new ActiveRuleParamDto().setRulesParameterUuid(ruleParam.getUuid()).setKey("foo").setValue("bar");
db.getDbClient().activeRuleDao().insertParam(dbSession, activeRuleDto, activeRuleParam);
db.getDbClient().qProfileChangeDao().insert(dbSession, new QProfileChangeDto().setChangeType(ActiveRuleChange.Type.ACTIVATED.name()).setRulesProfileUuid(profile.getRulesProfileUuid()));
db.commit();
return profile;
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class QProfileFactoryImplTest method delete_builtin_profile_associated_to_project.
@Test
public void delete_builtin_profile_associated_to_project() {
RulesProfileDto builtInProfile = createBuiltInProfile();
ProjectDto project = db.components().insertPrivateProjectDto();
QProfileDto profile = associateBuiltInProfile(builtInProfile);
db.qualityProfiles().associateWithProject(project, profile);
assertThat(db.getDbClient().qualityProfileDao().selectAssociatedToProjectAndLanguage(dbSession, project, profile.getLanguage())).isNotNull();
underTest.delete(dbSession, asList(profile));
verifyNoCallsActiveRuleIndexerDelete();
// remove only from org_qprofiles and project_qprofiles
assertThat(db.getDbClient().qualityProfileDao().selectAll(dbSession)).isEmpty();
assertThat(db.getDbClient().qualityProfileDao().selectAssociatedToProjectAndLanguage(dbSession, project, profile.getLanguage())).isNull();
assertThatRulesProfileExists(builtInProfile);
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class QProfileFactoryImplTest method delete_removes_custom_profile_from_project_associations.
@Test
public void delete_removes_custom_profile_from_project_associations() {
QProfileDto profile = createCustomProfile();
ProjectDto project = db.components().insertPrivateProjectDto();
db.qualityProfiles().associateWithProject(project, profile);
underTest.delete(dbSession, asList(profile));
assertThatCustomProfileDoesNotExist(profile);
}
Aggregations