Search in sources :

Example 1 with SearchWsResponse

use of org.sonarqube.ws.ProjectLinks.SearchWsResponse in project sonarqube by SonarSource.

the class SearchAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    SearchRequest searchWsRequest = toSearchWsRequest(request);
    SearchWsResponse searchWsResponse = doHandle(searchWsRequest);
    writeProtobuf(searchWsResponse, request, response);
}
Also used : SearchWsResponse(org.sonarqube.ws.ProjectLinks.SearchWsResponse)

Example 2 with SearchWsResponse

use of org.sonarqube.ws.ProjectLinks.SearchWsResponse in project sonarqube by SonarSource.

the class SearchActionTest method several_projects.

@Test
public void several_projects() {
    ComponentDto project1 = db.components().insertPrivateProject();
    ComponentDto project2 = db.components().insertPrivateProject();
    ProjectLinkDto link1 = db.componentLinks().insertCustomLink(project1);
    ProjectLinkDto link2 = db.componentLinks().insertCustomLink(project2);
    userSession.logIn().setRoot();
    SearchWsResponse response = callByKey(project1.getKey());
    assertThat(response.getLinksList()).extracting(Link::getId, Link::getName).containsExactlyInAnyOrder(tuple(link1.getUuid(), link1.getName()));
}
Also used : ProjectLinkDto(org.sonar.db.component.ProjectLinkDto) ComponentDto(org.sonar.db.component.ComponentDto) SearchWsResponse(org.sonarqube.ws.ProjectLinks.SearchWsResponse) Test(org.junit.Test)

Example 3 with SearchWsResponse

use of org.sonarqube.ws.ProjectLinks.SearchWsResponse in project sonarqube by SonarSource.

the class SearchActionTest method response_fields.

@Test
public void response_fields() {
    ComponentDto project = db.components().insertPrivateProject();
    ProjectLinkDto homepageLink = db.componentLinks().insertProvidedLink(project);
    ProjectLinkDto customLink = db.componentLinks().insertCustomLink(project);
    logInAsProjectAdministrator(project);
    SearchWsResponse response = callByKey(project.getKey());
    assertThat(response.getLinksList()).extracting(Link::getId, Link::getName, Link::getType, Link::getUrl).containsExactlyInAnyOrder(tuple(homepageLink.getUuid(), "", homepageLink.getType(), homepageLink.getHref()), tuple(customLink.getUuid(), customLink.getName(), customLink.getType(), customLink.getHref()));
}
Also used : ProjectLinkDto(org.sonar.db.component.ProjectLinkDto) ComponentDto(org.sonar.db.component.ComponentDto) SearchWsResponse(org.sonarqube.ws.ProjectLinks.SearchWsResponse) Test(org.junit.Test)

Example 4 with SearchWsResponse

use of org.sonarqube.ws.ProjectLinks.SearchWsResponse in project sonarqube by SonarSource.

the class SearchActionTest method project_user_can_search_for_links.

@Test
public void project_user_can_search_for_links() {
    ComponentDto project = db.components().insertPrivateProject();
    ProjectLinkDto link = db.componentLinks().insertCustomLink(project);
    userSession.logIn().addProjectPermission(UserRole.USER, project);
    SearchWsResponse response = callByKey(project.getKey());
    assertThat(response.getLinksList()).extracting(Link::getId, Link::getName).containsExactlyInAnyOrder(tuple(link.getUuid(), link.getName()));
}
Also used : ProjectLinkDto(org.sonar.db.component.ProjectLinkDto) ComponentDto(org.sonar.db.component.ComponentDto) SearchWsResponse(org.sonarqube.ws.ProjectLinks.SearchWsResponse) Test(org.junit.Test)

Example 5 with SearchWsResponse

use of org.sonarqube.ws.ProjectLinks.SearchWsResponse in project sonarqube by SonarSource.

the class SearchActionTest method request_does_not_fail_when_link_has_no_name.

@Test
public void request_does_not_fail_when_link_has_no_name() {
    ComponentDto project = db.components().insertPrivateProject();
    ProjectLinkDto link = db.componentLinks().insertProvidedLink(project);
    logInAsProjectAdministrator(project);
    SearchWsResponse response = callByKey(project.getKey());
    assertThat(response.getLinksList()).extracting(Link::getId, Link::hasName).containsExactlyInAnyOrder(tuple(link.getUuid(), false));
}
Also used : ProjectLinkDto(org.sonar.db.component.ProjectLinkDto) ComponentDto(org.sonar.db.component.ComponentDto) SearchWsResponse(org.sonarqube.ws.ProjectLinks.SearchWsResponse) Test(org.junit.Test)

Aggregations

SearchWsResponse (org.sonarqube.ws.ProjectLinks.SearchWsResponse)8 Test (org.junit.Test)7 ComponentDto (org.sonar.db.component.ComponentDto)7 ProjectLinkDto (org.sonar.db.component.ProjectLinkDto)7