use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class ExportMeasuresStepTest method test_null_exported_fields.
@Test
public void test_null_exported_fields() {
SnapshotDto analysis = insertSnapshot("U_1", PROJECT, STATUS_PROCESSED);
insertMeasure(analysis, PROJECT, new MeasureDto().setMetricUuid(NCLOC.getUuid()));
dbTester.commit();
underTest.execute(new TestComputationStepContext());
ProjectDump.Measure measure = dumpWriter.getWrittenMessagesOf(DumpElement.MEASURES).get(0);
assertThat(measure.getAlertStatus()).isEmpty();
assertThat(measure.getAlertText()).isEmpty();
assertThat(measure.hasDoubleValue()).isFalse();
assertThat(measure.getTextValue()).isEmpty();
assertThat(measure.hasVariation1()).isFalse();
}
use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class ExportMeasuresStepTest method do_not_export_measures_on_disabled_metrics.
@Test
public void do_not_export_measures_on_disabled_metrics() {
SnapshotDto firstAnalysis = insertSnapshot("U_1", PROJECT, STATUS_PROCESSED);
insertMeasure(firstAnalysis, PROJECT, new MeasureDto().setValue(100.0).setMetricUuid(DISABLED_METRIC.getUuid()));
dbTester.commit();
underTest.execute(new TestComputationStepContext());
List<ProjectDump.Measure> exportedMeasures = dumpWriter.getWrittenMessagesOf(DumpElement.MEASURES);
assertThat(exportedMeasures).isEmpty();
}
use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class ExportMeasuresStepTest method test_exported_fields.
@Test
public void test_exported_fields() {
SnapshotDto analysis = insertSnapshot("U_1", PROJECT, STATUS_PROCESSED);
MeasureDto dto = new MeasureDto().setMetricUuid(NCLOC.getUuid()).setValue(100.0).setData("data").setAlertStatus("OK").setAlertText("alert text").setVariation(1.0);
insertMeasure(analysis, PROJECT, dto);
dbTester.commit();
underTest.execute(new TestComputationStepContext());
List<ProjectDump.Measure> exportedMeasures = dumpWriter.getWrittenMessagesOf(DumpElement.MEASURES);
ProjectDump.Measure measure = exportedMeasures.get(0);
assertThat(measure.getAlertStatus()).isEqualTo(dto.getAlertStatus());
assertThat(measure.getAlertText()).isEqualTo(dto.getAlertText());
assertThat(measure.getDoubleValue().getValue()).isEqualTo(dto.getValue());
assertThat(measure.getTextValue()).isEqualTo(dto.getData());
assertThat(measure.getMetricRef()).isZero();
assertThat(measure.getAnalysisUuid()).isEqualTo(analysis.getUuid());
assertThat(measure.getVariation1().getValue()).isEqualTo(dto.getVariation());
}
use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class ExportMeasuresStepTest method do_not_export_measures_on_unprocessed_snapshots.
@Test
public void do_not_export_measures_on_unprocessed_snapshots() {
SnapshotDto firstAnalysis = insertSnapshot("U_1", PROJECT, STATUS_UNPROCESSED);
insertMeasure(firstAnalysis, PROJECT, new MeasureDto().setValue(100.0).setMetricUuid(NCLOC.getUuid()));
dbTester.commit();
underTest.execute(new TestComputationStepContext());
List<ProjectDump.Measure> exportedMeasures = dumpWriter.getWrittenMessagesOf(DumpElement.MEASURES);
assertThat(exportedMeasures).isEmpty();
}
use of org.sonar.db.measure.MeasureDto in project sonarqube by SonarSource.
the class PersistMeasuresStepTest method measures_on_non_historical_metrics_are_not_persisted.
@Test
public void measures_on_non_historical_metrics_are_not_persisted() {
prepareProject();
measureRepository.addRawMeasure(REF_1, NON_HISTORICAL_METRIC.getKey(), newMeasureBuilder().create(1));
measureRepository.addRawMeasure(REF_1, INT_METRIC.getKey(), newMeasureBuilder().create(2));
TestComputationStepContext context = execute();
assertThatMeasureIsNotPersisted("project-uuid", NON_HISTORICAL_METRIC);
MeasureDto persistedMeasure = selectMeasure("project-uuid", INT_METRIC).get();
assertThat(persistedMeasure.getValue()).isEqualTo(2);
assertNbOfInserts(context, 1);
}
Aggregations