use of org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_quality_gate_is_sticky.
@Test
public void facet_quality_gate_is_sticky() {
index(// 2 docs with QG OK
newDoc(NCLOC, 10d, COVERAGE, 0d).setQualityGateStatus(OK.name()), newDoc(NCLOC, 10d, COVERAGE, 0d).setQualityGateStatus(OK.name()), // 3 docs with QG WARN
newDoc(NCLOC, 100d, COVERAGE, 0d).setQualityGateStatus(WARN.name()), newDoc(NCLOC, 100d, COVERAGE, 0d).setQualityGateStatus(WARN.name()), newDoc(NCLOC, 100d, COVERAGE, 0d).setQualityGateStatus(WARN.name()), // 4 docs with QG ERROR
newDoc(NCLOC, 100d, COVERAGE, 0d).setQualityGateStatus(ERROR.name()), newDoc(NCLOC, 5000d, COVERAGE, 40d).setQualityGateStatus(ERROR.name()), newDoc(NCLOC, 12000d, COVERAGE, 50d).setQualityGateStatus(ERROR.name()), newDoc(NCLOC, 13000d, COVERAGE, 60d).setQualityGateStatus(ERROR.name()));
Facets facets = underTest.search(new ProjectMeasuresQuery().setQualityGateStatus(ERROR).addMetricCriterion(new MetricCriterion(COVERAGE, Operator.LT, 55d)), new SearchOptions().addFacets(ALERT_STATUS_KEY, NCLOC)).getFacets();
// Sticky facet on quality gate does not take into account quality gate filter
assertThat(facets.get(ALERT_STATUS_KEY)).containsOnly(entry(OK.name(), 2L), entry(WARN.name(), 3L), entry(ERROR.name(), 3L));
// But facet on ncloc does well take into into filters
assertThat(facets.get(NCLOC)).containsExactly(entry("*-1000.0", 1L), entry("1000.0-10000.0", 1L), entry("10000.0-100000.0", 1L), entry("100000.0-500000.0", 0L), entry("500000.0-*", 0L));
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method filter_with_equals.
@Test
public void filter_with_equals() {
index(newDoc(PROJECT1, COVERAGE, 79d, NCLOC, 10_000d), newDoc(PROJECT2, COVERAGE, 80d, NCLOC, 10_000d), newDoc(PROJECT3, COVERAGE, 81d, NCLOC, 10_000d));
ProjectMeasuresQuery query = new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion(COVERAGE, Operator.EQ, 80d));
assertResults(query, PROJECT2);
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_ncloc_is_sticky.
@Test
public void facet_ncloc_is_sticky() {
index(// 1 docs with ncloc<1K
newDoc(NCLOC, 999d, COVERAGE, 0d, DUPLICATION, 0d), // 2 docs with ncloc>=1K and ncloc<10K
newDoc(NCLOC, 1_000d, COVERAGE, 10d, DUPLICATION, 0d), newDoc(NCLOC, 9_999d, COVERAGE, 20d, DUPLICATION, 0d), // 3 docs with ncloc>=10K and ncloc<100K
newDoc(NCLOC, 10_000d, COVERAGE, 31d, DUPLICATION, 0d), newDoc(NCLOC, 11_000d, COVERAGE, 40d, DUPLICATION, 0d), newDoc(NCLOC, 99_000d, COVERAGE, 50d, DUPLICATION, 0d), // 2 docs with ncloc>=100K and ncloc<500K
newDoc(NCLOC, 100_000d, COVERAGE, 71d, DUPLICATION, 0d), newDoc(NCLOC, 499_000d, COVERAGE, 80d, DUPLICATION, 0d), // 1 docs with ncloc>= 500K
newDoc(NCLOC, 501_000d, COVERAGE, 81d, DUPLICATION, 20d));
Facets facets = underTest.search(new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion(NCLOC, Operator.LT, 10_000d)).addMetricCriterion(new MetricCriterion(DUPLICATION, Operator.LT, 10d)), new SearchOptions().addFacets(NCLOC, COVERAGE)).getFacets();
// Sticky facet on ncloc does not take into account ncloc filter
assertThat(facets.get(NCLOC)).containsExactly(entry("*-1000.0", 1L), entry("1000.0-10000.0", 2L), entry("10000.0-100000.0", 3L), entry("100000.0-500000.0", 2L), entry("500000.0-*", 0L));
// But facet on coverage does well take into into filters
assertThat(facets.get(COVERAGE)).containsExactly(entry("*-30.0", 3L), entry("30.0-50.0", 0L), entry("50.0-70.0", 0L), entry("70.0-80.0", 0L), entry("80.0-*", 0L));
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method filter_with_lower_than.
@Test
public void filter_with_lower_than() {
index(newDoc(PROJECT1, COVERAGE, 79d, NCLOC, 10_000d), newDoc(PROJECT2, COVERAGE, 80d, NCLOC, 10_000d), newDoc(PROJECT3, COVERAGE, 81d, NCLOC, 10_000d));
ProjectMeasuresQuery query = new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion(COVERAGE, Operator.LT, 80d));
assertResults(query, PROJECT1);
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method filter_with_greater_than_or_equals.
@Test
public void filter_with_greater_than_or_equals() {
index(newDoc(PROJECT1, COVERAGE, 80d, NCLOC, 30_000d), newDoc(PROJECT2, COVERAGE, 80d, NCLOC, 30_001d), newDoc(PROJECT3, COVERAGE, 80d, NCLOC, 30_001d));
ProjectMeasuresQuery query = new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion(NCLOC, Operator.GTE, 30_001d));
assertResults(query, PROJECT2, PROJECT3);
query = new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion(NCLOC, Operator.GTE, 100_000d));
assertNoResults(query);
}
Aggregations