Search in sources :

Example 21 with ProjectMeasuresQuery

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

the class ProjectMeasuresQueryFactoryTest method create_query_having_q.

@Test
public void create_query_having_q() throws Exception {
    List<Criterion> criteria = singletonList(Criterion.builder().setKey("query").setOperator(EQ).setValue("Sonar Qube").build());
    ProjectMeasuresQuery underTest = newProjectMeasuresQuery(criteria, emptySet());
    assertThat(underTest.getQueryText().get()).isEqualTo("Sonar Qube");
}
Also used : MetricCriterion(org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion) Criterion(org.sonar.server.component.ws.FilterParser.Criterion) ProjectMeasuresQuery(org.sonar.server.measure.index.ProjectMeasuresQuery) ProjectMeasuresQueryFactory.newProjectMeasuresQuery(org.sonar.server.component.ws.ProjectMeasuresQueryFactory.newProjectMeasuresQuery) Test(org.junit.Test)

Example 22 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 23 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 24 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)24 Test (org.junit.Test)22 ProjectMeasuresQueryFactory.newProjectMeasuresQuery (org.sonar.server.component.ws.ProjectMeasuresQueryFactory.newProjectMeasuresQuery)16 MetricCriterion (org.sonar.server.measure.index.ProjectMeasuresQuery.MetricCriterion)10 Criterion (org.sonar.server.component.ws.FilterParser.Criterion)4 ComponentDto (org.sonar.db.component.ComponentDto)1 SnapshotDto (org.sonar.db.component.SnapshotDto)1 SearchOptions (org.sonar.server.es.SearchOptions)1