Search in sources :

Example 16 with Period

use of org.sonar.ce.task.projectanalysis.period.Period in project sonarqube by SonarSource.

the class NewLinesRepositoryTest method return_empty_if_no_report_and_no_scm_info.

@Test
public void return_empty_if_no_report_and_no_scm_info() {
    periodHolder.setPeriod(new Period("", null, 1000L));
    Optional<Set<Integer>> newLines = repository.getNewLines(FILE);
    assertThat(newLines).isNotPresent();
    assertThat(repository.newLinesAvailable()).isTrue();
}
Also used : Set(java.util.Set) Period(org.sonar.ce.task.projectanalysis.period.Period) Test(org.junit.Test)

Example 17 with Period

use of org.sonar.ce.task.projectanalysis.period.Period in project sonarqube by SonarSource.

the class LoadPeriodsStep method execute.

@Override
public void execute(ComputationStep.Context context) {
    if (!analysisMetadataHolder.isBranch()) {
        periodsHolder.setPeriod(null);
        return;
    }
    String projectUuid = getProjectBranchUuid();
    String branchUuid = treeRootHolder.getRoot().getUuid();
    String projectVersion = treeRootHolder.getRoot().getProjectAttributes().getProjectVersion();
    try (DbSession dbSession = dbClient.openSession(false)) {
        Optional<NewCodePeriodDto> dto = firstPresent(Arrays.asList(() -> getBranchSetting(dbSession, projectUuid, branchUuid), () -> getProjectSetting(dbSession, projectUuid), () -> getGlobalSetting(dbSession)));
        NewCodePeriodDto newCodePeriod = dto.orElse(NewCodePeriodDto.defaultInstance());
        if (analysisMetadataHolder.isFirstAnalysis() && newCodePeriod.getType() != NewCodePeriodType.REFERENCE_BRANCH) {
            periodsHolder.setPeriod(null);
            return;
        }
        Period period = resolver.resolve(dbSession, branchUuid, newCodePeriod, projectVersion);
        periodsHolder.setPeriod(period);
    }
}
Also used : DbSession(org.sonar.db.DbSession) NewCodePeriodDto(org.sonar.db.newcodeperiod.NewCodePeriodDto) Period(org.sonar.ce.task.projectanalysis.period.Period)

Aggregations

Period (org.sonar.ce.task.projectanalysis.period.Period)17 Test (org.junit.Test)15 Component (org.sonar.ce.task.projectanalysis.component.Component)10 DefaultIssue (org.sonar.core.issue.DefaultIssue)7 Set (java.util.Set)3 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)3 ComponentDto (org.sonar.db.component.ComponentDto)3 SnapshotDto (org.sonar.db.component.SnapshotDto)3 Date (java.util.Date)2 ReportComponent (org.sonar.ce.task.projectanalysis.component.ReportComponent)2 ViewsComponent (org.sonar.ce.task.projectanalysis.component.ViewsComponent)1 DbSession (org.sonar.db.DbSession)1 NewCodePeriodDto (org.sonar.db.newcodeperiod.NewCodePeriodDto)1