use of org.sonar.server.measure.index.ProjectMeasuresQuery in project sonarqube by SonarSource.
the class ProjectMeasuresQueryFactoryTest method create_query.
@Test
public void create_query() throws Exception {
List<Criterion> criteria = asList(Criterion.builder().setKey("ncloc").setOperator(GT).setValue("10").build(), Criterion.builder().setKey("coverage").setOperator(LTE).setValue("80").build());
ProjectMeasuresQuery underTest = newProjectMeasuresQuery(criteria, emptySet());
assertThat(underTest.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_on_tag_using_in_operator.
@Test
public void create_query_on_tag_using_in_operator() throws Exception {
ProjectMeasuresQuery query = newProjectMeasuresQuery(singletonList(Criterion.builder().setKey("tags").setOperator(IN).setValues(asList("java", "js")).build()), emptySet());
assertThat(query.getTags().get()).containsOnly("java", "js");
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery in project sonarqube by SonarSource.
the class ProjectMeasuresQueryValidatorTest method fail_when_metric_is_disabled.
@Test
public void fail_when_metric_is_disabled() throws Exception {
insertMetric(createValidMetric("ncloc").setEnabled(false));
insertMetric(createValidMetric("debt").setEnabled(false));
ProjectMeasuresQuery query = new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion("ncloc", GT, 10d)).setSort("debt");
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Following metrics are disabled : [debt, ncloc]");
underTest.validate(dbSession, query);
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery in project sonarqube by SonarSource.
the class ProjectMeasuresQueryValidatorTest method fail_when_metric_are_not_numeric.
@Test
public void fail_when_metric_are_not_numeric() throws Exception {
insertMetric(createValidMetric("ncloc").setValueType(INT.name()));
insertMetric(createValidMetric("debt").setValueType(WORK_DUR.name()));
insertMetric(createValidMetric("data").setValueType(DATA.name()));
insertMetric(createValidMetric("distrib").setValueType(DISTRIB.name()));
insertMetric(createValidMetric("string").setValueType(STRING.name()));
ProjectMeasuresQuery query = new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion("data", GT, 10d)).addMetricCriterion(new MetricCriterion("distrib", EQ, 11d)).addMetricCriterion(new MetricCriterion("ncloc", LTE, 20d)).addMetricCriterion(new MetricCriterion("debt", LT, 20d)).addMetricCriterion(new MetricCriterion("string", EQ, 40d));
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Following metrics are not numeric : [data, distrib, string]");
underTest.validate(dbSession, query);
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery in project sonarqube by SonarSource.
the class ProjectMeasuresQueryValidatorTest method does_not_fail_when_sort_contains_an_existing_metric.
@Test
public void does_not_fail_when_sort_contains_an_existing_metric() throws Exception {
insertValidMetric("ncloc");
insertValidMetric("debt");
ProjectMeasuresQuery query = new ProjectMeasuresQuery().addMetricCriterion(new MetricCriterion("ncloc", GT, 10d)).setSort("debt");
underTest.validate(dbSession, query);
}
Aggregations