use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_no_duplication.
@Test
public void filter_projects_by_no_duplication() {
userSession.logIn();
MetricDto coverage = db.measures().insertMetric(c -> c.setKey(COVERAGE).setValueType("PERCENT"));
MetricDto duplications = db.measures().insertMetric(c -> c.setKey(DUPLICATED_LINES_DENSITY_KEY).setValueType("PERCENT"));
ComponentDto project1 = insertProject(new Measure(coverage, c -> c.setValue(10d)));
ComponentDto project2 = insertProject(new Measure(duplications, c -> c.setValue(0d)));
ComponentDto project3 = insertProject(new Measure(duplications, c -> c.setValue(79d)));
index();
SearchProjectsWsResponse result = call(request.setFilter("duplicated_lines_density = NO_DATA"));
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactlyInAnyOrder(project1.getDbKey());
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_quality_gate_facet.
@Test
public void return_quality_gate_facet() {
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.WARN.name()).setValue(null)));
insertProject(new Measure(qualityGateStatus, c -> c.setData(Metric.Level.OK.name()).setValue(null)));
projectsInWarning.update(1L);
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), tuple("WARN", 1L));
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_new_rating_facet.
@Test
@UseDataProvider("new_rating_metric_keys")
public void return_new_rating_facet(String newRatingMetricKey) {
userSession.logIn();
MetricDto newRatingMetric = db.measures().insertMetric(c -> c.setKey(newRatingMetricKey).setValueType("RATING"));
insertProject(new Measure(newRatingMetric, c -> c.setVariation(1d)));
insertProject(new Measure(newRatingMetric, c -> c.setVariation(1d)));
insertProject(new Measure(newRatingMetric, c -> c.setVariation(3d)));
insertProject(new Measure(newRatingMetric, c -> c.setVariation(5d)));
index();
SearchProjectsWsResponse result = call(request.setFacets(singletonList(newRatingMetricKey)));
Common.Facet facet = result.getFacets().getFacetsList().stream().filter(oneFacet -> newRatingMetricKey.equals(oneFacet.getProperty())).findFirst().orElseThrow(IllegalStateException::new);
assertThat(facet.getValuesList()).extracting(Common.FacetValue::getVal, Common.FacetValue::getCount).containsExactly(tuple("1", 2L), tuple("2", 0L), tuple("3", 1L), tuple("4", 0L), tuple("5", 1L));
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method return_qualifiers_facet_with_qualifiers_having_no_project_if_qualifiers_is_in_filter.
@Test
public void return_qualifiers_facet_with_qualifiers_having_no_project_if_qualifiers_is_in_filter() {
when(editionProviderMock.get()).thenReturn(Optional.of(Edition.ENTERPRISE));
userSession.logIn();
ComponentDto application1 = insertApplication();
ComponentDto application2 = insertApplication();
ComponentDto application3 = insertApplication();
ComponentDto application4 = insertApplication();
index();
SearchProjectsWsResponse result = call(request.setFilter("qualifier = APP").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", 0L));
}
use of org.sonarqube.ws.Components.SearchProjectsWsResponse in project sonarqube by SonarSource.
the class SearchProjectsActionTest method filter_projects_by_rating.
@Test
@UseDataProvider("rating_metric_keys")
public void filter_projects_by_rating(String metricKey) {
userSession.logIn();
MetricDto ratingMetric = db.measures().insertMetric(c -> c.setKey(metricKey).setValueType(INT.name()));
ComponentDto project1 = insertProject(new Measure(ratingMetric, c -> c.setValue(1d)));
ComponentDto project2 = insertProject(new Measure(ratingMetric, c -> c.setValue(2d)));
ComponentDto project3 = insertProject(new Measure(ratingMetric, c -> c.setValue(3d)));
index();
SearchProjectsWsResponse result = call(request.setFilter(metricKey + " = 2"));
assertThat(result.getComponentsList()).extracting(Component::getKey).containsExactly(project2.getDbKey());
}
Aggregations