use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class SearchActionTest method fails_with_NotFoundException_if_project_does_not_exist.
@Test
public void fails_with_NotFoundException_if_project_does_not_exist() {
String key = randomAlphabetic(12);
TestRequest request = actionTester.newRequest().setParam("projectKey", key);
assertThatThrownBy(request::execute).isInstanceOf(NotFoundException.class).hasMessage("Project '%s' not found", key);
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class SearchActionTest method fails_with_IAE_if_parameters_projectKey_and_hotspots_are_missing.
@Test
public void fails_with_IAE_if_parameters_projectKey_and_hotspots_are_missing() {
TestRequest request = actionTester.newRequest();
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class).hasMessage("A value must be provided for either parameter 'projectKey' or parameter 'hotspots'");
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class SearchActionTest method fails_with_NotFoundException_if_project_is_neither_a_project_nor_an_application.
@Test
public void fails_with_NotFoundException_if_project_is_neither_a_project_nor_an_application() {
ComponentDto project = dbTester.components().insertPrivateProject();
ComponentDto directory = dbTester.components().insertComponent(ComponentTesting.newDirectory(project, "foo"));
ComponentDto file = dbTester.components().insertComponent(ComponentTesting.newFileDto(project));
ComponentDto portfolio = dbTester.components().insertPrivatePortfolio();
TestRequest request = actionTester.newRequest();
for (ComponentDto component : Arrays.asList(directory, file, portfolio)) {
request.setParam("projectKey", component.getKey());
assertThatThrownBy(request::execute).isInstanceOf(NotFoundException.class).hasMessage("Project '%s' not found", component.getKey());
}
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class ChangeStatusActionTest method fails_with_ForbiddenException_if_project_is_public_and_user_has_no_HotspotAdmin_permission_on_it.
@Test
@UseDataProvider("anyPublicProjectPermissionButHotspotAdmin")
public void fails_with_ForbiddenException_if_project_is_public_and_user_has_no_HotspotAdmin_permission_on_it(String permission) {
ComponentDto project = dbTester.components().insertPublicProject();
userSessionRule.logIn().registerComponents(project).addProjectPermission(permission, project);
ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
IssueDto hotspot = dbTester.issues().insertHotspot(project, file);
Arrays.stream(validStatusAndResolutions()).forEach(o -> {
String status = (String) o[0];
String resolution = (String) o[1];
TestRequest request = newRequest(hotspot, status, resolution, NO_COMMENT);
assertThatThrownBy(request::execute).isInstanceOf(ForbiddenException.class).hasMessage("Insufficient privileges");
});
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class ChangeStatusActionTest method fail_with_IAE_if_status_value_is_neither_REVIEWED_nor_TO_REVIEW.
@Test
@UseDataProvider("badStatuses")
public void fail_with_IAE_if_status_value_is_neither_REVIEWED_nor_TO_REVIEW(String badStatus) {
String key = randomAlphabetic(12);
userSessionRule.logIn();
TestRequest request = actionTester.newRequest().setParam("hotspot", key).setParam("status", badStatus);
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class).hasMessage("Value of parameter 'status' (" + badStatus + ") must be one of: [TO_REVIEW, REVIEWED]");
}
Aggregations