use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class DbLineHashVersionTest method hasLineHashWithSignificantCode_should_return_false_if_file_is_not_found.
@Test
public void hasLineHashWithSignificantCode_should_return_false_if_file_is_not_found() {
Component component = ReportComponent.builder(Component.Type.FILE, 1).setKey("key").setUuid("123").build();
assertThat(underTest.hasLineHashesWithSignificantCode(component)).isFalse();
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class DbLineHashVersionTest method hasLineHashWithSignificantCode_should_return_false_if_pr_reference_has_file_but_it_is_not_in_db.
@Test
public void hasLineHashWithSignificantCode_should_return_false_if_pr_reference_has_file_but_it_is_not_in_db() {
ComponentDto project = db.components().insertPublicProject();
ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project));
when(analysisMetadataHolder.isPullRequest()).thenReturn(true);
when(referenceBranchComponentUuids.getComponentUuid("key")).thenReturn(file.uuid());
Component component = ReportComponent.builder(Component.Type.FILE, 1).setKey("key").setUuid("123").build();
assertThat(underTest.hasLineHashesWithSignificantCode(component)).isFalse();
verify(analysisMetadataHolder).isPullRequest();
verify(referenceBranchComponentUuids).getComponentUuid(component.getDbKey());
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class PurgeDatastoresStepTest method call_purge_method_of_the_purge_task_for_view.
@Test
public void call_purge_method_of_the_purge_task_for_view() {
Component project = ViewsComponent.builder(Component.Type.VIEW, PROJECT_KEY).setUuid(PROJECT_UUID).build();
verify_call_purge_method_of_the_purge_task(project);
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitorTest method leaf_components_always_have_a_measure_when_at_least_one_period_exist_and_ratio_is_computed_from_current_level_new_debt.
@Test
public void leaf_components_always_have_a_measure_when_at_least_one_period_exist_and_ratio_is_computed_from_current_level_new_debt() {
when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
Component 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());
assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 83.33);
assertNewDebtRatioValues(111, 83.33);
assertNewDebtRatioValues(ROOT_REF, 83.33);
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitorTest method setupOneFileAloneInAProject.
private void setupOneFileAloneInAProject(int newDebt, Flag isUnitTest, Flag withNclocLines, Flag withNewLines) {
checkArgument(isUnitTest == Flag.UT_FILE || isUnitTest == Flag.SRC_FILE);
checkArgument(withNclocLines == Flag.WITH_NCLOC || withNclocLines == Flag.NO_NCLOC || withNclocLines == Flag.MISSING_MEASURE_NCLOC);
checkArgument(withNewLines == Flag.WITH_NEW_LINES || withNewLines == Flag.NO_NEW_LINES);
Component file = builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(isUnitTest == Flag.UT_FILE, LANGUAGE_1_KEY, 1)).build();
treeRootHolder.setRoot(builder(PROJECT, ROOT_REF).addChildren(file).build());
Measure newDebtMeasure = createNewDebtMeasure(newDebt);
measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NEW_TECHNICAL_DEBT_KEY, newDebtMeasure);
if (withNclocLines == Flag.WITH_NCLOC) {
// 4 lines file, only first one is not ncloc
measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNclocDataMeasure(2, 3, 4));
} else if (withNclocLines == Flag.NO_NCLOC) {
// 4 lines file, none of which is ncloc
measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNoNclocDataMeasure(4));
}
if (withNewLines == Flag.WITH_NEW_LINES) {
// 2 last lines are new
setNewLines(file, 3, 4);
}
}
Aggregations