Search in sources :

Example 1 with SiblingComponentsWithOpenIssues

use of org.sonar.ce.task.projectanalysis.component.SiblingComponentsWithOpenIssues 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()));
}
Also used : Branch(org.sonar.ce.task.projectanalysis.analysis.Branch) IssueDto(org.sonar.db.issue.IssueDto) RuleDefinitionDto(org.sonar.db.rule.RuleDefinitionDto) UserDto(org.sonar.db.user.UserDto) Date(java.util.Date) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) ComponentTesting.newFileDto(org.sonar.db.component.ComponentTesting.newFileDto) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SimpleTracker(org.sonar.core.issue.tracking.SimpleTracker) MapSettings(org.sonar.api.config.internal.MapSettings) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) ArgumentCaptor(org.mockito.ArgumentCaptor) AnalysisMetadataHolderRule(org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolderRule) ReportComponent.builder(org.sonar.ce.task.projectanalysis.component.ReportComponent.builder) Before(org.junit.Before) DbTester(org.sonar.db.DbTester) BranchType(org.sonar.db.component.BranchType) DefaultIssue(org.sonar.core.issue.DefaultIssue) System2(org.sonar.api.utils.System2) IssueTesting(org.sonar.db.issue.IssueTesting) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Instant(java.time.Instant) Mockito.verify(org.mockito.Mockito.verify) FieldDiffs(org.sonar.core.issue.FieldDiffs) DbClient(org.sonar.db.DbClient) ComponentDto(org.sonar.db.component.ComponentDto) ChronoUnit(java.time.temporal.ChronoUnit) Rule(org.junit.Rule) Issue(org.sonar.api.issue.Issue) RuleKey(org.sonar.api.rule.RuleKey) TreeRootHolderRule(org.sonar.ce.task.projectanalysis.component.TreeRootHolderRule) SiblingComponentsWithOpenIssues(org.sonar.ce.task.projectanalysis.component.SiblingComponentsWithOpenIssues) Collections(java.util.Collections) Project(org.sonar.server.project.Project) Mockito.mock(org.mockito.Mockito.mock) Project(org.sonar.server.project.Project) DbClient(org.sonar.db.DbClient) MapSettings(org.sonar.api.config.internal.MapSettings) SiblingComponentsWithOpenIssues(org.sonar.ce.task.projectanalysis.component.SiblingComponentsWithOpenIssues) Before(org.junit.Before)

Aggregations

Instant (java.time.Instant)1 ChronoUnit (java.time.temporal.ChronoUnit)1 Collections (java.util.Collections)1 Date (java.util.Date)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1 ArgumentCaptor (org.mockito.ArgumentCaptor)1 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.verify (org.mockito.Mockito.verify)1 Mockito.verifyNoInteractions (org.mockito.Mockito.verifyNoInteractions)1 Mockito.when (org.mockito.Mockito.when)1 MapSettings (org.sonar.api.config.internal.MapSettings)1 Issue (org.sonar.api.issue.Issue)1 RuleKey (org.sonar.api.rule.RuleKey)1 System2 (org.sonar.api.utils.System2)1 AnalysisMetadataHolderRule (org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolderRule)1 Branch (org.sonar.ce.task.projectanalysis.analysis.Branch)1