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);
}
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)));
}
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);
}
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);
}
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);
}
Aggregations