use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class MeasureDtoToWsMeasureTest method fail_when_mapping_fails.
@Test
public void fail_when_mapping_fails() {
MetricDto metric = spy(newMetricDto().setKey("metric-key"));
when(metric.getValueType()).thenThrow(NullPointerException.class);
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Error while mapping a measure of metric key 'metric-key' and parameters ");
MeasureDtoToWsMeasure.measureDtoToWsMeasure(metric, newMeasure());
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class SearchActionTest 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 SearchActionTest method insertCoverageMetric.
private MetricDto insertCoverageMetric() {
MetricDto metric = dbClient.metricDao().insert(dbSession, newMetricDtoWithoutOptimization().setKey("coverage").setShortName("Coverage").setDescription("Code Coverage").setDomain("Coverage").setValueType(Metric.ValueType.FLOAT.name()).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 SearchActionTest method only_returns_authorized_projects.
@Test
public void only_returns_authorized_projects() {
MetricDto metricDto = insertComplexityMetric();
ComponentDto project1 = newProjectDto(db.getDefaultOrganization());
SnapshotDto projectSnapshot1 = db.components().insertProjectAndSnapshot(project1);
ComponentDto project2 = newProjectDto(db.getDefaultOrganization());
SnapshotDto projectSnapshot2 = db.components().insertProjectAndSnapshot(project2);
dbClient.measureDao().insert(dbSession, newMeasureDto(metricDto, project1, projectSnapshot1).setValue(15.5d), newMeasureDto(metricDto, project2, projectSnapshot2).setValue(42.0d));
db.commit();
setBrowsePermissionOnUser(project1);
SearchWsResponse result = call(asList(project1.key(), project2.key()), singletonList("complexity"));
assertThat(result.getMeasuresList()).extracting(Measure::getComponent).containsOnly(project1.key());
}
use of org.sonar.db.metric.MetricDto in project sonarqube by SonarSource.
the class SearchActionTest 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