use of org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_maintainability_rating_is_sticky.
@Test
public void facet_maintainability_rating_is_sticky() {
index(// docs with rating A
newDoc(MAINTAINABILITY_RATING, 1d, NCLOC, 100d, COVERAGE, 0d), newDoc(MAINTAINABILITY_RATING, 1d, NCLOC, 200d, COVERAGE, 0d), newDoc(MAINTAINABILITY_RATING, 1d, NCLOC, 999d, COVERAGE, 0d), // docs with rating B
newDoc(MAINTAINABILITY_RATING, 2d, NCLOC, 2000d, COVERAGE, 0d), newDoc(MAINTAINABILITY_RATING, 2d, NCLOC, 5000d, COVERAGE, 0d), // docs with rating C
newDoc(MAINTAINABILITY_RATING, 3d, NCLOC, 20000d, COVERAGE, 0d), newDoc(MAINTAINABILITY_RATING, 3d, NCLOC, 30000d, COVERAGE, 0d), newDoc(MAINTAINABILITY_RATING, 3d, NCLOC, 40000d, COVERAGE, 0d), newDoc(MAINTAINABILITY_RATING, 3d, NCLOC, 50000d, COVERAGE, 0d), // docs with rating D
newDoc(MAINTAINABILITY_RATING, 4d, NCLOC, 120000d, COVERAGE, 0d), // docs with rating E
newDoc(MAINTAINABILITY_RATING, 5d, NCLOC, 600000d, COVERAGE, 40d), newDoc(MAINTAINABILITY_RATING, 5d, NCLOC, 700000d, COVERAGE, 50d), newDoc(MAINTAINABILITY_RATING, 5d, NCLOC, 800000d, COVERAGE, 60d));
Facets facets = underTest.search(new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion(MAINTAINABILITY_RATING, Operator.LT, 3d)).addMetricCriterion(new MetricCriterion(COVERAGE, Operator.LT, 30d)), new SearchOptions().addFacets(MAINTAINABILITY_RATING, NCLOC)).getFacets();
// Sticky facet on maintainability rating does not take into account maintainability rating filter
assertThat(facets.get(MAINTAINABILITY_RATING)).containsExactly(entry("1", 3L), entry("2", 2L), entry("3", 4L), entry("4", 1L), entry("5", 0L));
// But facet on ncloc does well take into into filters
assertThat(facets.get(NCLOC)).containsExactly(entry("*-1000.0", 3L), entry("1000.0-10000.0", 2L), entry("10000.0-100000.0", 0L), 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 ProjectMeasuresQueryTest method add_metric_criterion.
@Test
public void add_metric_criterion() throws Exception {
underTest.addMetricCriterion(new MetricCriterion("coverage", EQ, 10d));
assertThat(underTest.getMetricCriteria()).extracting(MetricCriterion::getMetricKey, MetricCriterion::getOperator, MetricCriterion::getValue).containsOnly(tuple("coverage", EQ, 10d));
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method filter_on_several_metrics.
@Test
public void filter_on_several_metrics() {
index(newDoc(PROJECT1, COVERAGE, 81d, NCLOC, 10_001d), newDoc(PROJECT2, COVERAGE, 80d, NCLOC, 10_001d), newDoc(PROJECT3, COVERAGE, 79d, NCLOC, 10_000d));
ProjectMeasuresQuery esQuery = new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion(COVERAGE, Operator.LTE, 80d)).addMetricCriterion(new MetricCriterion(NCLOC, Operator.GT, 10_000d)).addMetricCriterion(new MetricCriterion(NCLOC, Operator.LT, 11_000d));
assertResults(esQuery, PROJECT2);
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method filter_with_greater_than.
@Test
public void filter_with_greater_than() {
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.GT, 30_000d));
assertResults(query, PROJECT2, PROJECT3);
query = new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion(NCLOC, Operator.GT, 100_000d));
assertNoResults(query);
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method filter_with_lower_than_or_equals.
@Test
public void filter_with_lower_than_or_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.LTE, 80d));
assertResults(query, PROJECT1, PROJECT2);
}
Aggregations