use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class ExportMeasuresStepTest method insertSnapshot.
private SnapshotDto insertSnapshot(String snapshotUuid, ComponentDto project, String status) {
SnapshotDto snapshot = new SnapshotDto().setUuid(snapshotUuid).setComponentUuid(project.uuid()).setStatus(status).setLast(true);
dbTester.getDbClient().snapshotDao().insert(dbTester.getSession(), snapshot);
return snapshot;
}
use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class ExportMeasuresStepTest method export_measures.
@Test
public void export_measures() {
SnapshotDto firstAnalysis = insertSnapshot("U_1", PROJECT, STATUS_PROCESSED);
insertMeasure(firstAnalysis, PROJECT, new MeasureDto().setValue(100.0).setMetricUuid(NCLOC.getUuid()));
SnapshotDto secondAnalysis = insertSnapshot("U_2", PROJECT, STATUS_PROCESSED);
insertMeasure(secondAnalysis, PROJECT, new MeasureDto().setValue(110.0).setMetricUuid(NCLOC.getUuid()));
SnapshotDto anotherProjectAnalysis = insertSnapshot("U_3", ANOTHER_PROJECT, STATUS_PROCESSED);
insertMeasure(anotherProjectAnalysis, ANOTHER_PROJECT, new MeasureDto().setValue(500.0).setMetricUuid(NCLOC.getUuid()));
dbTester.commit();
underTest.execute(new TestComputationStepContext());
List<ProjectDump.Measure> exportedMeasures = dumpWriter.getWrittenMessagesOf(DumpElement.MEASURES);
assertThat(exportedMeasures).hasSize(2);
assertThat(exportedMeasures).extracting(ProjectDump.Measure::getAnalysisUuid).containsOnly(firstAnalysis.getUuid(), secondAnalysis.getUuid());
assertThat(exportedMeasures).extracting(ProjectDump.Measure::getMetricRef).containsOnly(0);
assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("2 measures exported");
assertThat(metricRepository.getRefByUuid()).containsOnlyKeys(NCLOC.getUuid());
}
use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class ExportEventsStepTest method insertSnapshot.
private SnapshotDto insertSnapshot() {
SnapshotDto snapshot = new SnapshotDto().setUuid("U1").setComponentUuid(PROJECT.uuid()).setStatus(STATUS_PROCESSED).setLast(false);
dbTester.getDbClient().snapshotDao().insert(dbTester.getSession(), snapshot);
dbTester.commit();
return snapshot;
}
use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class ExportEventsStepTest method export_events.
@Test
public void export_events() {
SnapshotDto snapshot = insertSnapshot();
insertEvent(snapshot, "E1", "one");
insertEvent(snapshot, "E2", "two");
underTest.execute(new TestComputationStepContext());
assertThat(logTester.logs(LoggerLevel.DEBUG)).contains("2 events exported");
List<ProjectDump.Event> events = dumpWriter.getWrittenMessagesOf(DumpElement.EVENTS);
assertThat(events).hasSize(2);
assertThat(events).extracting(ProjectDump.Event::getUuid).containsOnly("E1", "E2");
}
use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class PurgeCommandsTest method deleteAnalyses_by_analyses_deletes_analysis_properties.
@Test
@UseDataProvider("projectsAndViews")
public void deleteAnalyses_by_analyses_deletes_analysis_properties(ComponentDto projectOrView) {
dbTester.components().insertComponent(projectOrView);
SnapshotDto analysis = dbTester.components().insertSnapshot(projectOrView, randomLastAndStatus());
SnapshotDto otherAnalysis = dbTester.components().insertSnapshot(projectOrView);
int count = 4;
IntStream.range(0, count).forEach(i -> {
insertRandomAnalysisProperty(analysis);
insertRandomAnalysisProperty(otherAnalysis);
});
underTest.deleteAnalyses(singletonList(analysis.getUuid()));
assertThat(countAnalysisPropertiesOf(analysis)).isZero();
assertThat(countAnalysisPropertiesOf(otherAnalysis)).isEqualTo(count);
}
Aggregations