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);
}
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();
}
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());
}
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));
}
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");
}
Aggregations