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