use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_ncloc.
@Test
public void facet_ncloc() {
index(// 3 docs with ncloc<1K
newDoc(NCLOC, 0d), newDoc(NCLOC, 0d), newDoc(NCLOC, 999d), // 2 docs with ncloc>=1K and ncloc<10K
newDoc(NCLOC, 1_000d), newDoc(NCLOC, 9_999d), // 4 docs with ncloc>=10K and ncloc<100K
newDoc(NCLOC, 10_000d), newDoc(NCLOC, 10_000d), newDoc(NCLOC, 11_000d), newDoc(NCLOC, 99_000d), // 2 docs with ncloc>=100K and ncloc<500K
newDoc(NCLOC, 100_000d), newDoc(NCLOC, 499_000d), // 5 docs with ncloc>= 500K
newDoc(NCLOC, 500_000d), newDoc(NCLOC, 100_000_000d), newDoc(NCLOC, 500_000d), newDoc(NCLOC, 1_000_000d), newDoc(NCLOC, 100_000_000_000d));
Facets facets = underTest.search(new ProjectMeasuresQuery(), new SearchOptions().addFacets(NCLOC)).getFacets();
assertThat(facets.get(NCLOC)).containsExactly(entry("*-1000.0", 3L), entry("1000.0-10000.0", 2L), entry("10000.0-100000.0", 4L), entry("100000.0-500000.0", 2L), entry("500000.0-*", 5L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_security_rating.
@Test
public void facet_security_rating() {
index(// 3 docs with rating A
newDoc(SECURITY_RATING, 1.0d), newDoc(SECURITY_RATING, 1.0d), newDoc(SECURITY_RATING, 1.0d), // 2 docs with rating B
newDoc(SECURITY_RATING, 2.0d), newDoc(SECURITY_RATING, 2.0d), // 4 docs with rating C
newDoc(SECURITY_RATING, 3.0d), newDoc(SECURITY_RATING, 3.0d), newDoc(SECURITY_RATING, 3.0d), newDoc(SECURITY_RATING, 3.0d), // 2 docs with rating D
newDoc(SECURITY_RATING, 4.0d), newDoc(SECURITY_RATING, 4.0d), // 5 docs with rating E
newDoc(SECURITY_RATING, 5.0d), newDoc(SECURITY_RATING, 5.0d), newDoc(SECURITY_RATING, 5.0d), newDoc(SECURITY_RATING, 5.0d), newDoc(SECURITY_RATING, 5.0d));
Facets facets = underTest.search(new ProjectMeasuresQuery(), new SearchOptions().addFacets(SECURITY_RATING)).getFacets();
assertThat(facets.get(SECURITY_RATING)).containsExactly(entry("1", 3L), entry("2", 2L), entry("3", 4L), entry("4", 2L), entry("5", 5L));
}
use of org.sonar.server.es.SearchOptions in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_maintainability_rating_contains_only_projects_authorized_for_user.
@Test
public void facet_maintainability_rating_contains_only_projects_authorized_for_user() throws Exception {
// User can see these projects
indexForUser(USER1, // 3 docs with rating A
newDoc(MAINTAINABILITY_RATING, 1d), newDoc(MAINTAINABILITY_RATING, 1d), newDoc(MAINTAINABILITY_RATING, 1d), // 2 docs with rating B
newDoc(MAINTAINABILITY_RATING, 2d), newDoc(MAINTAINABILITY_RATING, 2d));
// User cannot see these projects
indexForUser(USER2, // docs with rating C
newDoc(MAINTAINABILITY_RATING, 3d), // docs with rating D
newDoc(MAINTAINABILITY_RATING, 4d), // docs with rating E
newDoc(MAINTAINABILITY_RATING, 5d));
userSession.logIn(USER1);
Facets facets = underTest.search(new ProjectMeasuresQuery(), new SearchOptions().addFacets(MAINTAINABILITY_RATING)).getFacets();
assertThat(facets.get(MAINTAINABILITY_RATING)).containsExactly(entry("1", 3L), entry("2", 2L), entry("3", 0L), entry("4", 0L), entry("5", 0L));
}
use of org.sonar.server.es.SearchOptions 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.es.SearchOptions in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_maintainability_rating.
@Test
public void facet_maintainability_rating() {
index(// 3 docs with rating A
newDoc(MAINTAINABILITY_RATING, 1d), newDoc(MAINTAINABILITY_RATING, 1d), newDoc(MAINTAINABILITY_RATING, 1d), // 2 docs with rating B
newDoc(MAINTAINABILITY_RATING, 2d), newDoc(MAINTAINABILITY_RATING, 2d), // 4 docs with rating C
newDoc(MAINTAINABILITY_RATING, 3d), newDoc(MAINTAINABILITY_RATING, 3d), newDoc(MAINTAINABILITY_RATING, 3d), newDoc(MAINTAINABILITY_RATING, 3d), // 2 docs with rating D
newDoc(MAINTAINABILITY_RATING, 4d), newDoc(MAINTAINABILITY_RATING, 4d), // 5 docs with rating E
newDoc(MAINTAINABILITY_RATING, 5d), newDoc(MAINTAINABILITY_RATING, 5d), newDoc(MAINTAINABILITY_RATING, 5d), newDoc(MAINTAINABILITY_RATING, 5d), newDoc(MAINTAINABILITY_RATING, 5d));
Facets facets = underTest.search(new ProjectMeasuresQuery(), new SearchOptions().addFacets(MAINTAINABILITY_RATING)).getFacets();
assertThat(facets.get(MAINTAINABILITY_RATING)).containsExactly(entry("1", 3L), entry("2", 2L), entry("3", 4L), entry("4", 2L), entry("5", 5L));
}
Aggregations