Search in sources :

Example 91 with TestComputationStepContext

use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.

the class NewCoverageMeasuresStepTest method no_measure_for_unit_test_FILE_component.

@Test
public void no_measure_for_unit_test_FILE_component() {
    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.FILE, FILE_1_REF).setFileAttributes(new FileAttributes(true, null, 1)).build());
    underTest.execute(new TestComputationStepContext());
    assertThat(measureRepository.isEmpty()).isTrue();
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) FileAttributes(org.sonar.ce.task.projectanalysis.component.FileAttributes) Test(org.junit.Test)

Example 92 with TestComputationStepContext

use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.

the class NewCoverageMeasuresStepTest method verify_aggregates_variations.

private void verify_aggregates_variations(LinesAndConditionsWithUncoveredMetricKeys metricKeys, String codeCoverageKey, String lineCoverageKey, String branchCoverageKey) {
    treeRootHolder.setRoot(MULTIPLE_FILES_TREE);
    measureRepository.addRawMeasure(FILE_1_REF, metricKeys.getLines(), createMeasure(3000d)).addRawMeasure(FILE_1_REF, metricKeys.getConditions(), createMeasure(300d)).addRawMeasure(FILE_1_REF, metricKeys.getUncoveredLines(), createMeasure(30d)).addRawMeasure(FILE_1_REF, metricKeys.getUncoveredConditions(), createMeasure(9d)).addRawMeasure(FILE_2_REF, metricKeys.getLines(), createMeasure(2000d)).addRawMeasure(FILE_2_REF, metricKeys.getConditions(), createMeasure(400d)).addRawMeasure(FILE_2_REF, metricKeys.getUncoveredLines(), createMeasure(200d)).addRawMeasure(FILE_2_REF, metricKeys.getUncoveredConditions(), createMeasure(16d));
    underTest.execute(new TestComputationStepContext());
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_1_REF))).containsOnly(entryOf(codeCoverageKey, createMeasure(98.8d)), entryOf(lineCoverageKey, createMeasure(99d)), entryOf(branchCoverageKey, createMeasure(97d)));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_2_REF))).containsOnly(entryOf(codeCoverageKey, createMeasure(91d)), entryOf(lineCoverageKey, createMeasure(90d)), entryOf(branchCoverageKey, createMeasure(96d)));
    assertThat(measureRepository.getAddedRawMeasures(FILE_3_REF)).isEmpty();
    assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_1_REF))).containsOnly(entryOf(codeCoverageKey, createMeasure(98.8d)), entryOf(lineCoverageKey, createMeasure(99d)), entryOf(branchCoverageKey, createMeasure(97d)));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_2_REF))).containsOnly(entryOf(codeCoverageKey, createMeasure(91d)), entryOf(lineCoverageKey, createMeasure(90d)), entryOf(branchCoverageKey, createMeasure(96d)));
    MeasureRepoEntry[] modulesAndProjectEntries = { entryOf(codeCoverageKey, createMeasure(95.5d)), entryOf(lineCoverageKey, createMeasure(95.4d)), entryOf(branchCoverageKey, createMeasure(96.4d)) };
    assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).containsOnly(modulesAndProjectEntries);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) MeasureRepoEntry(org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry)

Example 93 with TestComputationStepContext

use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.

the class NewCoverageMeasuresStepTest method zero_measures_for_FILE_component_without_CoverageData.

@Test
public void zero_measures_for_FILE_component_without_CoverageData() {
    treeRootHolder.setRoot(FILE_1);
    setNewLines(FILE_1);
    underTest.execute(new TestComputationStepContext());
    verify_only_zero_measures_on_new_lines_and_conditions_measures(FILE_1);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 94 with TestComputationStepContext

use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.

the class NewCoverageMeasuresStepTest method verify_computation_of_measures_for_new_lines_for_FILE.

@Test
public void verify_computation_of_measures_for_new_lines_for_FILE() {
    when(newLinesRepository.newLinesAvailable()).thenReturn(true);
    treeRootHolder.setRoot(FILE_COMPONENT);
    setNewLines(FILE_1, 1, 2, 4);
    reportReader.putCoverage(FILE_COMPONENT.getReportAttributes().getRef(), asList(ScannerReport.LineCoverage.newBuilder().setLine(2).setHits(false).build(), ScannerReport.LineCoverage.newBuilder().setLine(3).setHits(true).build(), ScannerReport.LineCoverage.newBuilder().setLine(4).setHits(true).build()));
    underTest.execute(new TestComputationStepContext());
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_COMPONENT.getReportAttributes().getRef()))).contains(entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(2d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(1d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(0d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(0d)));
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 95 with TestComputationStepContext

use of org.sonar.ce.task.step.TestComputationStepContext in project sonarqube by SonarSource.

the class NewCoverageMeasuresStepTest method no_measure_for_DIRECTORY_component.

@Test
public void no_measure_for_DIRECTORY_component() {
    treeRootHolder.setRoot(ReportComponent.builder(Component.Type.DIRECTORY, DIRECTORY_1_REF).build());
    underTest.execute(new TestComputationStepContext());
    assertThat(measureRepository.isEmpty()).isTrue();
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Aggregations

TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)458 Test (org.junit.Test)431 ComponentDto (org.sonar.db.component.ComponentDto)91 ProjectDump (com.sonarsource.governance.projectdump.protobuf.ProjectDump)38 Component (org.sonar.ce.task.projectanalysis.component.Component)38 SnapshotDto (org.sonar.db.component.SnapshotDto)31 Date (java.util.Date)30 ReportComponent (org.sonar.ce.task.projectanalysis.component.ReportComponent)28 ComputationStep (org.sonar.ce.task.step.ComputationStep)24 RuleDefinitionDto (org.sonar.db.rule.RuleDefinitionDto)17 FileSourceDto (org.sonar.db.source.FileSourceDto)15 BaseStepTest (org.sonar.ce.task.projectanalysis.step.BaseStepTest)14 Project (org.sonar.server.project.Project)14 TextBlock (org.sonar.ce.task.projectanalysis.duplication.TextBlock)13 QualityProfile (org.sonar.server.qualityprofile.QualityProfile)13 Notification (org.sonar.api.notifications.Notification)12 DefaultIssue (org.sonar.core.issue.DefaultIssue)12 MeasureComputer (org.sonar.api.ce.measure.MeasureComputer)11 IssueDto (org.sonar.db.issue.IssueDto)11 IssuesChangesNotification (org.sonar.server.issue.notification.IssuesChangesNotification)11