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));
}
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");
}
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));
}
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();
}
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);
}
Aggregations