use of org.sonarqube.ws.Components.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() {
userSession.anonymous();
ComponentDto javaProject = insertProject();
ComponentDto markDownProject = insertProject();
ComponentDto sonarQubeProject = insertProject();
Stream.of(javaProject, markDownProject).forEach(this::addFavourite);
index();
SearchProjectsWsResponse result = call(request.setFilter("isFavorite"));
assertThat(result.getComponentsCount()).isZero();
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_qualifiers_facet.
@Test
public void return_qualifiers_facet() {
when(editionProviderMock.get()).thenReturn(Optional.of(Edition.ENTERPRISE));
userSession.logIn();
ComponentDto application1 = insertApplication();
ComponentDto application2 = insertApplication();
ComponentDto application3 = insertApplication();
ComponentDto application4 = insertApplication();
ComponentDto project1 = insertProject();
ComponentDto project2 = insertProject();
ComponentDto project3 = insertProject();
index();
SearchProjectsWsResponse result = call(request.setFacets(singletonList(FILTER_QUALIFIER)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> FILTER_QUALIFIER.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsExactly(tuple("APP", 4L), tuple("TRK", 3L));
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_tags.
@Test
public void filter_projects_by_tags() {
userSession.logIn();
ComponentDto project1 = insertProject(defaults(), p -> p.setTags(asList("finance", "platform")));
insertProject(defaults(), p -> p.setTags(singletonList("marketing")));
ComponentDto project3 = insertProject(defaults(), p -> p.setTags(singletonList("offshore")));
index();
SearchProjectsWsResponse result = call(request.setFilter("tags in (finance, offshore)"));
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey(), project3.getDbKey());
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_quality_gate_facet_without_warning_when_no_projects_in_warning.
@Test
public void return_quality_gate_facet_without_warning_when_no_projects_in_warning() {
userSession.logIn();
MetricDto qualityGateStatus = db.measures().insertMetric(c -> c.setKey(ALERT_STATUS_KEY).setValueType(LEVEL.name()));
insertProject(new Measure(qualityGateStatus, c -> c.setData(Metric.Level.ERROR.name()).setValue(null)));
insertProject(new Measure(qualityGateStatus, c -> c.setData(Metric.Level.ERROR.name()).setValue(null)));
insertProject(new Measure(qualityGateStatus, c -> c.setData(Metric.Level.OK.name()).setValue(null)));
projectsInWarning.update(0L);
index();
SearchProjectsWsResponse result = call(request.setFacets(singletonList(ALERT_STATUS_KEY)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> ALERT_STATUS_KEY.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsOnly(tuple("OK", 1L), tuple("ERROR", 2L));
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method does_not_fail_on_orphan_favorite.
@Test
public void does_not_fail_on_orphan_favorite() {
userSession.logIn();
ComponentDto javaProject = insertProject();
ComponentDto markDownProject = insertProject();
ComponentDto sonarQubeProject = insertProject();
Stream.of(javaProject, markDownProject).forEach(this::addFavourite);
index();
addFavourite(null, null, null, null);
SearchProjectsWsResponse result = call(request.setFilter("isFavorite"));
assertThat(result.getComponentsCount()).isEqualTo(2);
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(javaProject.getDbKey(), markDownProject.getDbKey());
}
Aggregations