Search in sources :

Example 96 with TestComputationStepContext

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

the class NewCoverageMeasuresStepTest method verify_aggregation_of_measures_for_new_conditions.

@Test
public void verify_aggregation_of_measures_for_new_conditions() {
    when(newLinesRepository.newLinesAvailable()).thenReturn(true);
    treeRootHolder.setRoot(MULTIPLE_FILES_TREE);
    defineNewLinesAndLineCoverage(FILE_1, new LineCoverageValues(3, 4, 1), new LineCoverageValues(0, 3, 2));
    defineNewLinesAndLineCoverage(FILE_2, new LineCoverageValues(0, 14, 6), new LineCoverageValues(0, 13, 7));
    defineNewLinesAndLineCoverage(FILE_3, new LineCoverageValues(3, 4, 1), new LineCoverageValues(1, 13, 7));
    underTest.execute(new TestComputationStepContext());
    // files
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_1_REF))).contains(entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(5d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(3d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(7d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(4d)));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_2_REF))).contains(entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(5d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(4d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(27d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(14d)));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_3_REF))).contains(entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(5d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(2d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(17d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(9d)));
    // directories
    assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_1_REF))).contains(entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(5d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(3d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(7d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(4d)));
    assertThat(toEntries(measureRepository.getAddedRawMeasures(DIRECTORY_2_REF))).contains(entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(10d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(6d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(44d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(23d)));
    // submodule
    MeasureRepoEntry[] repoEntriesFromProject = { entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(15d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(9d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(51d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(27d)) };
    // project
    assertThat(toEntries(measureRepository.getAddedRawMeasures(ROOT_REF))).contains(repoEntriesFromProject);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) MeasureRepoEntry(org.sonar.ce.task.projectanalysis.measure.MeasureRepoEntry) Test(org.junit.Test)

Example 97 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_conditions.

private void verify_computation_of_measures_for_new_conditions() {
    treeRootHolder.setRoot(FILE_COMPONENT);
    defineNewLinesAndLineCoverage(FILE_COMPONENT, new LineCoverageValues(3, 4, 1), new LineCoverageValues(0, 3, 2));
    underTest.execute(new TestComputationStepContext());
    assertThat(toEntries(measureRepository.getAddedRawMeasures(FILE_COMPONENT.getReportAttributes().getRef()))).contains(entryOf(NEW_LINES_TO_COVER_KEY, createMeasure(5d)), entryOf(NEW_UNCOVERED_LINES_KEY, createMeasure(3d)), entryOf(NEW_CONDITIONS_TO_COVER_KEY, createMeasure(7d)), entryOf(NEW_UNCOVERED_CONDITIONS_KEY, createMeasure(4d)));
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext)

Example 98 with TestComputationStepContext

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

the class NewSizeMeasuresStepTest method compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate_of_a_single_line.

@Test
public void compute_duplicated_lines_counts_lines_from_original_and_InnerDuplicate_of_a_single_line() {
    duplicationRepository.addDuplication(FILE_1_REF, new TextBlock(1, 1), new TextBlock(2, 2));
    setNewLines(FILE_1);
    underTest.execute(new TestComputationStepContext());
    assertRawMeasureValueOnPeriod(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 2d);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) TextBlock(org.sonar.ce.task.projectanalysis.duplication.TextBlock) Test(org.junit.Test)

Example 99 with TestComputationStepContext

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

the class NewSizeMeasuresStepTest method compute_duplicated_blocks_one_for_original_and_ignores_CrossProjectDuplicate.

@Test
public void compute_duplicated_blocks_one_for_original_and_ignores_CrossProjectDuplicate() {
    duplicationRepository.addCrossProjectDuplication(FILE_1_REF, new TextBlock(1, 1), SOME_FILE_KEY, new TextBlock(2, 2));
    setNewLines(FILE_1);
    underTest.execute(new TestComputationStepContext());
    assertRawMeasureValueOnPeriod(FILE_1_REF, NEW_BLOCKS_DUPLICATED_KEY, 1);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) TextBlock(org.sonar.ce.task.projectanalysis.duplication.TextBlock) Test(org.junit.Test)

Example 100 with TestComputationStepContext

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

the class NewSizeMeasuresStepTest method compute_duplicated_lines_counts_lines_from_original_and_ignores_InProjectDuplicate.

@Test
public void compute_duplicated_lines_counts_lines_from_original_and_ignores_InProjectDuplicate() {
    TextBlock original = new TextBlock(1, 1);
    duplicationRepository.addDuplication(FILE_1_REF, original, FILE_2_REF, new TextBlock(2, 2));
    setNewLines(FILE_1);
    underTest.execute(new TestComputationStepContext());
    assertRawMeasureValueOnPeriod(FILE_1_REF, NEW_DUPLICATED_LINES_KEY, 1d);
}
Also used : TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) TextBlock(org.sonar.ce.task.projectanalysis.duplication.TextBlock) 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