use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class NewIssueClassifierTest method newPr.
private Branch newPr() {
Branch nonMainBranch = mock(Branch.class);
when(nonMainBranch.isMain()).thenReturn(false);
when(nonMainBranch.getType()).thenReturn(BranchType.PULL_REQUEST);
return nonMainBranch;
}
use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class PersistProjectLinksStepTest method mockBranch.
private void mockBranch(boolean isMain) {
Branch branch = Mockito.mock(Branch.class);
when(branch.isMain()).thenReturn(isMain);
analysisMetadataHolder.setBranch(branch);
}
use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class LoadDuplicationsFromReportStepTest method loads_duplication_with_otherFileRef_as_InExtendedProject_duplication.
@Test
public void loads_duplication_with_otherFileRef_as_InExtendedProject_duplication() {
Branch branch = mock(Branch.class);
when(branch.getType()).thenReturn(BranchType.PULL_REQUEST);
analysisMetadataHolder.setBranch(branch);
reportReader.putDuplications(FILE_1_REF, createDuplication(singleLineTextRange(LINE), createInProjectDuplicate(FILE_2_REF, LINE + 1)));
TestComputationStepContext context = new TestComputationStepContext();
underTest.execute(context);
assertDuplications(FILE_1_REF, singleLineDetailedTextBlock(1, LINE), new InExtendedProjectDuplicate(treeRootHolder.getComponentByRef(FILE_2_REF), singleLineTextBlock(LINE + 1)));
assertNoDuplication(FILE_2_REF);
assertNbOfDuplications(context, 1);
}
use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class SiblingsIssueMergerTest method setUp.
@Before
public void setUp() {
DbClient dbClient = db.getDbClient();
ComponentIssuesLoader componentIssuesLoader = new ComponentIssuesLoader(dbClient, null, null, new MapSettings().asConfig(), System2.INSTANCE);
copier = new SiblingsIssueMerger(new SiblingsIssuesLoader(new SiblingComponentsWithOpenIssues(treeRootHolder, metadataHolder, dbClient), dbClient, componentIssuesLoader), tracker, issueLifecycle);
projectDto = db.components().insertPublicProject(p -> p.setDbKey(PROJECT_KEY).setUuid(PROJECT_UUID));
branch1Dto = db.components().insertProjectBranch(projectDto, b -> b.setKey("myBranch1").setBranchType(BranchType.PULL_REQUEST).setMergeBranchUuid(projectDto.uuid()));
branch2Dto = db.components().insertProjectBranch(projectDto, b -> b.setKey("myBranch2").setBranchType(BranchType.PULL_REQUEST).setMergeBranchUuid(projectDto.uuid()));
branch3Dto = db.components().insertProjectBranch(projectDto, b -> b.setKey("myBranch3").setBranchType(BranchType.PULL_REQUEST).setMergeBranchUuid(projectDto.uuid()));
fileOnBranch1Dto = db.components().insertComponent(newFileDto(branch1Dto).setDbKey(FILE_1_KEY + ":PULL_REQUEST:myBranch1"));
fileOnBranch2Dto = db.components().insertComponent(newFileDto(branch2Dto).setDbKey(FILE_1_KEY + ":PULL_REQUEST:myBranch2"));
fileOnBranch3Dto = db.components().insertComponent(newFileDto(branch3Dto).setDbKey(FILE_1_KEY + ":PULL_REQUEST:myBranch3"));
rule = db.rules().insert();
when(branch.getReferenceBranchUuid()).thenReturn(projectDto.uuid());
metadataHolder.setBranch(branch);
metadataHolder.setProject(new Project(projectDto.uuid(), projectDto.getKey(), projectDto.name(), projectDto.description(), Collections.emptyList()));
}
use of org.sonar.ce.task.projectanalysis.analysis.Branch in project sonarqube by SonarSource.
the class SourceBranchComponentUuidsTest method setup.
@Before
public void setup() {
underTest = new SourceBranchComponentUuids(analysisMetadataHolder, db.getDbClient());
Project project = mock(Project.class);
analysisMetadataHolder.setProject(project);
analysisMetadataHolder.setBranch(branch);
ComponentDto projectDto = db.components().insertPublicProject();
when(project.getUuid()).thenReturn(projectDto.uuid());
branch1 = db.components().insertProjectBranch(projectDto, b -> b.setKey(BRANCH_KEY));
ComponentDto pr1branch = db.components().insertProjectBranch(projectDto, b -> b.setKey(PR_KEY).setBranchType(BranchType.PULL_REQUEST).setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch(BRANCH_KEY).build()).setMergeBranchUuid(projectDto.getMainBranchProjectUuid()));
branch1File = ComponentTesting.newFileDto(branch1, null, "file").setUuid("branch1File");
pr1File = ComponentTesting.newFileDto(pr1branch, null, "file").setUuid("file1");
db.components().insertComponents(branch1File, pr1File);
}
Aggregations