use of org.sonar.server.es.Facets in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_duplicated_lines_density_contains_only_projects_authorized_for_user.
@Test
public void facet_duplicated_lines_density_contains_only_projects_authorized_for_user() throws Exception {
// User can see these projects
indexForUser(USER1, // docs with duplication<3%
newDoc(DUPLICATION, 0d), newDoc(DUPLICATION, 0d), newDoc(DUPLICATION, 2.9d), // docs with duplication>=3% and duplication<5%
newDoc(DUPLICATION, 3d), newDoc(DUPLICATION, 4.9d));
// User cannot see these projects
indexForUser(USER2, // docs with duplication>=5% and duplication<10%
newDoc(DUPLICATION, 5d), // docs with duplication>=10% and duplication<20%
newDoc(DUPLICATION, 10d), // docs with duplication>= 20%
newDoc(DUPLICATION, 20d));
userSession.logIn(USER1);
Facets facets = underTest.search(new ProjectMeasuresQuery(), new SearchOptions().addFacets(DUPLICATION)).getFacets();
assertThat(facets.get(DUPLICATION)).containsExactly(entry("*-3.0", 3L), entry("3.0-5.0", 2L), entry("5.0-10.0", 0L), entry("10.0-20.0", 0L), entry("20.0-*", 0L));
}
use of org.sonar.server.es.Facets in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_languages_returns_more_than_10_languages_when_languages_filter_contains_value_not_in_top_10.
@Test
public void facet_languages_returns_more_than_10_languages_when_languages_filter_contains_value_not_in_top_10() {
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().setLanguages(ImmutableSet.of("xoo", "xml")), new SearchOptions().addFacets(LANGUAGES)).getFacets();
assertThat(facets.get(LANGUAGES)).containsOnly(entry("<null>", 1L), entry("cpp", 1L), entry("css", 1L), entry("java", 1L), entry("js", 1L), entry("perl", 1L), entry("php", 1L), entry("python", 1L), entry("ruby", 1L), entry("scala", 1L), entry("xoo", 1L), entry("xml", 1L));
}
use of org.sonar.server.es.Facets in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_tags_is_sticky.
@Test
public void facet_tags_is_sticky() {
index(newDoc().setTags(newArrayList("finance")).setQualityGateStatus(OK.name()), newDoc().setTags(newArrayList("finance")).setQualityGateStatus(ERROR.name()), newDoc().setTags(newArrayList("cpp")).setQualityGateStatus(WARN.name()));
Facets facets = underTest.search(new ProjectMeasuresQuery().setTags(newHashSet("cpp")), new SearchOptions().addFacets(FIELD_TAGS).addFacets(ALERT_STATUS_KEY)).getFacets();
assertThat(facets.get(FIELD_TAGS)).containsOnly(entry("finance", 2L), entry("cpp", 1L));
assertThat(facets.get(ALERT_STATUS_KEY)).containsOnly(entry(OK.name(), 0L), entry(ERROR.name(), 0L), entry(WARN.name(), 1L));
}
use of org.sonar.server.es.Facets 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.es.Facets in project sonarqube by SonarSource.
the class ProjectMeasuresIndexTest method facet_languages.
@Test
public void facet_languages() {
index(newDoc().setLanguages(singletonList("java")), newDoc().setLanguages(singletonList("java")), newDoc().setLanguages(singletonList("xoo")), newDoc().setLanguages(singletonList("xml")), newDoc().setLanguages(asList("<null>", "java")), newDoc().setLanguages(asList("<null>", "java", "xoo")));
Facets facets = underTest.search(new ProjectMeasuresQuery(), new SearchOptions().addFacets(LANGUAGES)).getFacets();
assertThat(facets.get(LANGUAGES)).containsOnly(entry("<null>", 2L), entry("java", 4L), entry("xoo", 2L), entry("xml", 1L));
}
Aggregations