Search in sources :

Example 16 with SearchProjectsWsResponse

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

the class SearchProjectsActionTest method empty_result.

@Test
public void empty_result() {
    SearchProjectsWsResponse result = call(request);
    assertThat(result.getComponentsCount()).isEqualTo(0);
    Common.Paging paging = result.getPaging();
    assertThat(paging.getPageIndex()).isEqualTo(1);
    assertThat(paging.getPageSize()).isEqualTo(100);
    assertThat(paging.getTotal()).isEqualTo(0);
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) Common(org.sonarqube.ws.Common) Test(org.junit.Test)

Example 17 with SearchProjectsWsResponse

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

the class SearchProjectsActionTest method filtering_on_favorites_returns_empty_results_if_not_logged_in.

@Test
public void filtering_on_favorites_returns_empty_results_if_not_logged_in() {
    ComponentDto javaProject = insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization(), "java-id").setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d)));
    insertProjectInDbAndEs(newProjectDto(db.organizations().insert()).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d)));
    addFavourite(javaProject);
    dbSession.commit();
    request.setFilter("isFavorite");
    userSession.anonymous();
    SearchProjectsWsResponse result = call(request);
    assertThat(result.getComponentsCount()).isEqualTo(0);
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 18 with SearchProjectsWsResponse

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

the class SearchProjectsActionTest method filter_projects_by_tags.

@Test
public void filter_projects_by_tags() {
    OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1");
    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Java").setTags(newArrayList("finance", "platform")));
    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Markdown").setTags(singletonList("marketing")));
    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Qube").setTags(newArrayList("offshore")));
    request.setFilter("tags in (finance, offshore)");
    SearchProjectsWsResponse result = call(request);
    assertThat(result.getComponentsList()).extracting(Component::getName).containsOnly("Sonar Java", "Sonar Qube");
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Test(org.junit.Test)

Example 19 with SearchProjectsWsResponse

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

the class SearchProjectsActionTest method filter_projects_on_favorites.

@Test
public void filter_projects_on_favorites() {
    userSession.logIn();
    ComponentDto javaProject = insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization(), "java-id").setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d)));
    ComponentDto markDownProject = insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization(), "markdown-id").setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
    insertProjectInDbAndEs(newProjectDto(db.organizations().insert()).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d)));
    addFavourite(javaProject);
    addFavourite(markDownProject);
    dbSession.commit();
    request.setFilter("isFavorite");
    SearchProjectsWsResponse result = call(request);
    assertThat(result.getComponentsCount()).isEqualTo(2);
    assertThat(result.getComponentsList()).extracting(Component::getId).containsExactly("java-id", "markdown-id");
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 20 with SearchProjectsWsResponse

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

the class SearchProjectsActionTest method filter_projects_with_query.

@Test
public void filter_projects_with_query() {
    OrganizationDto organizationDto = db.organizations().insertForKey("my-org-key-1");
    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81), newMeasure(NCLOC, 10_000d)));
    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Markdown"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d)));
    insertProjectInDbAndEs(newProjectDto(organizationDto).setName("Sonar Qube"), newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d)));
    insertMetrics(COVERAGE, NCLOC);
    request.setFilter("coverage <= 80 and ncloc <= 10000");
    SearchProjectsWsResponse result = call(request);
    assertThat(result.getComponentsCount()).isEqualTo(1);
    assertThat(result.getComponents(0).getName()).isEqualTo("Sonar Markdown");
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) 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