use of org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile in project sonarqube by SonarSource.
the class SearchActionTest method filter_on_deprecated_project_key_and_default.
@Test
public void filter_on_deprecated_project_key_and_default() {
ProjectDto project = db.components().insertPrivateProjectDto();
QProfileDto profileOnXoo1 = db.qualityProfiles().insert(q -> q.setLanguage(XOO1.getKey()));
QProfileDto defaultProfileOnXoo1 = db.qualityProfiles().insert(q -> q.setLanguage(XOO1.getKey()));
QProfileDto defaultProfileOnXoo2 = db.qualityProfiles().insert(q -> q.setLanguage(XOO2.getKey()));
db.qualityProfiles().associateWithProject(project, profileOnXoo1);
db.qualityProfiles().setAsDefault(defaultProfileOnXoo1, defaultProfileOnXoo2);
SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT_KEY, project.getKey()).setParam(PARAM_DEFAULTS, "true"));
assertThat(result.getProfilesList()).extracting(QualityProfile::getKey).containsExactlyInAnyOrder(defaultProfileOnXoo2.getKee()).doesNotContain(defaultProfileOnXoo1.getKee(), profileOnXoo1.getKee());
}
use of org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile in project sonarqube by SonarSource.
the class SearchActionTest method filter_on_project_key.
@Test
public void filter_on_project_key() {
ProjectDto project = db.components().insertPrivateProjectDto();
QProfileDto profileOnXoo1 = db.qualityProfiles().insert(q -> q.setLanguage(XOO1.getKey()));
QProfileDto defaultProfileOnXoo1 = db.qualityProfiles().insert(q -> q.setLanguage(XOO1.getKey()));
QProfileDto defaultProfileOnXoo2 = db.qualityProfiles().insert(q -> q.setLanguage(XOO2.getKey()));
db.qualityProfiles().associateWithProject(project, profileOnXoo1);
db.qualityProfiles().setAsDefault(defaultProfileOnXoo1, defaultProfileOnXoo2);
SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT, project.getKey()));
assertThat(result.getProfilesList()).extracting(QualityProfile::getKey).containsExactlyInAnyOrder(profileOnXoo1.getKee(), defaultProfileOnXoo2.getKee()).doesNotContain(defaultProfileOnXoo1.getKee());
}
use of org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile in project sonarqube by SonarSource.
the class SearchActionTest method actions_when_user_is_global_qprofile_administer.
@Test
public void actions_when_user_is_global_qprofile_administer() {
QProfileDto customProfile = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()));
QProfileDto builtInProfile = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()).setIsBuiltIn(true));
QProfileDto defaultProfile = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()));
db.qualityProfiles().setAsDefault(defaultProfile);
UserDto user = db.users().insertUser();
userSession.logIn(user).addPermission(GlobalPermission.ADMINISTER_QUALITY_PROFILES);
SearchWsResponse result = call(ws.newRequest());
assertThat(result.getProfilesList()).extracting(QualityProfile::getKey, qp -> qp.getActions().getEdit(), qp -> qp.getActions().getCopy(), qp -> qp.getActions().getSetAsDefault(), qp -> qp.getActions().getDelete(), qp -> qp.getActions().getAssociateProjects()).containsExactlyInAnyOrder(tuple(customProfile.getKee(), true, true, true, true, true), tuple(builtInProfile.getKee(), false, true, true, false, true), tuple(defaultProfile.getKee(), true, true, false, false, false));
assertThat(result.getActions().getCreate()).isTrue();
}
use of org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile in project sonarqube by SonarSource.
the class SearchActionTest method filter_on_project_key_and_default.
@Test
public void filter_on_project_key_and_default() {
ProjectDto project = db.components().insertPrivateProjectDto();
QProfileDto profileOnXoo1 = db.qualityProfiles().insert(q -> q.setLanguage(XOO1.getKey()));
QProfileDto defaultProfileOnXoo1 = db.qualityProfiles().insert(q -> q.setLanguage(XOO1.getKey()));
QProfileDto defaultProfileOnXoo2 = db.qualityProfiles().insert(q -> q.setLanguage(XOO2.getKey()));
db.qualityProfiles().associateWithProject(project, profileOnXoo1);
db.qualityProfiles().setAsDefault(defaultProfileOnXoo1, defaultProfileOnXoo2);
SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT, project.getKey()).setParam(PARAM_DEFAULTS, "true"));
assertThat(result.getProfilesList()).extracting(QualityProfile::getKey).containsExactlyInAnyOrder(defaultProfileOnXoo2.getKee()).doesNotContain(defaultProfileOnXoo1.getKee(), profileOnXoo1.getKee());
}
use of org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile in project sonarqube by SonarSource.
the class SearchActionTest method filter_on_default_profile.
@Test
public void filter_on_default_profile() {
QProfileDto defaultProfile1 = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()));
QProfileDto defaultProfile2 = db.qualityProfiles().insert(p -> p.setLanguage(XOO2.getKey()));
QProfileDto nonDefaultProfile = db.qualityProfiles().insert(p -> p.setLanguage(XOO1.getKey()));
db.qualityProfiles().setAsDefault(defaultProfile1, defaultProfile2);
SearchWsResponse result = call(ws.newRequest().setParam(PARAM_DEFAULTS, "true"));
assertThat(result.getProfilesList()).extracting(QualityProfile::getKey).containsExactlyInAnyOrder(defaultProfile1.getKee(), defaultProfile2.getKee()).doesNotContain(nonDefaultProfile.getKee());
}
Aggregations