Search in sources :

Example 31 with Component

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

the class MutableMovedFilesRepositoryImplTest method getOriginalFile_returns_absent_for_any_type_of_Component_but_file_when_non_empty.

@Test
public void getOriginalFile_returns_absent_for_any_type_of_Component_but_file_when_non_empty() {
    underTest.setOriginalFile(SOME_FILE, SOME_ORIGINAL_FILE);
    for (Component component : COMPONENTS_EXCEPT_FILE) {
        assertThat(underTest.getOriginalFile(component)).isEmpty();
    }
    assertThat(underTest.getOriginalFile(SOME_FILE)).contains(SOME_ORIGINAL_FILE);
}
Also used : Component(org.sonar.ce.task.projectanalysis.component.Component) ViewsComponent(org.sonar.ce.task.projectanalysis.component.ViewsComponent) Test(org.junit.Test)

Example 32 with Component

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

the class DuplicationRepositoryImplTest method addDuplication_inner_throws_IAE_if_file_type_is_not_FILE.

@Test
@UseDataProvider("allComponentTypesButFile")
public void addDuplication_inner_throws_IAE_if_file_type_is_not_FILE(Component.Type type) {
    assertThatThrownBy(() -> {
        Component component = mockComponentGetType(type);
        underTest.add(component, SOME_DUPLICATION);
    }).isInstanceOf(IllegalArgumentException.class).hasMessage("type of file must be FILE");
}
Also used : Component(org.sonar.ce.task.projectanalysis.component.Component) ReportComponent(org.sonar.ce.task.projectanalysis.component.ReportComponent) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 33 with Component

use of org.sonar.ce.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) {
    assertThatThrownBy(() -> {
        Component component = mockComponentGetType(type);
        underTest.getDuplications(component);
    }).isInstanceOf(IllegalArgumentException.class).hasMessage("type of file must be FILE");
}
Also used : Component(org.sonar.ce.task.projectanalysis.component.Component) ReportComponent(org.sonar.ce.task.projectanalysis.component.ReportComponent) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 34 with Component

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

the class DuplicationRepositoryRule method addCrossProjectDuplication.

public DuplicationRepositoryRule addCrossProjectDuplication(int fileRef, TextBlock original, String otherFileKey, TextBlock duplicate) {
    ensureComponentProviderInitialized();
    Component component = componentProvider.getByRef(fileRef);
    checkArgument(!componentRefsWithCrossProjectDuplications.containsEntry(component, original), "CrossProject duplications for file %s and original %s already set", fileRef);
    componentRefsWithCrossProjectDuplications.put(component, original);
    delegate.add(componentProvider.getByRef(fileRef), new Duplication(original, Collections.singletonList(new CrossProjectDuplicate(otherFileKey, duplicate))));
    return this;
}
Also used : Component(org.sonar.ce.task.projectanalysis.component.Component)

Example 35 with Component

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

the class DuplicationRepositoryRule method addExtendedProjectDuplication.

public DuplicationRepositoryRule addExtendedProjectDuplication(int fileRef, TextBlock original, int otherFileRef, TextBlock duplicate) {
    ensureComponentProviderInitialized();
    Component component = componentProvider.getByRef(fileRef);
    checkArgument(!componentRefsWithCrossProjectDuplications.containsEntry(component, original), "CrossProject duplications for file %s and original %s already set", fileRef);
    componentRefsWithCrossProjectDuplications.put(component, original);
    delegate.add(componentProvider.getByRef(fileRef), new Duplication(original, Collections.singletonList(new InExtendedProjectDuplicate(componentProvider.getByRef(otherFileRef), duplicate))));
    return this;
}
Also used : Component(org.sonar.ce.task.projectanalysis.component.Component)

Aggregations

Component (org.sonar.ce.task.projectanalysis.component.Component)118 Test (org.junit.Test)82 ReportComponent (org.sonar.ce.task.projectanalysis.component.ReportComponent)47 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)31 ComponentDto (org.sonar.db.component.ComponentDto)25 ViewsComponent (org.sonar.ce.task.projectanalysis.component.ViewsComponent)14 DefaultIssue (org.sonar.core.issue.DefaultIssue)14 DbSession (org.sonar.db.DbSession)11 Period (org.sonar.ce.task.projectanalysis.period.Period)8 SnapshotDto (org.sonar.db.component.SnapshotDto)8 FileAttributes (org.sonar.ce.task.projectanalysis.component.FileAttributes)6 DbClient (org.sonar.db.DbClient)6 List (java.util.List)5 ComputationStep (org.sonar.ce.task.step.ComputationStep)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Optional (java.util.Optional)4 DepthTraversalTypeAwareCrawler (org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler)4 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)3 Map (java.util.Map)3