use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class TrackerReferenceBranchInputFactoryTest 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.create(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 TrackerReferenceBranchInputFactoryTest method gets_issues_and_hashes_in_matching_component.
@Test
public void gets_issues_and_hashes_in_matching_component() {
DefaultIssue issue1 = new DefaultIssue();
when(referenceBranchComponentUuids.getComponentUuid(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, 3);
Component component = mock(Component.class);
when(component.getDbKey()).thenReturn(COMPONENT_KEY);
when(component.getType()).thenReturn(Component.Type.FILE);
Input<DefaultIssue> input = underTest.create(component);
assertThat(input.getIssues()).containsOnly(issue1);
assertThat(input.getLineHashSequence().length()).isEqualTo(3);
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class TrackerTargetBranchInputFactoryTest method get_issues_without_line_hashes.
@Test
public void get_issues_without_line_hashes() {
DefaultIssue issue1 = new DefaultIssue();
when(targetBranchComponentUuids.getTargetBranchComponentUuid(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.createForTargetBranch(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 TrackerTargetBranchInputFactoryTest method gets_issues_and_hashes_in_matching_component.
@Test
public void gets_issues_and_hashes_in_matching_component() {
DefaultIssue issue1 = new DefaultIssue();
when(targetBranchComponentUuids.getTargetBranchComponentUuid(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, 3);
Component component = mock(Component.class);
when(component.getDbKey()).thenReturn(COMPONENT_KEY);
when(component.getType()).thenReturn(Component.Type.FILE);
Input<DefaultIssue> input = underTest.createForTargetBranch(component);
assertThat(input.getIssues()).containsOnly(issue1);
assertThat(input.getLineHashSequence().length()).isEqualTo(3);
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class NotificationFactory method getProject.
private Project getProject() {
Component project = treeRootHolder.getRoot();
Branch branch = analysisMetadataHolder.getBranch();
Project.Builder builder = new Project.Builder(project.getUuid()).setKey(project.getKey()).setProjectName(project.getName());
if (branch.getType() != PULL_REQUEST && !branch.isMain()) {
builder.setBranchName(branch.getName());
}
return builder.build();
}
Aggregations