use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class ViewsPersistAnalysisStepTest method persist_snapshots_with_leak_period.
@Test
public void persist_snapshots_with_leak_period() {
OrganizationDto organizationDto = dbTester.organizations().insert();
ComponentDto viewDto = save(newView(organizationDto, "UUID_VIEW").setKey("KEY_VIEW"));
ComponentDto subViewDto = save(newSubView(viewDto, "UUID_SUBVIEW", "KEY_SUBVIEW"));
dbTester.getSession().commit();
Component subView = ViewsComponent.builder(SUBVIEW, "KEY_SUBVIEW").setUuid("UUID_SUBVIEW").build();
Component view = ViewsComponent.builder(VIEW, "KEY_VIEW").setUuid("UUID_VIEW").addChildren(subView).build();
treeRootHolder.setRoot(view);
periodsHolder.setPeriod(new Period(LEAK_PERIOD_MODE_DATE, "2015-01-01", analysisDate, "u1"));
underTest.execute();
SnapshotDto viewSnapshot = getUnprocessedSnapshot(viewDto.uuid());
assertThat(viewSnapshot.getPeriodMode()).isEqualTo(LEAK_PERIOD_MODE_DATE);
assertThat(viewSnapshot.getPeriodDate()).isEqualTo(analysisDate);
assertThat(viewSnapshot.getPeriodModeParameter()).isNotNull();
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class PersistEventsStepTest method create_version_event.
@Test
public void create_version_event() {
dbTester.prepareDbUnit(getClass(), "empty.xml");
Component project = builder(PROJECT, 1).setUuid("ABCD").setVersion("1.0").addChildren(builder(MODULE, 2).setUuid("BCDE").addChildren(builder(DIRECTORY, 3).setUuid("Q").addChildren(builder(FILE, 4).setUuid("Z").build()).build()).build()).build();
treeRootHolder.setRoot(project);
underTest.execute();
dbTester.assertDbUnit(getClass(), "add_version_event-result.xml", new String[] { "uuid" }, "events");
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class ReportComputeMeasureVariationsStepTest method do_nothing_when_no_period.
@Test
public void do_nothing_when_no_period() {
Component project = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).build();
treeRootHolder.setRoot(project);
periodsHolder.setPeriod(null);
underTest.execute();
assertThat(measureRepository.getRawMeasures(project).keys()).isEmpty();
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class FileMoveDetectionStepTest method real_life_use_case.
/**
* JH: A bug was encountered in the algorithm and I didn't manage to forge a simpler test case.
*/
@Test
public void real_life_use_case() throws Exception {
analysisMetadataHolder.setBaseAnalysis(ANALYSIS);
List<String> componentDtoKey = new ArrayList<>();
for (File f : FileUtils.listFiles(new File("src/test/resources/org/sonar/server/computation/task/projectanalysis/filemove/FileMoveDetectionStepTest/v1"), null, false)) {
componentDtoKey.add(f.getName());
mockContentOfFileInDb(f.getName(), readLines(f));
}
mockComponents(componentDtoKey.toArray(new String[0]));
Map<String, Component> comps = new HashMap<>();
int i = 1;
for (File f : FileUtils.listFiles(new File("src/test/resources/org/sonar/server/computation/task/projectanalysis/filemove/FileMoveDetectionStepTest/v2"), null, false)) {
comps.put(f.getName(), builder(Component.Type.FILE, i).setKey(f.getName()).setPath(f.getName()).build());
setFileContentInReport(i++, readLines(f));
}
setFilesInReport(comps.values().toArray(new Component[0]));
underTest.execute();
Component makeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex = comps.get("MakeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex.java");
Component migrationRb1238 = comps.get("1238_make_component_uuid_and_analysis_uuid_not_null_on_duplications_index.rb");
Component addComponentUuidAndAnalysisUuidColumnToDuplicationsIndex = comps.get("AddComponentUuidAndAnalysisUuidColumnToDuplicationsIndex.java");
assertThat(movedFilesRepository.getComponentsWithOriginal()).containsOnly(makeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex, migrationRb1238, addComponentUuidAndAnalysisUuidColumnToDuplicationsIndex);
assertThat(movedFilesRepository.getOriginalFile(makeComponentUuidAndAnalysisUuidNotNullOnDuplicationsIndex).get().getKey()).isEqualTo("MakeComponentUuidNotNullOnDuplicationsIndex.java");
assertThat(movedFilesRepository.getOriginalFile(migrationRb1238).get().getKey()).isEqualTo("1242_make_analysis_uuid_not_null_on_duplications_index.rb");
assertThat(movedFilesRepository.getOriginalFile(addComponentUuidAndAnalysisUuidColumnToDuplicationsIndex).get().getKey()).isEqualTo("AddComponentUuidColumnToDuplicationsIndex.java");
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class DuplicationRepositoryImplTest method getDuplications_throws_IAE_if_Component_type_is_not_FILE.
@Test
@UseDataProvider("allComponentTypesButFile")
public void getDuplications_throws_IAE_if_Component_type_is_not_FILE(Component.Type type) {
expectFileTypeIAE();
Component component = mockComponentGetType(type);
underTest.getDuplications(component);
}
Aggregations