use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class TreeActionTest method fail_when_search_query_has_less_than_3_characters.
@Test
public void fail_when_search_query_has_less_than_3_characters() {
ComponentDto project = db.components().insertComponent(newPrivateProjectDto("project-uuid"));
db.commit();
TestRequest request = ws.newRequest().setParam(PARAM_COMPONENT, project.getDbKey()).setParam(Param.TEXT_QUERY, "fi");
assertThatThrownBy(request::execute).isInstanceOf(IllegalArgumentException.class).hasMessage("'q' length (2) is shorter than the minimum authorized (3)");
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class SearchActionTest method call.
private SearchWsResponse call(SearchRequest wsRequest) {
TestRequest request = underTest.newRequest();
ofNullable(wsRequest.getQualifiers()).ifPresent(p1 -> request.setParam(PARAM_QUALIFIERS, Joiner.on(",").join(p1)));
ofNullable(wsRequest.getQuery()).ifPresent(p -> request.setParam(TEXT_QUERY, p));
ofNullable(wsRequest.getPage()).ifPresent(page -> request.setParam(PAGE, String.valueOf(page)));
ofNullable(wsRequest.getPageSize()).ifPresent(pageSize -> request.setParam(PAGE_SIZE, String.valueOf(pageSize)));
return request.executeProtobuf(SearchWsResponse.class);
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class ShowActionTest method fail_if_branch_does_not_exist.
@Test
public void fail_if_branch_does_not_exist() {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
userSession.addProjectPermission(UserRole.USER, project);
db.components().insertProjectBranch(project, b -> b.setKey("my_branch"));
TestRequest request = ws.newRequest().setParam(PARAM_COMPONENT, file.getKey()).setParam(PARAM_BRANCH, "another_branch");
assertThatThrownBy(request::execute).isInstanceOf(NotFoundException.class).hasMessage(String.format("Component '%s' on branch '%s' not found", file.getKey(), "another_branch"));
}
use of org.sonar.server.ws.TestRequest in project sonarqube by SonarSource.
the class ShowActionTest 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(ShowWsResponse.class)).isInstanceOf(NotFoundException.class).hasMessage(String.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_not_found.
@Test
public void fail_when_base_component_not_found() {
TestRequest request = ws.newRequest().setParam(PARAM_COMPONENT, "project-key");
assertThatThrownBy(request::execute).isInstanceOf(NotFoundException.class);
}
Aggregations