Search in sources :

Example 26 with Component

use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.

the class PersistMeasuresStepTest method setupViewsComponents.

private void setupViewsComponents() {
    Component view = ViewsComponent.builder(VIEW, ROOT_REF).setUuid("root-uuid").addChildren(ViewsComponent.builder(SUBVIEW, INTERMEDIATE_1_REF).setUuid("intermediate1-uuid").addChildren(ViewsComponent.builder(SUBVIEW, INTERMEDIATE_2_REF).setUuid("intermediate2-uuid").addChildren(ViewsComponent.builder(PROJECT_VIEW, LEAF_REF).setUuid("leaf-uuid").build()).build()).build()).build();
    treeRootHolder.setRoot(view);
    setupDbIds();
}
Also used : ViewsComponent(org.sonar.server.computation.task.projectanalysis.component.ViewsComponent) Component(org.sonar.server.computation.task.projectanalysis.component.Component) ReportComponent(org.sonar.server.computation.task.projectanalysis.component.ReportComponent)

Example 27 with Component

use of org.sonar.server.computation.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);
}
Also used : ViewsComponent(org.sonar.server.computation.task.projectanalysis.component.ViewsComponent) Component(org.sonar.server.computation.task.projectanalysis.component.Component) ReportComponent(org.sonar.server.computation.task.projectanalysis.component.ReportComponent) Test(org.junit.Test)

Example 28 with Component

use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.

the class PurgeDatastoresStepTest method call_purge_method_of_the_purge_task_for_project.

@Test
public void call_purge_method_of_the_purge_task_for_project() {
    Component project = ReportComponent.builder(Component.Type.PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).build();
    verify_call_purge_method_of_the_purge_task(project);
}
Also used : ViewsComponent(org.sonar.server.computation.task.projectanalysis.component.ViewsComponent) Component(org.sonar.server.computation.task.projectanalysis.component.Component) ReportComponent(org.sonar.server.computation.task.projectanalysis.component.ReportComponent) Test(org.junit.Test)

Example 29 with Component

use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.

the class PurgeDatastoresStepTest method do_not_call_purge_method_of_the_purge_task_for_other_views_components.

@Test
@UseDataProvider("nonRootViewsComponentTypes")
public void do_not_call_purge_method_of_the_purge_task_for_other_views_components(Component.Type type) {
    Component component = ViewsComponent.builder(type, PROJECT_KEY).setUuid(PROJECT_UUID).build();
    verify_do_not_call_purge_method_of_the_purge_task(component);
}
Also used : ViewsComponent(org.sonar.server.computation.task.projectanalysis.component.ViewsComponent) Component(org.sonar.server.computation.task.projectanalysis.component.Component) ReportComponent(org.sonar.server.computation.task.projectanalysis.component.ReportComponent) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 30 with Component

use of org.sonar.server.computation.task.projectanalysis.component.Component in project sonarqube by SonarSource.

the class ViewsComputeMeasureVariationsStepTest method set_variation.

@Test
public void set_variation() {
    // View
    SnapshotDto period1Snapshot = newAnalysis(view);
    dbClient.snapshotDao().insert(session, period1Snapshot);
    dbClient.measureDao().insert(session, newMeasureDto(ISSUES_METRIC.getId(), VIEW_UUID, period1Snapshot.getUuid(), 60d));
    // SubView
    ComponentDto subviewDto = ComponentTesting.newSubView(view, "dir", "key");
    dbClient.componentDao().insert(session, subviewDto);
    dbClient.measureDao().insert(session, newMeasureDto(ISSUES_METRIC.getId(), subviewDto.uuid(), period1Snapshot.getUuid(), 10d));
    session.commit();
    periodsHolder.setPeriod(newPeriod(period1Snapshot));
    Component subview = ViewsComponent.builder(Component.Type.SUBVIEW, 2).setUuid(subviewDto.uuid()).build();
    Component view = ViewsComponent.builder(Component.Type.VIEW, 1).setUuid(VIEW_UUID).addChildren(subview).build();
    treeRootHolder.setRoot(view);
    addRawMeasure(view, ISSUES_METRIC, Measure.newMeasureBuilder().create(80, null));
    addRawMeasure(subview, ISSUES_METRIC, Measure.newMeasureBuilder().create(20, null));
    underTest.execute();
    assertThat(measureRepository.getRawMeasure(view, ISSUES_METRIC).get().getVariation()).isEqualTo(20d);
    assertThat(measureRepository.getRawMeasure(subview, ISSUES_METRIC).get().getVariation()).isEqualTo(10d);
}
Also used : SnapshotDto(org.sonar.db.component.SnapshotDto) ComponentDto(org.sonar.db.component.ComponentDto) ViewsComponent(org.sonar.server.computation.task.projectanalysis.component.ViewsComponent) Component(org.sonar.server.computation.task.projectanalysis.component.Component) Test(org.junit.Test)

Aggregations

Component (org.sonar.server.computation.task.projectanalysis.component.Component)55 Test (org.junit.Test)33 ReportComponent (org.sonar.server.computation.task.projectanalysis.component.ReportComponent)24 ViewsComponent (org.sonar.server.computation.task.projectanalysis.component.ViewsComponent)15 ComponentDto (org.sonar.db.component.ComponentDto)12 SnapshotDto (org.sonar.db.component.SnapshotDto)10 DbSession (org.sonar.db.DbSession)6 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)5 OrganizationDto (org.sonar.db.organization.OrganizationDto)5 DepthTraversalTypeAwareCrawler (org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler)4 Period (org.sonar.server.computation.task.projectanalysis.period.Period)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 FileAttributes (org.sonar.server.computation.task.projectanalysis.component.FileAttributes)2 TypeAwareVisitorAdapter (org.sonar.server.computation.task.projectanalysis.component.TypeAwareVisitorAdapter)2 InProjectDuplicate (org.sonar.server.computation.task.projectanalysis.duplication.InProjectDuplicate)2 InnerDuplicate (org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate)2 File (org.sonar.server.computation.task.projectanalysis.filemove.FileSimilarity.File)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1