Search in sources :

Example 96 with Component

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

the class AddedFileRepositoryImplTest method isAdded_returns_true_for_any_component_type_on_first_analysis.

@Test
public void isAdded_returns_true_for_any_component_type_on_first_analysis() {
    when(analysisMetadataHolder.isFirstAnalysis()).thenReturn(true);
    Arrays.stream(Component.Type.values()).forEach(type -> {
        Component component = newComponent(type);
        assertThat(underTest.isAdded(component)).isTrue();
    });
}
Also used : Component(org.sonar.ce.task.projectanalysis.component.Component) Test(org.junit.Test)

Example 97 with Component

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

the class AddedFileRepositoryImplTest method isAdded_returns_true_for_registered_file_when_not_on_first_analysis.

@Test
public void isAdded_returns_true_for_registered_file_when_not_on_first_analysis() {
    when(analysisMetadataHolder.isFirstAnalysis()).thenReturn(false);
    Component file1 = newComponent(Component.Type.FILE);
    Component file2 = newComponent(Component.Type.FILE);
    underTest.register(file1);
    assertThat(underTest.isAdded(file1)).isTrue();
    assertThat(underTest.isAdded(file2)).isFalse();
}
Also used : Component(org.sonar.ce.task.projectanalysis.component.Component) Test(org.junit.Test)

Example 98 with Component

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

the class AddedFileRepositoryImplTest method register_fails_with_ISE_if_called_on_first_analysis.

@Test
public void register_fails_with_ISE_if_called_on_first_analysis() {
    when(analysisMetadataHolder.isFirstAnalysis()).thenReturn(true);
    Component component = newComponent(Component.Type.FILE);
    assertThatThrownBy(() -> underTest.register(component)).isInstanceOf(IllegalStateException.class).hasMessage("No file can be registered on first analysis");
}
Also used : Component(org.sonar.ce.task.projectanalysis.component.Component) Test(org.junit.Test)

Example 99 with Component

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

the class AddedFileRepositoryImplTest method newComponent.

private static Component newComponent(Component.Type type) {
    Component component = mock(Component.class);
    when(component.getType()).thenReturn(type);
    return component;
}
Also used : Component(org.sonar.ce.task.projectanalysis.component.Component)

Example 100 with Component

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

the class AddedFileRepositoryImplTest method isAdded_returns_false_for_unregistered_component_type_when_not_on_first_analysis.

@Test
public void isAdded_returns_false_for_unregistered_component_type_when_not_on_first_analysis() {
    when(analysisMetadataHolder.isFirstAnalysis()).thenReturn(false);
    Arrays.stream(Component.Type.values()).forEach(type -> {
        Component component = newComponent(type);
        assertThat(underTest.isAdded(component)).isFalse();
    });
}
Also used : Component(org.sonar.ce.task.projectanalysis.component.Component) Test(org.junit.Test)

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