use of org.sonar.ce.task.projectanalysis.period.Period in project sonarqube by SonarSource.
the class NewIssueClassifierTest method isEnabled_returns_true_when_periodDate_present.
@Test
public void isEnabled_returns_true_when_periodDate_present() {
periodHolder.setPeriod(new Period(NewCodePeriodType.NUMBER_OF_DAYS.name(), "10", 1000L));
assertThat(newIssueClassifier.isEnabled()).isTrue();
}
use of org.sonar.ce.task.projectanalysis.period.Period in project sonarqube by SonarSource.
the class ReportPersistAnalysisStepTest method persist_snapshots_with_new_code_period.
@Test
public void persist_snapshots_with_new_code_period() {
ComponentDto projectDto = ComponentTesting.newPrivateProjectDto("ABCD").setDbKey(PROJECT_KEY).setName("Project");
dbTester.components().insertComponent(projectDto);
SnapshotDto snapshotDto = SnapshotTesting.newAnalysis(projectDto).setCreatedAt(DateUtils.parseDateQuietly("2015-01-01").getTime());
dbClient.snapshotDao().insert(dbTester.getSession(), snapshotDto);
dbTester.getSession().commit();
periodsHolder.setPeriod(new Period("NUMBER_OF_DAYS", "10", analysisDate));
Component project = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).build();
treeRootHolder.setRoot(project);
underTest.execute(new TestComputationStepContext());
SnapshotDto projectSnapshot = getUnprocessedSnapshot(projectDto.uuid());
assertThat(projectSnapshot.getPeriodMode()).isEqualTo("NUMBER_OF_DAYS");
assertThat(projectSnapshot.getPeriodDate()).isEqualTo(analysisDate);
assertThat(projectSnapshot.getPeriodModeParameter()).isNotNull();
}
use of org.sonar.ce.task.projectanalysis.period.Period in project sonarqube by SonarSource.
the class ReportPersistAnalysisStepTest method only_persist_snapshots_with_new_code_period_on_project_and_module.
@Test
public void only_persist_snapshots_with_new_code_period_on_project_and_module() {
periodsHolder.setPeriod(new Period("PREVIOUS_VERSION", null, analysisDate));
ComponentDto projectDto = ComponentTesting.newPrivateProjectDto("ABCD").setDbKey(PROJECT_KEY).setName("Project");
dbTester.components().insertComponent(projectDto);
SnapshotDto projectSnapshot = SnapshotTesting.newAnalysis(projectDto);
dbClient.snapshotDao().insert(dbTester.getSession(), projectSnapshot);
ComponentDto moduleDto = ComponentTesting.newModuleDto("BCDE", projectDto).setDbKey("MODULE_KEY").setName("Module");
dbTester.components().insertComponent(moduleDto);
ComponentDto directoryDto = ComponentTesting.newDirectory(moduleDto, "CDEF", "MODULE_KEY:src/main/java/dir").setDbKey("MODULE_KEY:src/main/java/dir");
dbTester.components().insertComponent(directoryDto);
ComponentDto fileDto = ComponentTesting.newFileDto(moduleDto, directoryDto, "DEFG").setDbKey("MODULE_KEY:src/main/java/dir/Foo.java");
dbTester.components().insertComponent(fileDto);
dbTester.getSession().commit();
Component file = ReportComponent.builder(Component.Type.FILE, 3).setUuid("DEFG").setKey("MODULE_KEY:src/main/java/dir/Foo.java").build();
Component directory = ReportComponent.builder(Component.Type.DIRECTORY, 2).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir").addChildren(file).build();
Component project = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY).addChildren(directory).build();
treeRootHolder.setRoot(project);
underTest.execute(new TestComputationStepContext());
SnapshotDto newProjectSnapshot = getUnprocessedSnapshot(projectDto.uuid());
assertThat(newProjectSnapshot.getPeriodMode()).isEqualTo("PREVIOUS_VERSION");
}
use of org.sonar.ce.task.projectanalysis.period.Period 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.ce.task.projectanalysis.period.Period in project sonarqube by SonarSource.
the class LoadPeriodsStepTest method assertPeriod.
private void assertPeriod(NewCodePeriodType type, @Nullable String value, @Nullable Long date) {
Period period = periodsHolder.getPeriod();
assertThat(period).isNotNull();
assertThat(period.getMode()).isEqualTo(type.name());
assertThat(period.getModeParameter()).isEqualTo(value);
assertThat(period.getDate()).isEqualTo(date);
}
Aggregations