Search in sources :

Example 6 with SearchProjectsWsResponse

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

the class SearchProjectsActionTest method return_tags_facet_with_tags_having_no_project_if_tags_is_in_filter.

@Test
public void return_tags_facet_with_tags_having_no_project_if_tags_is_in_filter() {
    OrganizationDto organization = db.getDefaultOrganization();
    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java").setTags(newArrayList("finance", "platform")));
    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown").setTags(singletonList("offshore")));
    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube").setTags(newArrayList("offshore")));
    SearchProjectsWsResponse result = call(request.setFilter("tags = marketing").setFacets(singletonList(FILTER_TAGS)));
    Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> FILTER_TAGS.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
    assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsExactly(tuple("offshore", 2L), tuple("finance", 1L), tuple("platform", 1L), tuple("marketing", 0L));
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Common(org.sonarqube.ws.Common) Test(org.junit.Test)

Example 7 with SearchProjectsWsResponse

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

the class SearchProjectsActionTest method paginate_result.

@Test
public void paginate_result() {
    IntStream.rangeClosed(1, 9).forEach(i -> insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("PROJECT-" + i)));
    SearchProjectsWsResponse result = call(request.setPage(2).setPageSize(3));
    assertThat(result.getPaging().getPageIndex()).isEqualTo(2);
    assertThat(result.getPaging().getPageSize()).isEqualTo(3);
    assertThat(result.getPaging().getTotal()).isEqualTo(9);
    assertThat(result.getComponentsCount()).isEqualTo(3);
    assertThat(result.getComponentsList()).extracting(Component::getName).containsExactly("PROJECT-4", "PROJECT-5", "PROJECT-6");
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) Test(org.junit.Test)

Example 8 with SearchProjectsWsResponse

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

the class SearchProjectsActionTest method return_tags_facet.

@Test
public void return_tags_facet() {
    OrganizationDto organization = db.getDefaultOrganization();
    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Java").setTags(newArrayList("finance", "platform")));
    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Markdown").setTags(singletonList("offshore")));
    insertProjectInDbAndEs(newProjectDto(organization).setName("Sonar Qube").setTags(newArrayList("offshore")));
    SearchProjectsWsResponse result = call(request.setFacets(singletonList(FILTER_TAGS)));
    Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> FILTER_TAGS.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
    assertThat(facet.getProperty()).isEqualTo(FILTER_TAGS);
    assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsExactly(tuple("offshore", 2L), tuple("finance", 1L), tuple("platform", 1L));
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) OrganizationDto(org.sonar.db.organization.OrganizationDto) Common(org.sonarqube.ws.Common) Test(org.junit.Test)

Example 9 with SearchProjectsWsResponse

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

the class SearchProjectsActionTest method do_not_return_isFavorite_if_anonymous_user.

@Test
public void do_not_return_isFavorite_if_anonymous_user() {
    insertProjectInDbAndEs(newProjectDto(db.getDefaultOrganization()).setName("Sonar Java"), newArrayList(newMeasure(COVERAGE, 81)));
    insertMetrics(COVERAGE);
    userSession.anonymous();
    SearchProjectsWsResponse result = call(request);
    assertThat(result.getComponentsCount()).isEqualTo(1);
    assertThat(result.getComponents(0).hasIsFavorite()).isFalse();
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) Test(org.junit.Test)

Example 10 with SearchProjectsWsResponse

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

the class SearchProjectsTest method provisioned_projects_should_be_included_to_results.

@Test
public void provisioned_projects_should_be_included_to_results() throws Exception {
    orchestrator.getServer().provisionProject(PROJECT_KEY, PROJECT_NAME);
    SearchProjectsWsResponse response = searchProjects(SearchProjectsRequest.builder().build());
    assertThat(response.getComponentsList()).extracting(Component::getKey).containsOnly(PROJECT_KEY);
}
Also used : SearchProjectsWsResponse(org.sonarqube.ws.WsComponents.SearchProjectsWsResponse) 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