Search in sources :

Example 1 with SearchWsResponse

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

the class SearchAction method handle.

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

Example 2 with SearchWsResponse

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

the class SearchActionTest method checkItWorks.

private void checkItWorks(ComponentDto project) throws IOException {
    insertHomepageLink(project.uuid());
    SearchWsResponse response = callByKey(project.key());
    assertThat(response.getLinksCount()).isEqualTo(1);
    assertThat(response.getLinks(0).getName()).isEqualTo("Homepage");
}
Also used : SearchWsResponse(org.sonarqube.ws.WsProjectLinks.SearchWsResponse)

Example 3 with SearchWsResponse

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

the class SearchActionTest method response_fields.

@Test
public void response_fields() throws IOException {
    ComponentDto project = insertProject();
    ComponentLinkDto homepageLink = insertHomepageLink(project.uuid());
    ComponentLinkDto customLink = insertCustomLink(project.uuid());
    logInAsProjectAdministrator(project);
    SearchWsResponse response = callByKey(project.key());
    assertThat(response.getLinksCount()).isEqualTo(2);
    assertThat(response.getLinksList()).extracting(Link::getId, Link::getName, Link::getType, Link::getUrl).containsOnlyOnce(tuple(homepageLink.getIdAsString(), homepageLink.getName(), homepageLink.getType(), homepageLink.getHref()), tuple(customLink.getIdAsString(), customLink.getName(), customLink.getType(), customLink.getHref()));
}
Also used : ComponentLinkDto(org.sonar.db.component.ComponentLinkDto) ComponentDto(org.sonar.db.component.ComponentDto) SearchWsResponse(org.sonarqube.ws.WsProjectLinks.SearchWsResponse) Test(org.junit.Test)

Example 4 with SearchWsResponse

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

the class SearchActionTest method several_projects.

@Test
public void several_projects() throws IOException {
    ComponentDto project1 = insertProject();
    ComponentDto project2 = insertProject("another", "abcd");
    ComponentLinkDto customLink1 = insertCustomLink(project1.uuid());
    insertCustomLink(project2.uuid());
    userSession.logIn().setRoot();
    SearchWsResponse response = callByKey(project1.key());
    assertThat(response.getLinksCount()).isEqualTo(1);
    assertThat(response.getLinks(0).getId()).isEqualTo(customLink1.getIdAsString());
}
Also used : ComponentLinkDto(org.sonar.db.component.ComponentLinkDto) ComponentDto(org.sonar.db.component.ComponentDto) SearchWsResponse(org.sonarqube.ws.WsProjectLinks.SearchWsResponse) Test(org.junit.Test)

Example 5 with SearchWsResponse

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

the class SearchActionTest method request_by_project_id.

@Test
public void request_by_project_id() throws IOException {
    ComponentDto project = insertProject();
    insertHomepageLink(project.uuid());
    logInAsProjectAdministrator(project);
    SearchWsResponse response = callByUuid(project.uuid());
    assertThat(response.getLinksCount()).isEqualTo(1);
    assertThat(response.getLinks(0).getName()).isEqualTo("Homepage");
}
Also used : ComponentDto(org.sonar.db.component.ComponentDto) SearchWsResponse(org.sonarqube.ws.WsProjectLinks.SearchWsResponse) Test(org.junit.Test)

Aggregations

SearchWsResponse (org.sonarqube.ws.WsProjectLinks.SearchWsResponse)6 Test (org.junit.Test)4 ComponentDto (org.sonar.db.component.ComponentDto)4 ComponentLinkDto (org.sonar.db.component.ComponentLinkDto)2 SearchWsRequest (org.sonarqube.ws.client.projectlinks.SearchWsRequest)1