use of org.sonar.server.computation.task.projectanalysis.component.FileAttributes in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitorTest method compute_new_maintainability_rating.
@Test
public void compute_new_maintainability_rating() throws Exception {
setPeriod();
when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
treeRootHolder.setRoot(builder(PROJECT, ROOT_REF).addChildren(builder(MODULE, 11).addChildren(builder(DIRECTORY, 111).addChildren(builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build()).build()).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(11, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(200));
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
scmInfoRepository.setScmInfo(LANGUAGE_1_FILE_REF, createChangesets(PERIOD_SNAPSHOT_DATE - 100, 2, PERIOD_SNAPSHOT_DATE + 100, 2));
underTest.visit(treeRootHolder.getRoot());
assertNewMaintainability(LANGUAGE_1_FILE_REF, D);
assertNewMaintainability(111, D);
assertNewMaintainability(11, D);
assertNewMaintainability(ROOT_REF, D);
}
use of org.sonar.server.computation.task.projectanalysis.component.FileAttributes 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() {
setPeriod();
when(ratingSettings.getDevCost(LANGUAGE_1_KEY)).thenReturn(LANGUAGE_1_DEV_COST);
treeRootHolder.setRoot(builder(PROJECT, ROOT_REF).addChildren(builder(MODULE, 11).addChildren(builder(DIRECTORY, 111).addChildren(builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(false, LANGUAGE_1_KEY, 1)).build()).build()).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(11, NEW_TECHNICAL_DEBT_KEY, createNewDebtMeasure(200));
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
scmInfoRepository.setScmInfo(LANGUAGE_1_FILE_REF, createChangesets(PERIOD_SNAPSHOT_DATE - 100, 2, PERIOD_SNAPSHOT_DATE + 100, 2));
underTest.visit(treeRootHolder.getRoot());
assertNewDebtRatioValues(LANGUAGE_1_FILE_REF, 83.33);
assertNewDebtRatioValues(111, 83.33);
assertNewDebtRatioValues(11, 83.33);
assertNewDebtRatioValues(ROOT_REF, 83.33);
}
use of org.sonar.server.computation.task.projectanalysis.component.FileAttributes in project sonarqube by SonarSource.
the class PersistTestsStepTest method setup.
@Before
public void setup() {
System2 system2 = mock(System2.class);
when(system2.now()).thenReturn(now);
underTest = new PersistTestsStep(dbClient, system2, reportReader, treeRootHolder);
root = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).addChildren(ReportComponent.builder(Component.Type.MODULE, 2).setUuid("MODULE_UUID").setKey("MODULE_KEY").addChildren(ReportComponent.builder(Component.Type.FILE, 3).setUuid(TEST_FILE_UUID_1).setKey("TEST_FILE1_KEY").setFileAttributes(new FileAttributes(true, null, 1)).build(), ReportComponent.builder(Component.Type.FILE, 4).setUuid(TEST_FILE_UUID_2).setKey("TEST_FILE2_KEY").setFileAttributes(new FileAttributes(true, null, 1)).build(), ReportComponent.builder(Component.Type.FILE, 5).setUuid(MAIN_FILE_UUID_1).setKey("MAIN_FILE1_KEY").build(), ReportComponent.builder(Component.Type.FILE, 6).setUuid(MAIN_FILE_UUID_2).setKey("MAIN_FILE2_KEY").build()).build()).build();
treeRootHolder.setRoot(root);
}
use of org.sonar.server.computation.task.projectanalysis.component.FileAttributes in project sonarqube by SonarSource.
the class ReportNewCoverageMeasuresStepTest method no_measures_for_FILE_component_without_code.
@Test
public void no_measures_for_FILE_component_without_code() {
treeRootHolder.setRoot(ReportComponent.builder(Component.Type.FILE, FILE_1_REF).setFileAttributes(new FileAttributes(false, null, 1)).build());
underTest.execute();
assertThat(measureRepository.isEmpty()).isTrue();
}
use of org.sonar.server.computation.task.projectanalysis.component.FileAttributes in project sonarqube by SonarSource.
the class ReportNewCoverageMeasuresStepTest 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();
assertThat(measureRepository.isEmpty()).isTrue();
}
Aggregations