use of org.sonarqube.ws.WsMeasures.Measure in project sonarqube by SonarSource.
the class SincePreviousVersionHistoryTest method test_since_previous_version_period.
/**
* SONAR-2496
*/
@Test
public void test_since_previous_version_period() {
analyzeProjectWithExclusions("0.9", "**/*2.xoo");
analyzeProject("1.0-SNAPSHOT");
analyzeProject("1.0-SNAPSHOT");
Measure measure = getMeasureWithVariation(orchestrator, PROJECT, "files");
// There are 4 files
assertThat(parseInt(measure.getValue())).isEqualTo(4);
// 2 files were added since the first analysis which was version 0.9
assertThat(measure.getPeriods().getPeriodsValueList()).extracting(PeriodValue::getValue).contains("2");
}
use of org.sonarqube.ws.WsMeasures.Measure 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.sonarqube.ws.WsMeasures.Measure in project sonar-java by SonarSource.
the class UnitTestsTest method tests_without_main_code.
@Test
public void tests_without_main_code() {
MavenBuild build = MavenBuild.create().setPom(TestUtils.projectPom("tests-without-main-code")).setGoals("clean test-compile surefire:test", "sonar:sonar");
orchestrator.executeBuild(build);
Map<String, Measure> measures = getMeasures("com.sonarsource.it.samples:tests-without-main-code", "tests", "test_errors", "test_failures", "skipped_tests", "test_execution_time", "test_success_density");
assertThat(parseInt(measures.get("tests").getValue())).isEqualTo(1);
assertThat(parseInt(measures.get("test_errors").getValue())).isEqualTo(0);
assertThat(parseInt(measures.get("test_failures").getValue())).isEqualTo(0);
assertThat(parseInt(measures.get("skipped_tests").getValue())).isEqualTo(1);
assertThat(parseInt(measures.get("test_execution_time").getValue())).isGreaterThan(0);
assertThat(parseDouble(measures.get("test_success_density").getValue())).isEqualTo(100.0);
}
use of org.sonarqube.ws.WsMeasures.Measure in project sonar-java by SonarSource.
the class UnitTestsTest method tests_with_report_name_suffix.
@Test
public void tests_with_report_name_suffix() {
MavenBuild build = MavenBuild.create().setPom(TestUtils.projectPom("tests-surefire-suffix")).setGoals("clean test-compile surefire:test -Dsurefire.reportNameSuffix=Run1", "test-compile surefire:test -Dsurefire.reportNameSuffix=Run2", "sonar:sonar");
orchestrator.executeBuild(build);
Map<String, Measure> measures = getMeasures("com.sonarsource.it.samples:tests-surefire-suffix", "tests", "test_errors", "test_failures", "skipped_tests", "test_execution_time", "test_success_density");
assertThat(parseInt(measures.get("tests").getValue())).isEqualTo(2);
assertThat(parseInt(measures.get("test_errors").getValue())).isEqualTo(0);
assertThat(parseInt(measures.get("test_failures").getValue())).isEqualTo(0);
assertThat(parseInt(measures.get("skipped_tests").getValue())).isEqualTo(2);
assertThat(parseInt(measures.get("test_execution_time").getValue())).isGreaterThan(0);
assertThat(parseDouble(measures.get("test_success_density").getValue())).isEqualTo(100.0);
}
use of org.sonarqube.ws.WsMeasures.Measure in project sonarqube by SonarSource.
the class TimeMachineTest method measure_variations_are_only_meaningful_when_additional_fields_contains_periods.
/**
* SONAR-4962
*/
@Test
public void measure_variations_are_only_meaningful_when_additional_fields_contains_periods() {
Map<String, Measure> measures = getMeasuresWithVariationsByMetricKey(orchestrator, PROJECT, "violations", "new_violations");
assertThat(measures.get("violations")).isNotNull();
assertThat(measures.get("new_violations")).isNotNull();
SearchHistoryResponse response = searchHistory("new_violations");
assertThat(response.getMeasures(0).getHistoryCount()).isGreaterThan(0);
measures = getMeasuresByMetricKey(orchestrator, PROJECT, "violations", "new_violations");
assertThat(measures.get("violations")).isNotNull();
assertThat(measures.get("new_violations")).isNull();
}
Aggregations