use of org.sonar.server.es.SearchOptions 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.es.SearchOptions in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_languages_is_limited_to_10_languages.
@Test
public void facet_languages_is_limited_to_10_languages() {
index(newDoc().setLanguages(asList("<null>", "java", "xoo", "css", "cpp")), newDoc().setLanguages(asList("xml", "php", "python", "perl", "ruby")), newDoc().setLanguages(asList("js", "scala")));
Facets facets = underTest.search(new ProjectMeasuresQuery(), new SearchOptions().addFacets(LANGUAGES)).getFacets();
assertThat(facets.get(LANGUAGES)).hasSize(10);
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_coverage_contains_only_projects_authorized_for_user.
@Test
public void facet_coverage_contains_only_projects_authorized_for_user() throws Exception {
// User can see these projects
indexForUser(USER1, // docs with coverage<30%
newDoc(COVERAGE, 0d), newDoc(COVERAGE, 0d), newDoc(COVERAGE, 29d), // docs with coverage>=30% and coverage<50%
newDoc(COVERAGE, 30d), newDoc(COVERAGE, 49d));
// User cannot see these projects
indexForUser(USER2, // docs with coverage>=50% and coverage<70%
newDoc(COVERAGE, 50d), // docs with coverage>=70% and coverage<80%
newDoc(COVERAGE, 70d), // docs with coverage>= 80%
newDoc(COVERAGE, 80d));
userSession.logIn(USER1);
Facets facets = underTest.search(new ProjectMeasuresQuery(), new SearchOptions().addFacets(COVERAGE)).getFacets();
assertThat(facets.get(COVERAGE)).containsExactly(entry("*-30.0", 3L), entry("30.0-50.0", 2L), entry("50.0-70.0", 0L), entry("70.0-80.0", 0L), entry("80.0-*", 0L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_languages_is_sticky.
@Test
public void facet_languages_is_sticky() {
index(newDoc(NCLOC, 10d).setLanguages(singletonList("java")), newDoc(NCLOC, 10d).setLanguages(singletonList("java")), newDoc(NCLOC, 10d).setLanguages(singletonList("xoo")), newDoc(NCLOC, 100d).setLanguages(singletonList("xml")), newDoc(NCLOC, 100d).setLanguages(asList("<null>", "java")), newDoc(NCLOC, 5000d).setLanguages(asList("<null>", "java", "xoo")));
Facets facets = underTest.search(new ProjectMeasuresQuery().setLanguages(ImmutableSet.of("java")), new SearchOptions().addFacets(LANGUAGES, NCLOC)).getFacets();
// Sticky facet on language does not take into account language filter
assertThat(facets.get(LANGUAGES)).containsOnly(entry("<null>", 2L), entry("java", 4L), entry("xoo", 2L), entry("xml", 1L));
// But facet on ncloc does well take account into filters
assertThat(facets.get(NCLOC)).containsExactly(entry("*-1000.0", 3L), entry("1000.0-10000.0", 1L), entry("10000.0-100000.0", 0L), entry("100000.0-500000.0", 0L), entry("500000.0-*", 0L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_reliability_rating.
@Test
public void facet_reliability_rating() {
index(// 3 docs with rating A
newDoc(RELIABILITY_RATING, 1d), newDoc(RELIABILITY_RATING, 1d), newDoc(RELIABILITY_RATING, 1d), // 2 docs with rating B
newDoc(RELIABILITY_RATING, 2d), newDoc(RELIABILITY_RATING, 2d), // 4 docs with rating C
newDoc(RELIABILITY_RATING, 3d), newDoc(RELIABILITY_RATING, 3d), newDoc(RELIABILITY_RATING, 3d), newDoc(RELIABILITY_RATING, 3d), // 2 docs with rating D
newDoc(RELIABILITY_RATING, 4d), newDoc(RELIABILITY_RATING, 4d), // 5 docs with rating E
newDoc(RELIABILITY_RATING, 5d), newDoc(RELIABILITY_RATING, 5d), newDoc(RELIABILITY_RATING, 5d), newDoc(RELIABILITY_RATING, 5d), newDoc(RELIABILITY_RATING, 5d));
Facets facets = underTest.search(new ProjectMeasuresQuery(), new SearchOptions().addFacets(RELIABILITY_RATING)).getFacets();
assertThat(facets.get(RELIABILITY_RATING)).containsExactly(entry("1", 3L), entry("2", 2L), entry("3", 4L), entry("4", 2L), entry("5", 5L));
}
Aggregations