aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce-task-projectanalysis
diff options
context:
space:
mode:
authorLukasz Jarocki <lukasz.jarocki@sonarsource.com>2022-10-31 12:25:54 +0100
committersonartech <sonartech@sonarsource.com>2022-11-01 20:03:09 +0000
commitb0be5da0c49b74538dbce98014298a104d4ac5b0 (patch)
tree6a9b4734fefe01a34ef2b45336276be4fafa1483 /server/sonar-ce-task-projectanalysis
parentb309ce1704e490af7daef2a0d0ab1bbba8c930b8 (diff)
downloadsonarqube-b0be5da0c49b74538dbce98014298a104d4ac5b0.tar.gz
sonarqube-b0be5da0c49b74538dbce98014298a104d4ac5b0.zip
SONAR-17524 changing default branch name for projects
Diffstat (limited to 'server/sonar-ce-task-projectanalysis')
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchLoader.java9
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImpl.java5
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java9
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchLoaderTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImplTest.java6
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStepTest.java7
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java5
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepTest.java12
13 files changed, 40 insertions, 30 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchLoader.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchLoader.java
index 3eb24b243ac..b0e79f88490 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchLoader.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/BranchLoader.java
@@ -19,13 +19,14 @@
*/
package org.sonar.ce.task.projectanalysis.component;
+import javax.annotation.Nullable;
+import javax.inject.Inject;
import org.sonar.api.utils.MessageException;
import org.sonar.ce.task.projectanalysis.analysis.MutableAnalysisMetadataHolder;
import org.sonar.scanner.protocol.output.ScannerReport;
-import static org.sonar.scanner.protocol.output.ScannerReport.Metadata.BranchType.UNSET;
-import javax.annotation.Nullable;
-import javax.inject.Inject;
+import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.scanner.protocol.output.ScannerReport.Metadata.BranchType.UNSET;
public class BranchLoader {
private final MutableAnalysisMetadataHolder metadataHolder;
@@ -47,7 +48,7 @@ public class BranchLoader {
} else if (hasBranchProperties(metadata)) {
throw MessageException.of("Current edition does not support branch feature");
} else {
- metadataHolder.setBranch(new DefaultBranchImpl());
+ metadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImpl.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImpl.java
index b7d3c0d5808..67f12196ef0 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImpl.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImpl.java
@@ -20,7 +20,6 @@
package org.sonar.ce.task.projectanalysis.component;
import org.sonar.ce.task.projectanalysis.analysis.Branch;
-import org.sonar.db.component.BranchDto;
import org.sonar.db.component.BranchType;
/**
@@ -30,8 +29,8 @@ import org.sonar.db.component.BranchType;
public class DefaultBranchImpl implements Branch {
private final String branchName;
- public DefaultBranchImpl() {
- this.branchName = BranchDto.DEFAULT_MAIN_BRANCH_NAME;
+ public DefaultBranchImpl(String branch) {
+ this.branchName = branch;
}
@Override
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java
index 0016009a0b3..6362ab8ca68 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java
@@ -38,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.sonar.core.platform.EditionProvider.Edition;
+import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
@RunWith(DataProviderRunner.class)
@@ -210,9 +211,9 @@ public class AnalysisMetadataHolderImplTest {
public void set_branch() {
AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
- underTest.setBranch(new DefaultBranchImpl());
+ underTest.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
- assertThat(underTest.getBranch().getName()).isEqualTo("master");
+ assertThat(underTest.getBranch().getName()).isEqualTo("main");
}
@Test
@@ -225,9 +226,9 @@ public class AnalysisMetadataHolderImplTest {
@Test
public void setBranch_throws_ISE_when_called_twice() {
AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
- underTest.setBranch(new DefaultBranchImpl());
+ underTest.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
- assertThatThrownBy(() -> underTest.setBranch(new DefaultBranchImpl()))
+ assertThatThrownBy(() -> underTest.setBranch(new DefaultBranchImpl("main")))
.isInstanceOf(IllegalStateException.class)
.hasMessage("Branch has already been set");
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchLoaderTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchLoaderTest.java
index 1ef830545c3..fd0787729ac 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchLoaderTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchLoaderTest.java
@@ -60,7 +60,7 @@ public class BranchLoaderTest {
Branch branch = metadataHolder.getBranch();
assertThat(branch.isMain()).isTrue();
- assertThat(branch.getName()).isEqualTo(BranchDto.DEFAULT_MAIN_BRANCH_NAME);
+ assertThat(branch.getName()).isEqualTo(BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME);
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java
index 7f3839bab0f..c2ff3c08ab7 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java
@@ -32,9 +32,10 @@ import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
public class ComponentUuidFactoryWithMigrationTest {
- private final Branch mainBranch = new DefaultBranchImpl();
+ private final Branch mainBranch = new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
private Function<String, String> pathToKey = path -> path != null ? "project:" + path : "project";
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImplTest.java
index b8182111459..e8bfcd84658 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImplTest.java
@@ -20,12 +20,12 @@
package org.sonar.ce.task.projectanalysis.component;
import org.junit.Test;
-import org.sonar.db.component.BranchDto;
import org.sonar.db.component.BranchType;
import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
public class DefaultBranchImplTest {
private static final String PROJECT_KEY = "P";
@@ -34,11 +34,11 @@ public class DefaultBranchImplTest {
@Test
public void default_branch_represents_the_project() {
- DefaultBranchImpl branch = new DefaultBranchImpl();
+ DefaultBranchImpl branch = new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
assertThat(branch.isMain()).isTrue();
assertThat(branch.getType()).isEqualTo(BranchType.BRANCH);
- assertThat(branch.getName()).isEqualTo(BranchDto.DEFAULT_MAIN_BRANCH_NAME);
+ assertThat(branch.getName()).isEqualTo(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
assertThat(branch.supportsCrossProjectCpd()).isTrue();
assertThat(branch.generateKey(PROJECT_KEY, null)).isEqualTo("P");
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStepTest.java
index b94d867192d..00ab641116e 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStepTest.java
@@ -56,6 +56,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
import static org.sonar.db.component.ComponentTesting.newDirectory;
import static org.sonar.db.component.ComponentTesting.newFileDto;
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
@@ -558,7 +559,7 @@ public class BuildComponentTreeStepTest {
}
private void setAnalysisMetadataHolder(boolean isPr) {
- Branch branch = isPr ? new PrBranch() : new DefaultBranchImpl();
+ Branch branch = isPr ? new PrBranch(DEFAULT_PROJECT_MAIN_BRANCH_NAME) : new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
analysisMetadataHolder.setRootComponentRef(ROOT_REF)
.setAnalysisDate(ANALYSIS_DATE)
.setBranch(branch)
@@ -575,6 +576,10 @@ public class BuildComponentTreeStepTest {
}
private static class PrBranch extends DefaultBranchImpl {
+ public PrBranch(String branch) {
+ super(branch);
+ }
+
@Override
public BranchType getType() {
return BranchType.PULL_REQUEST;
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java
index 0ae78766c07..8b7bee5e225 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java
@@ -59,6 +59,7 @@ import static org.mockito.Mockito.when;
import static org.sonar.api.measures.CoreMetrics.ALERT_STATUS_KEY;
import static org.sonar.ce.task.projectanalysis.measure.Measure.Level.ERROR;
import static org.sonar.ce.task.projectanalysis.measure.Measure.Level.OK;
+import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
public class QualityGateEventsStepTest {
private static final String PROJECT_VERSION = randomAlphabetic(19);
@@ -250,7 +251,7 @@ public class QualityGateEventsStepTest {
@Test
public void verify_branch_name_is_not_set_in_notification_when_main() {
- analysisMetadataHolder.setBranch(new DefaultBranchImpl());
+ analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
when(measureRepository.getRawMeasure(PROJECT_COMPONENT, alertStatusMetric))
.thenReturn(of(Measure.newMeasureBuilder().setQualityGateStatus(OK_QUALITY_GATE_STATUS).createNoValue()));
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java
index ec94c781441..f725c5437b2 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java
@@ -43,10 +43,8 @@ import org.sonar.ce.task.step.ComputationStep;
import org.sonar.ce.task.step.TestComputationStepContext;
import org.sonar.db.DbClient;
import org.sonar.db.DbTester;
-import org.sonar.db.component.BranchDto;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
-import org.sonar.db.project.ProjectDto;
import org.sonar.server.project.Project;
import static org.assertj.core.api.Assertions.assertThat;
@@ -57,6 +55,7 @@ import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTO
import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
+import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
import static org.sonar.db.component.ComponentDto.UUID_PATH_OF_ROOT;
import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR;
import static org.sonar.db.component.ComponentTesting.newDirectory;
@@ -623,7 +622,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
private ComponentDto prepareProject(Consumer<ComponentDto> populators) {
ComponentDto dto = db.components().insertPrivateProject(populators);
analysisMetadataHolder.setProject(Project.from(dto));
- analysisMetadataHolder.setBranch(new DefaultBranchImpl());
+ analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
return dto;
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java
index a0b7c98b26b..d3e15488558 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java
@@ -98,6 +98,7 @@ import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT;
import static org.sonar.ce.task.projectanalysis.component.Component.Type;
import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
import static org.sonar.ce.task.projectanalysis.step.SendIssueNotificationsStep.NOTIF_TYPES;
+import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.db.component.BranchType.PULL_REQUEST;
import static org.sonar.db.component.ComponentTesting.newBranchComponent;
@@ -127,7 +128,7 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
.setRoot(PROJECT);
@Rule
public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule()
- .setBranch(new DefaultBranchImpl())
+ .setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME))
.setAnalysisDate(new Date(ANALYSE_DATE));
@Rule
public TemporaryFolder temp = new TemporaryFolder();
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java
index fdc355dfe2a..a1eaf07b4c2 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java
@@ -43,13 +43,14 @@ import org.sonar.db.component.SnapshotTesting;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
public class ValidateProjectStepTest {
static long PAST_ANALYSIS_TIME = 1_420_088_400_000L; // 2015-01-01
static long DEFAULT_ANALYSIS_TIME = 1_433_131_200_000L; // 2015-06-01
static final String PROJECT_KEY = "PROJECT_KEY";
- static final Branch DEFAULT_BRANCH = new DefaultBranchImpl();
+ static final Branch DEFAULT_BRANCH = new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java
index 52e02ab9b0a..9690ef6f783 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java
@@ -56,6 +56,7 @@ import static org.mockito.Mockito.when;
import static org.sonar.ce.task.projectanalysis.component.ViewAttributes.Type.APPLICATION;
import static org.sonar.ce.task.projectanalysis.component.ViewAttributes.Type.PORTFOLIO;
import static org.sonar.ce.task.projectanalysis.component.ViewsComponent.builder;
+import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
import static org.sonar.db.component.ComponentTesting.newProjectCopy;
import static org.sonar.db.component.ComponentTesting.newSubPortfolio;
@@ -96,7 +97,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
now = DATE_FORMAT.parse("2015-06-02");
when(system2.now()).thenReturn(now.getTime());
- analysisMetadataHolder.setBranch(new DefaultBranchImpl());
+ analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
BranchPersister branchPersister = mock(BranchPersister.class);
ProjectPersister projectPersister = mock(ProjectPersister.class);
underTest = new PersistComponentsStep(dbClient, treeRootHolder, system2, disabledComponentsHolder, analysisMetadataHolder, branchPersister, projectPersister);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepTest.java
index ace1622934d..7e622600604 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepTest.java
@@ -125,12 +125,12 @@ public class ExportBranchesStepTest {
.stream()
.collect(toMap(ProjectDump.Branch::getUuid, Function.identity()));
assertThat(branches).hasSize(3);
- ProjectDump.Branch masterBranch = branches.get(PROJECT_UUID);
- assertThat(masterBranch).isNotNull();
- assertThat(masterBranch.getKee()).isEqualTo("master");
- assertThat(masterBranch.getProjectUuid()).isEqualTo(PROJECT_UUID);
- assertThat(masterBranch.getMergeBranchUuid()).isEmpty();
- assertThat(masterBranch.getBranchType()).isEqualTo("BRANCH");
+ ProjectDump.Branch mainBranch = branches.get(PROJECT_UUID);
+ assertThat(mainBranch).isNotNull();
+ assertThat(mainBranch.getKee()).isEqualTo(BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+ assertThat(mainBranch.getProjectUuid()).isEqualTo(PROJECT_UUID);
+ assertThat(mainBranch.getMergeBranchUuid()).isEmpty();
+ assertThat(mainBranch.getBranchType()).isEqualTo("BRANCH");
ProjectDump.Branch branch1 = branches.get("branch-1-uuid");
assertThat(branch1.getKee()).isEqualTo("branch-1");
assertThat(branch1.getProjectUuid()).isEqualTo(PROJECT_UUID);