use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class TreeActionTest method fail_when_using_branch_db_key.
@Test
public void fail_when_using_branch_db_key() {
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
ComponentDto branch = db.components().insertProjectBranch(project);
TestRequest request = ws.newRequest().setParam(PARAM_COMPONENT, branch.getDbKey());
assertThatThrownBy(() -> request.executeProtobuf(Components.ShowWsResponse.class)).isInstanceOf(NotFoundException.class).hasMessage(format("Component key '%s' not found", branch.getDbKey()));
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class TreeActionTest method fail_when_base_component_is_removed.
@Test
public void fail_when_base_component_is_removed() {
ComponentDto project = db.components().insertComponent(newPrivateProjectDto());
db.components().insertComponent(ComponentTesting.newFileDto(project).setDbKey("file-key").setEnabled(false));
logInWithBrowsePermission(project);
TestRequest request = ws.newRequest().setParam(PARAM_COMPONENT, "file-key");
assertThatThrownBy(request::execute).isInstanceOf(NotFoundException.class).hasMessage("Component key 'file-key' not found");
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class ShowActionTest method fail_if_file_does_not_exist.
@Test
public void fail_if_file_does_not_exist() {
TestRequest request = newBaseRequest().setParam("key", "missing");
assertThatThrownBy(request::execute).isInstanceOf(NotFoundException.class);
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class ShowActionTest method fail_if_user_is_not_allowed_to_access_project.
@Test
public void fail_if_user_is_not_allowed_to_access_project() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
TestRequest request = newBaseRequest().setParam("key", file.getDbKey());
assertThatThrownBy(request::execute).isInstanceOf(ForbiddenException.class);
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class AppActionTest method fail_if_no_parameter_provided.
@Test
public void fail_if_no_parameter_provided() {
TestRequest request = ws.newRequest();
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class).hasMessage("The 'component' parameter is missing");
}
Aggregations