Search in sources :

Example 36 with Component

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

the class ComponentIssuesRepositoryRule method getIssues.

public List<DefaultIssue> getIssues(int componentRef) {
    checkState(this.component != null && this.issues != null, "Issues have not been initialized");
    Component component = treeRootHolder.getComponentByRef(componentRef);
    checkArgument(component != null, String.format("Component '%s' does not exists in the report ", componentRef));
    checkArgument(component == this.component, String.format("Only issues from component '%s' are available, but wanted component is '%s'.", this.component.getReportAttributes().getRef(), component.getReportAttributes().getRef()));
    return issues;
}
Also used : Component(org.sonar.server.computation.task.projectanalysis.component.Component)

Example 37 with Component

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

the class BuildComponentTreeStepTest method verify_ref_and_type.

@Test
@UseDataProvider("allComponentTypes")
public void verify_ref_and_type(ComponentType componentType) {
    int componentRef = 1;
    reportReader.putComponent(component(componentRef, componentType));
    underTest.execute();
    Component root = treeRootHolder.getRoot();
    assertThat(root).isNotNull();
    assertThat(root.getType()).isEqualTo(Component.Type.valueOf(componentType.name()));
    assertThat(root.getReportAttributes().getRef()).isEqualTo(ROOT_REF);
    assertThat(root.getChildren()).isEmpty();
}
Also used : Component(org.sonar.server.computation.task.projectanalysis.component.Component) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 38 with Component

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

the class IndexAnalysisStepTest method call_indexByProjectUuid_of_indexer_for_project.

@Test
public void call_indexByProjectUuid_of_indexer_for_project() {
    Component project = ReportComponent.builder(PROJECT, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).build();
    treeRootHolder.setRoot(project);
    underTest.execute();
    verify(componentIndexer).indexProject(PROJECT_UUID, ProjectIndexer.Cause.NEW_ANALYSIS);
}
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 39 with Component

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

the class LoadDuplicationsFromReportStepTest method loads_never_consider_originals_from_batch_on_same_lines_as_the_equals.

@Test
public void loads_never_consider_originals_from_batch_on_same_lines_as_the_equals() {
    reportReader.putDuplications(FILE_2_REF, createDuplication(singleLineTextRange(LINE), createInnerDuplicate(LINE + 1), createInnerDuplicate(LINE + 2), createInProjectDuplicate(FILE_1_REF, LINE + 2)), createDuplication(singleLineTextRange(LINE), createInnerDuplicate(LINE + 2), createInnerDuplicate(LINE + 3), createInProjectDuplicate(FILE_1_REF, LINE + 2)));
    underTest.execute();
    Component file1Component = treeRootHolder.getComponentByRef(FILE_1_REF);
    assertThat(duplicationRepository.getDuplications(FILE_2_REF)).containsOnly(duplication(singleLineDetailedTextBlock(1, LINE), new InnerDuplicate(singleLineTextBlock(LINE + 1)), new InnerDuplicate(singleLineTextBlock(LINE + 2)), new InProjectDuplicate(file1Component, singleLineTextBlock(LINE + 2))), duplication(singleLineDetailedTextBlock(2, LINE), new InnerDuplicate(singleLineTextBlock(LINE + 2)), new InnerDuplicate(singleLineTextBlock(LINE + 3)), new InProjectDuplicate(file1Component, singleLineTextBlock(LINE + 2))));
}
Also used : InnerDuplicate(org.sonar.server.computation.task.projectanalysis.duplication.InnerDuplicate) InProjectDuplicate(org.sonar.server.computation.task.projectanalysis.duplication.InProjectDuplicate) Component(org.sonar.server.computation.task.projectanalysis.component.Component) Test(org.junit.Test)

Example 40 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_report_components.

@Test
@UseDataProvider("nonRootProjectComponentTypes")
public void do_not_call_purge_method_of_the_purge_task_for_other_report_components(Component.Type type) {
    Component component = ReportComponent.builder(type, 1).setUuid(PROJECT_UUID).setKey(PROJECT_KEY).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)

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