use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class SearchActionTest method insertNewViolationsMetric.
private MetricDto insertNewViolationsMetric() {
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).setOptimizedBestValue(true).setBestValue(0.0d));
db.commit();
return metric;
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class SearchActionTest method return_measures.
@Test
public void return_measures() throws Exception {
ComponentDto project = newProjectDto(db.getDefaultOrganization());
SnapshotDto projectSnapshot = db.components().insertProjectAndSnapshot(project);
setBrowsePermissionOnUser(project);
MetricDto coverage = insertCoverageMetric();
dbClient.measureDao().insert(dbSession, newMeasureDto(coverage, project, projectSnapshot).setValue(15.5d));
db.commit();
SearchWsResponse result = call(singletonList(project.key()), singletonList("coverage"));
List<Measure> measures = result.getMeasuresList();
assertThat(measures).hasSize(1);
Measure measure = measures.get(0);
assertThat(measure.getMetric()).isEqualTo("coverage");
assertThat(measure.getValue()).isEqualTo("15.5");
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class SearchActionTest method return_measures_on_leak_period.
@Test
public void return_measures_on_leak_period() throws Exception {
ComponentDto project = newProjectDto(db.organizations().insert());
SnapshotDto projectSnapshot = db.components().insertProjectAndSnapshot(project);
setBrowsePermissionOnUser(project);
MetricDto coverage = insertCoverageMetric();
dbClient.measureDao().insert(dbSession, newMeasureDto(coverage, project, projectSnapshot).setValue(15.5d).setVariation(10d));
db.commit();
SearchWsResponse result = call(singletonList(project.key()), singletonList("coverage"));
List<Measure> measures = result.getMeasuresList();
assertThat(measures).hasSize(1);
Measure measure = measures.get(0);
assertThat(measure.getMetric()).isEqualTo("coverage");
assertThat(measure.getValue()).isEqualTo("15.5");
assertThat(measure.getPeriods().getPeriodsValueList()).extracting(WsMeasures.PeriodValue::getIndex, WsMeasures.PeriodValue::getValue).containsOnly(tuple(1, "10.0"));
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class ProjectStatusActionTest method return_status_by_project_key.
@Test
public void return_status_by_project_key() throws IOException {
ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert()).setKey("project-key"));
SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setPeriodMode("last_version").setPeriodParam("2015-12-07").setPeriodDate(956789123987L));
MetricDto metric = dbClient.metricDao().insert(dbSession, newMetricDto().setEnabled(true).setKey(CoreMetrics.QUALITY_GATE_DETAILS_KEY));
dbClient.measureDao().insert(dbSession, newMeasureDto(metric, project, snapshot).setData(IOUtils.toString(getClass().getResource("ProjectStatusActionTest/measure_data.json"))));
dbSession.commit();
userSession.addProjectUuidPermissions(UserRole.USER, project.uuid());
String response = ws.newRequest().setParam(PARAM_PROJECT_KEY, "project-key").execute().getInput();
assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json"));
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class QualityGateConditionsUpdaterTest method create_error_condition_with_period.
@Test
public void create_error_condition_with_period() {
MetricDto metricDto = dbClient.metricDao().insert(dbSession, newMetricDto().setKey("new_coverage").setValueType(INT.name()).setHidden(false));
dbSession.commit();
QualityGateConditionDto result = underTest.createCondition(dbSession, qualityGateDto.getId(), "new_coverage", "LT", null, "80", 1);
verifyCondition(result, metricDto.getId(), "LT", null, "80", 1);
}
Aggregations