use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class ViewsComputeMeasureVariationsStepTest method do_nothing_when_no_period.
@Test
public void do_nothing_when_no_period() {
Component view = ViewsComponent.builder(Component.Type.VIEW, 1).setUuid(VIEW_UUID).build();
treeRootHolder.setRoot(view);
periodsHolder.setPeriod(null);
underTest.execute();
assertThat(measureRepository.getRawMeasures(view).keys()).isEmpty();
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class ViewsPersistAnalysisStepTest method persist_analysis.
@Test
public void persist_analysis() {
OrganizationDto organizationDto = dbTester.organizations().insert();
ComponentDto viewDto = save(newView(organizationDto, "UUID_VIEW").setKey("KEY_VIEW"));
save(newSubView(viewDto, "UUID_SUBVIEW", "KEY_SUBVIEW"));
save(newProjectDto(organizationDto, "proj"));
dbTester.getSession().commit();
Component projectView = ViewsComponent.builder(PROJECT_VIEW, "KEY_PROJECT_COPY").setUuid("UUID_PROJECT_COPY").build();
Component subView = ViewsComponent.builder(SUBVIEW, "KEY_SUBVIEW").setUuid("UUID_SUBVIEW").addChildren(projectView).build();
Component view = ViewsComponent.builder(VIEW, "KEY_VIEW").setUuid("UUID_VIEW").addChildren(subView).build();
treeRootHolder.setRoot(view);
underTest.execute();
assertThat(dbTester.countRowsOfTable("snapshots")).isEqualTo(1);
SnapshotDto viewSnapshot = getUnprocessedSnapshot(viewDto.uuid());
assertThat(viewSnapshot.getUuid()).isEqualTo(ANALYSIS_UUID);
assertThat(viewSnapshot.getComponentUuid()).isEqualTo(view.getUuid());
assertThat(viewSnapshot.getVersion()).isNull();
assertThat(viewSnapshot.getLast()).isFalse();
assertThat(viewSnapshot.getStatus()).isEqualTo("U");
assertThat(viewSnapshot.getCreatedAt()).isEqualTo(analysisDate);
assertThat(viewSnapshot.getBuildDate()).isEqualTo(now);
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class PersistMeasuresStepTest method setupReportComponents.
private void setupReportComponents() {
Component project = ReportComponent.builder(PROJECT, ROOT_REF).setUuid("root-uuid").addChildren(ReportComponent.builder(MODULE, INTERMEDIATE_1_REF).setUuid("intermediate1-uuid").addChildren(ReportComponent.builder(DIRECTORY, INTERMEDIATE_2_REF).setUuid("intermediate2-uuid").addChildren(ReportComponent.builder(FILE, LEAF_REF).setUuid("leaf-uuid").build()).build()).build()).build();
treeRootHolder.setRoot(project);
setupDbIds();
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class ReportComputeMeasureVariationsStepTest method set_variation_to_raw_value_on_new_component.
@Test
public void set_variation_to_raw_value_on_new_component() throws Exception {
// Project
SnapshotDto past1ProjectSnapshot = newAnalysis(project).setCreatedAt(1000_000_000L);
SnapshotDto currentProjectSnapshot = newAnalysis(project).setCreatedAt(2000_000_000L);
dbClient.snapshotDao().insert(session, past1ProjectSnapshot);
dbClient.snapshotDao().insert(session, currentProjectSnapshot);
dbClient.measureDao().insert(session, newMeasureDto(ISSUES_METRIC.getId(), PROJECT_UUID, past1ProjectSnapshot.getUuid(), 60d));
dbClient.measureDao().insert(session, newMeasureDto(ISSUES_METRIC.getId(), PROJECT_UUID, currentProjectSnapshot.getUuid(), 60d));
session.commit();
periodsHolder.setPeriod(newPeriod(past1ProjectSnapshot));
// Directory has just been added => no snapshot
Component directory = ReportComponent.builder(Component.Type.DIRECTORY, 2).setUuid("DIRECTORY").build();
Component project = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).addChildren(directory).build();
treeRootHolder.setRoot(project);
addRawMeasure(project, ISSUES_METRIC, newMeasureBuilder().create(90, null));
addRawMeasure(directory, ISSUES_METRIC, newMeasureBuilder().create(10, null));
underTest.execute();
assertThat(measureRepository.getRawMeasure(project, ISSUES_METRIC).get().getVariation()).isEqualTo(30d);
// Variation should be the raw value
assertThat(measureRepository.getRawMeasure(directory, ISSUES_METRIC).get().getVariation()).isEqualTo(10d);
}
use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class PersistEventsStepTest method keep_one_event_by_version.
@Test
public void keep_one_event_by_version() {
dbTester.prepareDbUnit(getClass(), "keep_one_event_by_version.xml");
Component project = builder(PROJECT, 1).setUuid("ABCD").setVersion("1.5-SNAPSHOT").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(), "keep_one_event_by_version-result.xml", new String[] { "uuid" }, "events");
}
Aggregations