use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class AddCommentActionTest method fails_with_IAE_if_parameter_comment_is_missing.
@Test
public void fails_with_IAE_if_parameter_comment_is_missing() {
String key = randomAlphabetic(12);
userSessionRule.logIn();
TestRequest request = actionTester.newRequest().setParam("hotspot", key);
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class).hasMessage("The 'comment' parameter is missing");
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class AddCommentActionTest method fails_with_NotFoundException_if_hotspot_does_not_exist.
@Test
public void fails_with_NotFoundException_if_hotspot_does_not_exist() {
String key = randomAlphabetic(12);
userSessionRule.logIn();
TestRequest request = actionTester.newRequest().setParam("hotspot", key).setParam("comment", randomAlphabetic(10));
assertThatThrownBy(request::execute).isInstanceOf(NotFoundException.class).hasMessage("Hotspot '%s' does not exist", key);
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class SearchActionTest method fails_with_IAE_if_status_parameter_is_neither_TO_REVIEW_or_REVIEWED.
@Test
@UseDataProvider("badStatuses")
public void fails_with_IAE_if_status_parameter_is_neither_TO_REVIEW_or_REVIEWED(String badStatus) {
TestRequest request = actionTester.newRequest().setParam("projectKey", randomAlphabetic(13)).setParam("status", badStatus);
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class).hasMessage("Value of parameter 'status' (" + badStatus + ") must be one of: [TO_REVIEW, REVIEWED]");
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class SearchActionTest method fail_if_hotspots_provided_with_onlyMine_param.
@Test
public void fail_if_hotspots_provided_with_onlyMine_param() {
ComponentDto project = dbTester.components().insertPrivateProject();
userSessionRule.registerComponents(project);
userSessionRule.logIn().addProjectPermission(USER, project);
TestRequest request = actionTester.newRequest().setParam("hotspots", IntStream.range(2, 10).mapToObj(String::valueOf).collect(joining(","))).setParam("onlyMine", "true");
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class).hasMessage("Parameter 'onlyMine' can be used with parameter 'projectKey' only");
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class EditCommentActionTest method fails_if_trying_to_delete_comment_of_another_user_in_public_project.
@Test
public void fails_if_trying_to_delete_comment_of_another_user_in_public_project() {
UserDto userTryingToEdit = dbTester.users().insertUser();
UserDto userWithHotspotComment = dbTester.users().insertUser();
ComponentDto project = dbTester.components().insertPublicProject();
IssueDto hotspot = dbTester.issues().insertHotspot(h -> h.setProject(project));
IssueChangeDto comment = dbTester.issues().insertComment(hotspot, userWithHotspotComment, "Some comment");
userSessionRule.logIn(userTryingToEdit).registerComponents(project);
TestRequest request = newRequest(comment.getKey(), "new comment");
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class).hasMessage("You can only edit your own comments");
}
Aggregations