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();
});
}
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();
}
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");
}
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;
}
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();
});
}
Aggregations