use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class ViewsPersistAnalysisStepTest method persist_snapshots_with_new_code_period.
@Test
public void persist_snapshots_with_new_code_period() {
ComponentDto viewDto = save(ComponentTesting.newPortfolio("UUID_VIEW").setDbKey("KEY_VIEW"));
ComponentDto subViewDto = save(ComponentTesting.newSubPortfolio(viewDto, "UUID_SUBVIEW", "KEY_SUBVIEW"));
dbTester.getSession().commit();
Component subView = ViewsComponent.builder(SUBVIEW, "KEY_SUBVIEW").setUuid("UUID_SUBVIEW").build();
Component view = ViewsComponent.builder(VIEW, "KEY_VIEW").setUuid("UUID_VIEW").addChildren(subView).build();
treeRootHolder.setRoot(view);
periodsHolder.setPeriod(new Period("NUMBER_OF_DAYS", "30", analysisDate));
underTest.execute(new TestComputationStepContext());
SnapshotDto viewSnapshot = getUnprocessedSnapshot(viewDto.uuid());
assertThat(viewSnapshot.getPeriodMode()).isEqualTo("NUMBER_OF_DAYS");
assertThat(viewSnapshot.getPeriodDate()).isEqualTo(analysisDate);
assertThat(viewSnapshot.getPeriodModeParameter()).isNotNull();
}
use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class LoadPeriodsStepTest method ignore_unprocessed_snapshots.
@Test
public void ignore_unprocessed_snapshots() {
SnapshotDto analysis1 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setStatus(STATUS_UNPROCESSED).setCreatedAt(milisSinceEpoch(2019, 3, 12, 0)).setLast(false));
SnapshotDto analysis2 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setStatus(STATUS_PROCESSED).setProjectVersion("not provided").setCreatedAt(milisSinceEpoch(2019, 3, 15, 0)).setLast(false));
dbTester.events().insertEvent(newEvent(analysis1).setName("not provided").setCategory(CATEGORY_VERSION).setDate(analysis1.getCreatedAt()));
dbTester.events().insertEvent(newEvent(analysis2).setName("not provided").setCategory(CATEGORY_VERSION).setDate(analysis2.getCreatedAt()));
setupRoot(project);
setProjectPeriod(project.uuid(), NewCodePeriodType.NUMBER_OF_DAYS, "10");
underTest.execute(new TestComputationStepContext());
assertPeriod(NewCodePeriodType.NUMBER_OF_DAYS, "10", analysis2.getCreatedAt());
verifyDebugLogs("Resolving new code period by 10 days: 2019-03-10");
}
use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class LoadPeriodsStepTest method testNumberOfDays.
private void testNumberOfDays(ComponentDto projectOrBranch) {
setupRoot(projectOrBranch);
SnapshotDto analysis = dbTester.components().insertSnapshot(projectOrBranch, snapshot -> snapshot.setCreatedAt(milisSinceEpoch(2019, 3, 15, 0)));
underTest.execute(new TestComputationStepContext());
assertPeriod(NewCodePeriodType.NUMBER_OF_DAYS, "10", analysis.getCreatedAt());
verifyDebugLogs("Resolving new code period by 10 days: 2019-03-10");
}
use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class LoadPeriodsStepTest method load_previous_version_with_previous_version_deleted.
@Test
public void load_previous_version_with_previous_version_deleted() {
// 2008-11-11
SnapshotDto analysis1 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226379600000L).setProjectVersion("0.9").setLast(false));
// 2008-11-12
SnapshotDto analysis2 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226494680000L).setProjectVersion("1.0").setLast(false));
// 2008-11-20
SnapshotDto analysis3 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1227157200000L).setProjectVersion("1.1").setLast(true));
dbTester.events().insertEvent(newEvent(analysis1).setName("0.9").setCategory(CATEGORY_VERSION));
// The "1.0" version was deleted from the history
setupRoot(project, "1.1");
underTest.execute(new TestComputationStepContext());
// Analysis form 2008-11-11
assertPeriod(NewCodePeriodType.PREVIOUS_VERSION, "0.9", analysis1.getCreatedAt());
}
use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class LoadPeriodsStepTest method load_previous_version_when_version_is_changing.
@Test
public void load_previous_version_when_version_is_changing() {
// 2008-11-11
SnapshotDto analysis1 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226379600000L).setProjectVersion("0.9").setLast(false));
// 2008-11-12
SnapshotDto analysis2 = dbTester.components().insertSnapshot(project, snapshot -> snapshot.setCreatedAt(1226494680000L).setProjectVersion("0.9").setLast(true));
dbTester.events().insertEvent(newEvent(analysis2).setName("0.9").setCategory(CATEGORY_VERSION).setDate(analysis2.getCreatedAt()));
setupRoot(project, "1.0");
setProjectPeriod(project.uuid(), NewCodePeriodType.PREVIOUS_VERSION, null);
underTest.execute(new TestComputationStepContext());
assertPeriod(NewCodePeriodType.PREVIOUS_VERSION, "0.9", analysis2.getCreatedAt());
verifyDebugLogs("Resolving new code period by previous version: 0.9");
}
Aggregations