use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class CreateActionTest method fail_when_project_id_and_project_key_are_provided.
@Test
public void fail_when_project_id_and_project_key_are_provided() throws Exception {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Either 'projectId' or 'projectKey' must be provided, not both");
insertProject(DEFAULT_PROJECT_UUID);
MetricDto metric = insertMetric(STRING);
newRequest().setParam(CreateAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID).setParam(CreateAction.PARAM_PROJECT_KEY, DEFAULT_PROJECT_KEY).setParam(CreateAction.PARAM_METRIC_ID, metric.getId().toString()).setParam(CreateAction.PARAM_VALUE, "whatever-value").execute();
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class CreateActionTest method create_level_type_custom_measure_in_db.
@Test
public void create_level_type_custom_measure_in_db() throws Exception {
insertProject(DEFAULT_PROJECT_UUID);
MetricDto metric = insertMetric(LEVEL);
newRequest().setParam(CreateAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID).setParam(CreateAction.PARAM_METRIC_ID, metric.getId().toString()).setParam(CreateAction.PARAM_VALUE, Metric.Level.WARN.name()).execute();
CustomMeasureDto customMeasure = dbClient.customMeasureDao().selectByMetricId(dbSession, metric.getId()).get(0);
assertThat(customMeasure.getTextValue()).isEqualTo(Metric.Level.WARN.name());
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class CreateActionTest method insertMetric.
private MetricDto insertMetric(ValueType metricType) {
MetricDto metric = MetricTesting.newMetricDto().setEnabled(true).setValueType(metricType.name()).setKey("metric-key");
dbClient.metricDao().insert(dbSession, metric);
dbSession.commit();
return metric;
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class CreateActionTest method fail_when_metric_id_nor_metric_key_is_provided.
@Test
public void fail_when_metric_id_nor_metric_key_is_provided() throws Exception {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("The metric id or the metric key must be provided, not both.");
insertProject(DEFAULT_PROJECT_UUID);
MetricDto metric = insertMetric(STRING);
newRequest().setParam(CreateAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID).setParam(CreateAction.PARAM_VALUE, "whatever-value").execute();
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class CreateActionTest method create_float_custom_measure_in_db.
@Test
public void create_float_custom_measure_in_db() throws Exception {
insertProject(DEFAULT_PROJECT_UUID);
MetricDto metric = insertMetric(FLOAT);
newRequest().setParam(CreateAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID).setParam(CreateAction.PARAM_METRIC_ID, metric.getId().toString()).setParam(CreateAction.PARAM_VALUE, "4.2").execute();
CustomMeasureDto customMeasure = dbClient.customMeasureDao().selectByMetricId(dbSession, metric.getId()).get(0);
assertThat(customMeasure.getValue()).isCloseTo(4.2d, Offset.offset(0.01d));
assertThat(customMeasure.getTextValue()).isNullOrEmpty();
}
Aggregations