use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class AddProjectActionTest method throw_NotFoundException_if_project_does_not_exist.
@Test
public void throw_NotFoundException_if_project_does_not_exist() {
logInAsProfileAdmin();
QProfileDto profile = db.qualityProfiles().insert();
assertThatThrownBy(() -> {
tester.newRequest().setParam("project", "unknown").setParam("profileKey", profile.getKee()).execute();
}).isInstanceOf(NotFoundException.class).hasMessage("Project 'unknown' not found");
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class AddProjectActionTest method project_administrator_can_change_profile.
@Test
public void project_administrator_can_change_profile() {
ProjectDto project = db.components().insertPrivateProjectDto();
QProfileDto profile = db.qualityProfiles().insert(qp -> qp.setLanguage("xoo"));
userSession.logIn(db.users().insertUser()).addProjectPermission(UserRole.ADMIN, project);
call(project, profile);
assertProjectIsAssociatedToProfile(project, profile);
verify(qualityProfileChangeEventService).publishRuleActivationToSonarLintClients(project, profile, null);
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class AddProjectActionTest method throw_ForbiddenException_if_not_project_nor_global_administrator.
@Test
public void throw_ForbiddenException_if_not_project_nor_global_administrator() {
userSession.logIn(db.users().insertUser());
ProjectDto project = db.components().insertPrivateProjectDto();
QProfileDto profile = db.qualityProfiles().insert(qp -> qp.setLanguage("xoo"));
assertThatThrownBy(() -> call(project, profile)).isInstanceOf(ForbiddenException.class).hasMessage("Insufficient privileges");
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class AddProjectActionTest method throw_UnauthorizedException_if_not_logged_in.
@Test
public void throw_UnauthorizedException_if_not_logged_in() {
userSession.anonymous();
ProjectDto project = db.components().insertPrivateProjectDto();
QProfileDto profile = db.qualityProfiles().insert();
assertThatThrownBy(() -> call(project, profile)).isInstanceOf(UnauthorizedException.class).hasMessage("Authentication is required");
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class AddProjectActionTest method add_project_on_profile.
@Test
public void add_project_on_profile() {
logInAsProfileAdmin();
ProjectDto project = db.components().insertPrivateProjectDto();
QProfileDto profile = db.qualityProfiles().insert(qp -> qp.setLanguage("xoo"));
TestResponse response = call(project, profile);
assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT);
assertProjectIsAssociatedToProfile(project, profile);
verify(qualityProfileChangeEventService).publishRuleActivationToSonarLintClients(project, profile, null);
}
Aggregations