use of org.sonar.db.metric.MetricDto 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.metric.MetricDto in project sonarqube by SonarSource.
the class CreateActionTest method fail_when_project_id_nor_project_key_provided.
@Test
public void fail_when_project_id_nor_project_key_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_METRIC_ID, "whatever-id").setParam(CreateAction.PARAM_VALUE, metric.getId().toString()).execute();
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class ComponentActionTest method insertJsonExampleData.
private void insertJsonExampleData() {
ComponentDto project = newProjectDto(db.getDefaultOrganization(), PROJECT_UUID);
SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(project).setPeriodDate(parseDateTime("2016-01-11T10:49:50+0100").getTime()).setPeriodMode("previous_version").setPeriodParam("1.0-SNAPSHOT");
ComponentDto file = newFileDto(project, null).setUuid("AVIwDXE-bJbJqrw6wFv5").setKey("MY_PROJECT:ElementImpl.java").setName("ElementImpl.java").setQualifier(Qualifiers.FILE).setLanguage("java").setPath("src/main/java/com/sonarsource/markdown/impl/ElementImpl.java");
componentDb.insertComponents(project, file);
dbClient.snapshotDao().insert(dbSession, projectSnapshot);
MetricDto complexity = insertComplexityMetric();
dbClient.measureDao().insert(dbSession, newMeasureDto(complexity, file, projectSnapshot).setValue(12.0d).setVariation(2.0d));
MetricDto ncloc = insertNclocMetric();
dbClient.measureDao().insert(dbSession, newMeasureDto(ncloc, file, projectSnapshot).setValue(114.0d).setVariation(3.0d));
MetricDto newViolations = insertNewViolationMetric();
dbClient.measureDao().insert(dbSession, newMeasureDto(newViolations, file, projectSnapshot).setVariation(25.0d));
db.commit();
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class ComponentActionTest method insertComplexityMetric.
private MetricDto insertComplexityMetric() {
MetricDto metric = dbClient.metricDao().insert(dbSession, newMetricDtoWithoutOptimization().setKey("complexity").setShortName("Complexity").setDescription("Cyclomatic complexity").setDomain("Complexity").setValueType("INT").setDirection(-1).setQualitative(false).setHidden(false).setUserManaged(false));
db.commit();
return metric;
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class ComponentTreeActionTest method insertCoverageMetric.
private MetricDto insertCoverageMetric() {
MetricDto metric = dbClient.metricDao().insert(dbSession, newMetricDtoWithoutOptimization().setKey("coverage").setShortName("Coverage").setDescription("Code Coverage").setDomain("Coverage").setValueType(ValueType.FLOAT.name()).setDirection(1).setQualitative(false).setHidden(false).setUserManaged(false));
db.commit();
return metric;
}
Aggregations