use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class ScmInfoDbLoaderTest method do_not_read_from_db_on_first_analysis_if_there_is_no_reference_branch.
@Test
public void do_not_read_from_db_on_first_analysis_if_there_is_no_reference_branch() {
Branch branch = mock(Branch.class);
when(branch.getType()).thenReturn(BranchType.PULL_REQUEST);
analysisMetadataHolder.setBaseAnalysis(null);
analysisMetadataHolder.setBranch(branch);
assertThat(underTest.getScmInfo(FILE)).isEmpty();
assertThat(logTester.logs(TRACE)).isEmpty();
}
use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class ScmInfoDbLoaderTest method read_from_target_if_pullrequest.
@Test
public void read_from_target_if_pullrequest() {
Branch branch = mock(Branch.class);
when(branch.getType()).thenReturn(BranchType.PULL_REQUEST);
analysisMetadataHolder.setBaseAnalysis(null);
analysisMetadataHolder.setBranch(branch);
String targetBranchFileUuid = "targetBranchFileUuid";
String hash = computeSourceHash(1);
when(referenceBranchComponentUuids.getComponentUuid(FILE.getDbKey())).thenReturn(targetBranchFileUuid);
addFileSourceInDb("henry", DATE_1, "rev-1", hash, targetBranchFileUuid);
DbScmInfo scmInfo = underTest.getScmInfo(FILE).get();
assertThat(scmInfo.getAllChangesets()).hasSize(1);
assertThat(scmInfo.fileHash()).isEqualTo(hash);
assertThat(logTester.logs(TRACE)).containsOnly("Reading SCM info from DB for file 'targetBranchFileUuid'");
}
use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class CrossProjectDuplicationStatusHolderImplTest method newBranch.
private static Branch newBranch(boolean supportsCrossProjectCpd) {
Branch branch = mock(Branch.class);
when(branch.supportsCrossProjectCpd()).thenReturn(supportsCrossProjectCpd);
return branch;
}
use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class IssueTrackingDelegatorTest method delegate_pull_request_tracker.
@Test
public void delegate_pull_request_tracker() {
Branch branch = mock(Branch.class);
when(branch.getType()).thenReturn(BranchType.PULL_REQUEST);
when(analysisMetadataHolder.getBranch()).thenReturn(mock(Branch.class));
when(analysisMetadataHolder.isPullRequest()).thenReturn(true);
underTest.track(component, rawInput);
verify(prBranchTracker).track(component, rawInput);
verifyNoInteractions(tracker);
verifyNoInteractions(mergeBranchTracker);
}
use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class NewEffortAggregatorTest method no_measures_if_no_periods.
@Test
public void no_measures_if_no_periods() {
when(newIssueClassifier.isEnabled()).thenReturn(false);
Branch branch = mock(Branch.class);
when(branch.getType()).thenReturn(BranchType.BRANCH);
periodsHolder.setPeriod(null);
DefaultIssue unresolved = newCodeSmellIssue(10);
underTest.beforeComponent(FILE);
underTest.onIssue(FILE, unresolved);
underTest.afterComponent(FILE);
assertThat(measureRepository.getRawMeasures(FILE)).isEmpty();
}
Aggregations