use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class CreateActionTest method create_text_custom_measure_in_db.
@Test
public void create_text_custom_measure_in_db() throws Exception {
insertProject(DEFAULT_PROJECT_UUID);
MetricDto metric = insertMetric(STRING);
newRequest().setParam(CreateAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID).setParam(CreateAction.PARAM_METRIC_ID, metric.getId().toString()).setParam(CreateAction.PARAM_VALUE, "custom-measure-free-text").execute();
CustomMeasureDto customMeasure = dbClient.customMeasureDao().selectByMetricId(dbSession, metric.getId()).get(0);
assertThat(customMeasure.getTextValue()).isEqualTo("custom-measure-free-text");
}
use of org.sonar.db.measure.custom.CustomMeasureDto 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.measure.custom.CustomMeasureDto 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();
}
use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class CreateActionTest method create_text_custom_measure_with_metric_key.
@Test
public void create_text_custom_measure_with_metric_key() throws Exception {
insertProject(DEFAULT_PROJECT_UUID);
MetricDto metric = insertMetric(STRING);
newRequest().setParam(CreateAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID).setParam(CreateAction.PARAM_METRIC_KEY, metric.getKey()).setParam(CreateAction.PARAM_VALUE, "whatever-value").execute();
CustomMeasureDto customMeasure = dbClient.customMeasureDao().selectByMetricId(dbSession, metric.getId()).get(0);
assertThat(customMeasure).isNotNull();
}
use of org.sonar.db.measure.custom.CustomMeasureDto in project sonarqube by SonarSource.
the class CustomMeasuresCopyStepTest method test_long_value_type.
@Test
public void test_long_value_type() throws Exception {
CustomMeasureDto dto = new CustomMeasureDto();
dto.setValue(10.0);
assertThat(dtoToMeasure(dto, new MetricImpl(1, "m", "M", Metric.MetricType.WORK_DUR)).getLongValue()).isEqualTo(10);
}
Aggregations