use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class CreateAction method insertNewMetric.
private MetricDto insertNewMetric(DbSession dbSession, MetricDto metricTemplate) {
MetricDto metric = new MetricDto().setKey(metricTemplate.getKey()).setShortName(metricTemplate.getShortName()).setValueType(metricTemplate.getValueType()).setDomain(metricTemplate.getDomain()).setDescription(metricTemplate.getDescription()).setEnabled(true).setUserManaged(true).setDirection(0).setQualitative(false).setHidden(false).setOptimizedBestValue(false).setDeleteHistoricalData(false);
dbClient.metricDao().insert(dbSession, metric);
dbSession.commit();
return metric;
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class AppActionTest method insertMetrics.
private void insertMetrics() {
metricsByKey = new HashMap<>();
for (String metricKey : AppAction.METRIC_KEYS) {
MetricDto dto = RegisterMetrics.MetricToDto.INSTANCE.apply(getMetric(metricKey));
dbTester.getDbClient().metricDao().insert(dbTester.getSession(), dto);
metricsByKey.put(metricKey, dto);
}
dbTester.commit();
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class MetricDtoToMetricTest method verify_mapping_from_dto.
@Test
public void verify_mapping_from_dto() {
for (Metric.MetricType metricType : Metric.MetricType.values()) {
MetricDto metricDto = createMetricDto(metricType);
Metric metric = underTest.apply(metricDto);
assertThat(metric.getId()).isEqualTo(metricDto.getId());
assertThat(metric.getKey()).isEqualTo(metricDto.getKey());
assertThat(metric.getName()).isEqualTo(metricDto.getShortName());
assertThat(metric.getType()).isEqualTo(metricType);
assertThat(metric.isBestValueOptimized()).isFalse();
assertThat(metric.getBestValue()).isEqualTo(SOME_BEST_VALUE);
}
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class ComponentActionTest method insertNewViolationMetric.
private MetricDto insertNewViolationMetric() {
MetricDto metric = dbClient.metricDao().insert(dbSession, newMetricDtoWithoutOptimization().setKey("new_violations").setShortName("New issues").setDescription("New Issues").setDomain("Issues").setValueType("INT").setDirection(-1).setQualitative(true).setHidden(false).setUserManaged(false));
db.commit();
return metric;
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class ComponentActionTest method insertNclocMetric.
private MetricDto insertNclocMetric() {
MetricDto metric = dbClient.metricDao().insert(dbSession, newMetricDtoWithoutOptimization().setKey("ncloc").setShortName("Lines of code").setDescription("Non Commenting Lines of Code").setDomain("Size").setValueType("INT").setDirection(-1).setQualitative(false).setHidden(false).setUserManaged(false));
db.commit();
return metric;
}
Aggregations