use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class NewReliabilityAndSecurityRatingMeasuresVisitorTest method measures_created_for_project_are_all_A_when_they_have_no_FILE_child.
@Test
public void measures_created_for_project_are_all_A_when_they_have_no_FILE_child() {
ReportComponent root = builder(PROJECT, 1).build();
treeRootHolder.setRoot(root);
underTest.visit(root);
verifyAddedRawMeasureOnLeakPeriod(1, NEW_SECURITY_RATING_KEY, A);
verifyAddedRawMeasureOnLeakPeriod(1, NEW_RELIABILITY_RATING_KEY, A);
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class ComputeQProfileMeasureStepTest method nothing_to_add_when_no_files.
@Test
public void nothing_to_add_when_no_files() {
ReportComponent project = ReportComponent.builder(PROJECT, PROJECT_REF).build();
treeRootHolder.setRoot(project);
underTest.execute(new TestComputationStepContext());
assertThat(measureRepository.getAddedRawMeasures(PROJECT_REF)).isEmpty();
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitorTest method file_has_0_new_debt_ratio_if_no_line_is_new.
@Test
public void file_has_0_new_debt_ratio_if_no_line_is_new() {
ReportComponent file = builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build();
treeRootHolder.setRoot(builder(PROJECT, ROOT_REF).addChildren(file).build());
measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(50));
measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNclocDataMeasure(2, 3, 4));
setNewLines(file);
underTest.visit(treeRootHolder.getRoot());
assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 0);
assertNewDebtRatioValues(ROOT_REF, 0);
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitorTest method compute_new_maintainability_rating.
@Test
public void compute_new_maintainability_rating() {
when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
ReportComponent file = builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build();
treeRootHolder.setRoot(builder(PROJECT, ROOT_REF).addChildren(builder(DIRECTORY, 111).addChildren(file).build()).build());
Measure newDebtMeasure = createNewDebtMeasure(50);
measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NEW_TECHNICAL_DEBT_KEY, newDebtMeasure);
measureRepository.addRawMeasure(111, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(150));
measureRepository.addRawMeasure(ROOT_REF, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(250));
// 4 lines file, only first one is not ncloc
measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNclocDataMeasure(2, 3, 4));
// first 2 lines are before all snapshots, 2 last lines are after PERIOD 2's snapshot date
setNewLines(file, 3, 4);
underTest.visit(treeRootHolder.getRoot());
assertNewMaintainability(LANGUAGE_1_FILE_REF, D);
assertNewMaintainability(111, D);
assertNewMaintainability(ROOT_REF, D);
}
use of org.sonar.ce.task.projectanalysis.component.ReportComponent in project sonarqube by SonarSource.
the class ReliabilityAndSecurityRatingMeasuresVisitorTest method measures_created_for_project_are_all_A_when_they_have_no_FILE_child.
@Test
public void measures_created_for_project_are_all_A_when_they_have_no_FILE_child() {
ReportComponent root = builder(PROJECT, 1).build();
treeRootHolder.setRoot(root);
underTest.visit(root);
assertThat(measureRepository.getRawMeasures(root).entrySet().stream().map(e -> entryOf(e.getKey(), e.getValue()))).containsOnly(entryOf(RELIABILITY_RATING_KEY, createRatingMeasure(A)), entryOf(SECURITY_RATING_KEY, createRatingMeasure(A)));
}
Aggregations