use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class AddedFileRepositoryImplTest method register_fails_with_IAE_if_component_is_not_a_file.
@Test
@UseDataProvider("anyTypeButFile")
public void register_fails_with_IAE_if_component_is_not_a_file(Component.Type anyTypeButFile) {
Component component = newComponent(anyTypeButFile);
assertThatThrownBy(() -> underTest.register(component)).isInstanceOf(IllegalArgumentException.class).hasMessage("component must be a file");
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class TrackerSourceBranchInputFactoryTest method gets_nothing_when_there_is_no_matching_component.
@Test
public void gets_nothing_when_there_is_no_matching_component() {
Component component = mock(Component.class);
when(component.getDbKey()).thenReturn(COMPONENT_KEY);
when(component.getType()).thenReturn(Component.Type.FILE);
Input<DefaultIssue> input = underTest.createForSourceBranch(component);
assertThat(input.getIssues()).isEmpty();
assertThat(input.getLineHashSequence().length()).isZero();
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class TrackerSourceBranchInputFactoryTest method get_issues_without_line_hashes.
@Test
public void get_issues_without_line_hashes() {
DefaultIssue issue1 = new DefaultIssue();
when(sourceBranchComponentUuids.getSourceBranchComponentUuid(COMPONENT_KEY)).thenReturn(COMPONENT_UUID);
when(componentIssuesLoader.loadOpenIssuesWithChanges(COMPONENT_UUID)).thenReturn(Collections.singletonList(issue1));
ComponentDto fileDto = ComponentTesting.newFileDto(ComponentTesting.newPublicProjectDto()).setUuid(COMPONENT_UUID);
db.fileSources().insertFileSource(fileDto, 0);
Component component = mock(Component.class);
when(component.getDbKey()).thenReturn(COMPONENT_KEY);
when(component.getType()).thenReturn(Component.Type.FILE);
Input<DefaultIssue> input = underTest.createForSourceBranch(component);
assertThat(input.getIssues()).containsOnly(issue1);
assertThat(input.getLineHashSequence().length()).isZero();
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class NewIssueClassifierTest method isNew_returns_false_for_issue_which_was_new_but_it_is_not_located_on_changed_lines_anymore.
@Test
public void isNew_returns_false_for_issue_which_was_new_but_it_is_not_located_on_changed_lines_anymore() {
periodHolder.setPeriod(new Period(NewCodePeriodType.REFERENCE_BRANCH.name(), "master", null));
Component file = mock(Component.class);
DefaultIssue issue = mock(DefaultIssue.class);
when(file.getType()).thenReturn(Component.Type.FILE);
when(file.getUuid()).thenReturn("fileUuid");
when(newLinesRepository.getNewLines(file)).thenReturn(Optional.of(Set.of(2, 3)));
when(issue.getLocations()).thenReturn(DbIssues.Locations.newBuilder().setTextRange(DbCommons.TextRange.newBuilder().setStartLine(10).setStartOffset(1).setEndLine(10).setEndOffset(2).build()).build());
when(issue.isNewCodeReferenceIssue()).thenReturn(true);
assertThat(newIssueClassifier.isNew(file, issue)).isFalse();
assertThat(newIssueClassifier.isOnBranchUsingReferenceBranch()).isTrue();
assertThat(newIssueClassifier.hasAtLeastOneLocationOnChangedLines(file, issue)).isFalse();
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class FillComponentIssuesVisitorRule method setIssues.
public void setIssues(int componentRef, DefaultIssue... issues) {
Component component = treeRootHolder.getComponentByRef(componentRef);
checkArgument(component != null, String.format("Component '%s' does not exists in the report ", componentRef));
this.issues.get(component).clear();
this.issues.putAll(component, asList(issues));
}
Aggregations