Search in sources :

Example 26 with ProjectMeasuresQuery

use of org.sonar.server.measure.index.ProjectMeasuresQuery in project sonarqube by SonarSource.

the class ProjectMeasuresQueryFactoryTest method create_query_on_language_using_in_operator.

@Test
public void create_query_on_language_using_in_operator() {
    ProjectMeasuresQuery query = newProjectMeasuresQuery(singletonList(Criterion.builder().setKey("languages").setOperator(IN).setValues(asList("java", "js")).build()), emptySet());
    assertThat(query.getLanguages().get()).containsOnly("java", "js");
}
Also used : ProjectMeasuresQuery(org.sonar.server.measure.index.ProjectMeasuresQuery) ProjectMeasuresQueryFactory.newProjectMeasuresQuery(org.sonar.server.component.ws.ProjectMeasuresQueryFactory.newProjectMeasuresQuery) Test(org.junit.Test)

Example 27 with ProjectMeasuresQuery

use of org.sonar.server.measure.index.ProjectMeasuresQuery in project sonarqube by SonarSource.

the class ProjectMeasuresQueryValidatorTest method return_all_unknown_metrics.

@Test
public void return_all_unknown_metrics() throws Exception {
    insertValidMetric("ncloc");
    ProjectMeasuresQuery query = new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion("debt", GT, 10d)).addMetricCriterion(new MetricCriterion("ncloc", LTE, 20d)).addMetricCriterion(new MetricCriterion("coverage", GT, 30d)).setSort("duplications");
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("Unknown metric(s) [coverage, debt, duplications]");
    underTest.validate(dbSession, query);
}
Also used : MetricCriterion(org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion) ProjectMeasuresQuery(org.sonar.server.measure.index.ProjectMeasuresQuery) Test(org.junit.Test)

Example 28 with ProjectMeasuresQuery

use of org.sonar.server.measure.index.ProjectMeasuresQuery in project sonarqube by SonarSource.

the class ProjectMeasuresQueryValidatorTest method does_not_fail_when_sort_is_by_name.

@Test
public void does_not_fail_when_sort_is_by_name() throws Exception {
    insertValidMetric("ncloc");
    ProjectMeasuresQuery query = new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion("ncloc", GT, 10d)).setSort("name");
    underTest.validate(dbSession, query);
}
Also used : MetricCriterion(org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion) ProjectMeasuresQuery(org.sonar.server.measure.index.ProjectMeasuresQuery) Test(org.junit.Test)

Example 29 with ProjectMeasuresQuery

use of org.sonar.server.measure.index.ProjectMeasuresQuery in project sonarqube by SonarSource.

the class ProjectMeasuresQueryValidatorTest method does_not_fail_when_metric_criteria_contains_an_existing_metric.

@Test
public void does_not_fail_when_metric_criteria_contains_an_existing_metric() throws Exception {
    insertValidMetric("ncloc");
    ProjectMeasuresQuery query = new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion("ncloc", GT, 10d));
    underTest.validate(dbSession, query);
}
Also used : MetricCriterion(org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion) ProjectMeasuresQuery(org.sonar.server.measure.index.ProjectMeasuresQuery) Test(org.junit.Test)

Aggregations

ProjectMeasuresQuery (org.sonar.server.measure.index.ProjectMeasuresQuery)29 Test (org.junit.Test)25 ProjectMeasuresQueryFactory.newProjectMeasuresQuery (org.sonar.server.component.ws.ProjectMeasuresQueryFactory.newProjectMeasuresQuery)20 MetricCriterion (org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion)12 Criterion (org.sonar.server.component.ws.FilterParser.Criterion)7 SnapshotDto (org.sonar.db.component.SnapshotDto)2 SearchOptions (org.sonar.server.es.SearchOptions)2 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 HashSet (java.util.HashSet)1 ComponentDto (org.sonar.db.component.ComponentDto)1 ProjectDto (org.sonar.db.project.ProjectDto)1