Search in sources :

Example 11 with ProjectMeasuresQuery

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

the class ProjectMeasuresQueryValidatorTest method fail_when_metric_does_not_exists.

@Test
public void fail_when_metric_does_not_exists() throws Exception {
    insertValidMetric("ncloc");
    ProjectMeasuresQuery query = new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion("unknown", GT, 10d)).setSort("debt");
    expectedException.expect(IllegalArgumentException.class);
    expectedException.expectMessage("Unknown metric(s) [debt, unknown]");
    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 12 with ProjectMeasuresQuery

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

the class ProjectMeasuresQueryFactoryTest method filter_on_projectUuids_if_projectUuid_is_non_empty_and_criteria_non_empty.

@Test
public void filter_on_projectUuids_if_projectUuid_is_non_empty_and_criteria_non_empty() throws Exception {
    ProjectMeasuresQuery query = newProjectMeasuresQuery(singletonList(Criterion.builder().setKey("ncloc").setOperator(GT).setValue("10").build()), Collections.singleton("foo"));
    assertThat(query.getProjectUuids()).isPresent();
}
Also used : ProjectMeasuresQuery(org.sonar.server.measure.index.ProjectMeasuresQuery) ProjectMeasuresQueryFactory.newProjectMeasuresQuery(org.sonar.server.component.ws.ProjectMeasuresQueryFactory.newProjectMeasuresQuery) Test(org.junit.Test)

Example 13 with ProjectMeasuresQuery

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

the class ProjectMeasuresQueryFactoryTest method create_query_on_quality_gate.

@Test
public void create_query_on_quality_gate() throws Exception {
    ProjectMeasuresQuery query = newProjectMeasuresQuery(singletonList(Criterion.builder().setKey("alert_status").setOperator(EQ).setValue("OK").build()), emptySet());
    assertThat(query.getQualityGateStatus().get().name()).isEqualTo(OK.name());
}
Also used : ProjectMeasuresQuery(org.sonar.server.measure.index.ProjectMeasuresQuery) ProjectMeasuresQueryFactory.newProjectMeasuresQuery(org.sonar.server.component.ws.ProjectMeasuresQueryFactory.newProjectMeasuresQuery) Test(org.junit.Test)

Example 14 with ProjectMeasuresQuery

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

the class ProjectMeasuresQueryFactoryTest method convert_metric_to_lower_case.

@Test
public void convert_metric_to_lower_case() throws Exception {
    ProjectMeasuresQuery query = newProjectMeasuresQuery(asList(Criterion.builder().setKey("NCLOC").setOperator(GT).setValue("10").build(), Criterion.builder().setKey("coVERage").setOperator(LTE).setValue("80").build()), emptySet());
    assertThat(query.getMetricCriteria()).extracting(MetricCriterion::getMetricKey, MetricCriterion::getOperator, MetricCriterion::getValue).containsOnly(tuple("ncloc", GT, 10d), tuple("coverage", Operator.LTE, 80d));
}
Also used : ProjectMeasuresQuery(org.sonar.server.measure.index.ProjectMeasuresQuery) ProjectMeasuresQueryFactory.newProjectMeasuresQuery(org.sonar.server.component.ws.ProjectMeasuresQueryFactory.newProjectMeasuresQuery) Test(org.junit.Test)

Example 15 with ProjectMeasuresQuery

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

the class ProjectMeasuresQueryFactoryTest method create_query_having_q_ignore_case_sensitive.

@Test
public void create_query_having_q_ignore_case_sensitive() 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)

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