use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class ChangeStatusActionTest method fails_with_NotFoundException_if_hotspot_is_closed.
@Test
@UseDataProvider("validStatusAndResolutions")
public void fails_with_NotFoundException_if_hotspot_is_closed(String status, @Nullable String resolution) {
ComponentDto project = dbTester.components().insertPublicProject();
ComponentDto file = dbTester.components().insertComponent(newFileDto(project));
RuleDefinitionDto rule = newRule(SECURITY_HOTSPOT);
IssueDto closedHotspot = dbTester.issues().insertHotspot(rule, project, file, t -> t.setStatus(STATUS_CLOSED));
userSessionRule.logIn();
TestRequest request = actionTester.newRequest().setParam("hotspot", closedHotspot.getKey()).setParam("status", status);
if (resolution != null) {
request.setParam("resolution", resolution);
}
assertThatThrownBy(request::execute).isInstanceOf(NotFoundException.class).hasMessage("Hotspot '%s' does not exist", closedHotspot.getKey());
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class ChangeStatusActionTest method fails_with_NotFoundException_if_hotspot_does_not_exist.
@Test
@UseDataProvider("validStatusAndResolutions")
public void fails_with_NotFoundException_if_hotspot_does_not_exist(String status, @Nullable String resolution) {
String key = randomAlphabetic(12);
userSessionRule.logIn();
TestRequest request = actionTester.newRequest().setParam("hotspot", key).setParam("status", status);
if (resolution != null) {
request.setParam("resolution", resolution);
}
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 ChangeStatusActionTest method fail_with_IAE_if_status_is_TO_REVIEW_and_resolution_is_set.
@Test
@UseDataProvider("validResolutions")
public void fail_with_IAE_if_status_is_TO_REVIEW_and_resolution_is_set(String resolution) {
String key = randomAlphabetic(12);
userSessionRule.logIn();
TestRequest request = actionTester.newRequest().setParam("hotspot", key).setParam("status", STATUS_TO_REVIEW).setParam("resolution", resolution);
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class).hasMessage("Parameter 'resolution' must not be specified when Parameter 'status' has value 'TO_REVIEW'");
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class ChangeStatusActionTest method fails_with_UnauthorizedException_if_user_is_anonymous.
@Test
public void fails_with_UnauthorizedException_if_user_is_anonymous() {
userSessionRule.anonymous();
TestRequest request = actionTester.newRequest();
assertThatThrownBy(request::execute).isInstanceOf(UnauthorizedException.class).hasMessage("Authentication is required");
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class ChangeStatusActionTest method fails_with_IAE_if_parameter_status_is_missing.
@Test
public void fails_with_IAE_if_parameter_status_is_missing() {
String key = randomAlphabetic(12);
userSessionRule.logIn();
TestRequest request = actionTester.newRequest().setParam("hotspot", key);
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class).hasMessage("The 'status' parameter is missing");
}
Aggregations