Search in sources :

Example 11 with SearchProjectsWsResponse

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

the class SearchProjectsAction method handle.

@Override
public void handle(Request httpRequest, Response httpResponse) throws Exception {
    SearchProjectsWsResponse response = doHandle(toRequest(httpRequest));
    writeProtobuf(response, httpRequest, httpResponse);
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse)

Example 12 with SearchProjectsWsResponse

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

the class SearchProjectsActionTest method order_by_name_case_insensitive.

@Test
public void order_by_name_case_insensitive() {
    insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("Maven"));
    insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("Apache"));
    insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("guava"));
    SearchProjectsWsResponse result = call(request);
    assertThat(result.getComponentsList()).extracting(Component::getName).containsExactly("Apache", "guava", "Maven");
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) Test(org.junit.Test)

Example 13 with SearchProjectsWsResponse

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

the class SearchProjectsActionTest method filter_projects_by_quality_gate.

@Test
public void filter_projects_by_quality_gate() {
    OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1");
    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Java"), "OK");
    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Markdown"), "OK");
    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Qube"), "ERROR");
    insertMetrics(COVERAGE, NCLOC);
    request.setFilter("alert_status = OK");
    SearchProjectsWsResponse result = call(request);
    assertThat(result.getComponentsList()).extracting(Component::getName).containsOnly("Sonar Java", "Sonar Markdown");
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 14 with SearchProjectsWsResponse

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

the class SearchProjectsActionTest method default_sort_is_by_ascending_name.

@Test
public void default_sort_is_by_ascending_name() throws Exception {
    OrganizationDto organization = db.getDefaultOrganization();
    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Groovy"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 5d)));
    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 500_001d)));
    SearchProjectsWsResponse result = call(request);
    assertThat(result.getComponentsList()).extracting(Component::getName).containsExactly("Sonar Groovy", "Sonar Java", "Sonar Markdown", "Sonar Qube");
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 15 with SearchProjectsWsResponse

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

the class SearchProjectsActionTest method return_only_projects.

@Test
public void return_only_projects() {
    OrganizationDto organizationDto = db.organizations().insert();
    ComponentDto project = newProjectDto(organizationDto).setName("SonarQube");
    ComponentDto directory = newDirectory(project, "path");
    insertProjectInDbAndEs(project);
    componentDb.insertComponents(newModuleDto(project), newView(organizationDto), newDeveloper(organizationDto, "Sonar Developer"), directory, newFileDto(project, directory));
    SearchProjectsWsResponse result = call(request);
    assertThat(result.getComponentsCount()).isEqualTo(1);
    assertThat(result.getComponents(0).getName()).isEqualTo("SonarQube");
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Aggregations

SearchProjectsWsResponse (org.sonarqube.ws.WsComponents.SearchProjectsWsResponse)21 Test (org.junit.Test)20 OrganizationDto (org.sonar.db.organization.OrganizationDto)12 Common (org.sonarqube.ws.Common)6 ComponentDto (org.sonar.db.component.ComponentDto)4 Date (java.util.Date)1