Search in sources :

Example 1 with SuggestionsWsResponse

use of org.sonarqube.ws.WsComponents.SuggestionsWsResponse in project sonarqube by SonarSource.

the class SuggestionsAction method handle.

@Override
public void handle(Request wsRequest, Response wsResponse) throws Exception {
    SuggestionsWsResponse searchWsResponse = doHandle(wsRequest.param(URL_PARAM_QUERY));
    writeProtobuf(searchWsResponse, wsRequest, wsResponse);
}
Also used : SuggestionsWsResponse(org.sonarqube.ws.WsComponents.SuggestionsWsResponse)

Example 2 with SuggestionsWsResponse

use of org.sonarqube.ws.WsComponents.SuggestionsWsResponse in project sonarqube by SonarSource.

the class SuggestionsActionTest method exact_match_in_one_qualifier.

@Test
public void exact_match_in_one_qualifier() {
    ComponentDto project = db.components().insertComponent(newProjectDto(organization));
    componentIndexer.indexOnStartup(null);
    authorizationIndexerTester.allowOnlyAnyone(project);
    SuggestionsWsResponse response = action.doHandle(project.getKey());
    // assert match in qualifier "TRK"
    assertThat(response.getResultsList()).filteredOn(q -> q.getItemsCount() > 0).extracting(SuggestionsWsResponse.Qualifier::getQ).containsExactly(Qualifiers.PROJECT);
    // assert correct id to be found
    assertThat(response.getResultsList()).flatExtracting(SuggestionsWsResponse.Qualifier::getItemsList).extracting(WsComponents.Component::getKey, WsComponents.Component::getOrganization).containsExactly(tuple(project.getKey(), organization.getKey()));
}
Also used : WsComponents(org.sonarqube.ws.WsComponents) ComponentDto(org.sonar.db.component.ComponentDto) SuggestionsWsResponse(org.sonarqube.ws.WsComponents.SuggestionsWsResponse) Test(org.junit.Test)

Aggregations

SuggestionsWsResponse (org.sonarqube.ws.WsComponents.SuggestionsWsResponse)2 Test (org.junit.Test)1 ComponentDto (org.sonar.db.component.ComponentDto)1 WsComponents (org.sonarqube.ws.WsComponents)1