]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-17613 changing default branch for applications to follow the setting
authorLukasz Jarocki <lukasz.jarocki@sonarsource.com>
Thu, 15 Dec 2022 14:20:40 +0000 (15:20 +0100)
committersonartech <sonartech@sonarsource.com>
Thu, 15 Dec 2022 20:03:33 +0000 (20:03 +0000)
38 files changed:
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchLoaderTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImplTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java
server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepTest.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDto.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
server/sonar-server-common/src/main/java/org/sonar/server/project/DefaultBranchNameResolver.java
server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueQueryFactoryTest.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentUpdater.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/azure/ImportAzureProjectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/bitbucketserver/ImportBitbucketServerProjectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/gitlab/ImportGitLabProjectActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/ws/ListActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/ws/SetAutomaticDeletionProtectionActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/ReportSubmitterTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentFinderTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentUpdaterTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/ShowActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/TreeActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullTaintActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/ListActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/SetActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/CreateActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SetBaselineActionTest.java

index 6362ab8ca685cc4a04b85ef4fe7f37723eb3608a..21e4fa952f1d10b22a7d99b15ee79045a3408592 100644 (file)
@@ -38,7 +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.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 
 @RunWith(DataProviderRunner.class)
@@ -211,7 +211,7 @@ public class AnalysisMetadataHolderImplTest {
   public void set_branch() {
     AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
 
-    underTest.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
+    underTest.setBranch(new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME));
 
     assertThat(underTest.getBranch().getName()).isEqualTo("main");
   }
@@ -226,7 +226,7 @@ public class AnalysisMetadataHolderImplTest {
   @Test
   public void setBranch_throws_ISE_when_called_twice() {
     AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
-    underTest.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
+    underTest.setBranch(new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME));
 
     assertThatThrownBy(() -> underTest.setBranch(new DefaultBranchImpl("main")))
       .isInstanceOf(IllegalStateException.class)
index 5f1dc0ab1ade36eb9a49996acf3d520ded29eed2..5dbec9ffa4ece3ad2399189069f27817acd9061f 100644 (file)
@@ -33,7 +33,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 
 public class BranchLoaderTest {
 
@@ -56,7 +56,7 @@ public class BranchLoaderTest {
     ScannerReport.Metadata metadata = ScannerReport.Metadata.newBuilder()
       .build();
     DefaultBranchNameResolver branchNameResolver = mock(DefaultBranchNameResolver.class);
-    when(branchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    when(branchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_MAIN_BRANCH_NAME);
 
     new BranchLoader(metadataHolder, branchNameResolver).load(metadata);
 
@@ -64,7 +64,7 @@ public class BranchLoaderTest {
 
     Branch branch = metadataHolder.getBranch();
     assertThat(branch.isMain()).isTrue();
-    assertThat(branch.getName()).isEqualTo(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    assertThat(branch.getName()).isEqualTo(DEFAULT_MAIN_BRANCH_NAME);
   }
 
   @Test
index c2ff3c08ab73090e2a48f747ab56117d32ff2f3b..3343f266d4079846b2d0e53a1fd3fa56dccfe005 100644 (file)
@@ -32,10 +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;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 
 public class ComponentUuidFactoryWithMigrationTest {
-  private final Branch mainBranch = new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+  private final Branch mainBranch = new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME);
   @Rule
   public DbTester db = DbTester.create(System2.INSTANCE);
   private Function<String, String> pathToKey = path -> path != null ? "project:" + path : "project";
index e8bfcd84658a4813f8d9f5a75e6c292027eb2524..e8ad33d45db9ec408047603c6e7409a80ab43e66 100644 (file)
@@ -25,7 +25,7 @@ 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;
+import static org.sonar.db.component.BranchDto.DEFAULT_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(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    DefaultBranchImpl branch = new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME);
 
     assertThat(branch.isMain()).isTrue();
     assertThat(branch.getType()).isEqualTo(BranchType.BRANCH);
-    assertThat(branch.getName()).isEqualTo(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    assertThat(branch.getName()).isEqualTo(DEFAULT_MAIN_BRANCH_NAME);
     assertThat(branch.supportsCrossProjectCpd()).isTrue();
 
     assertThat(branch.generateKey(PROJECT_KEY, null)).isEqualTo("P");
index 00ab641116e1c4b96d4ac63d136dbf870a764ce2..5de85bf428e32895193b07239555d54eba28cba4 100644 (file)
@@ -56,7 +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.BranchDto.DEFAULT_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;
@@ -559,7 +559,7 @@ public class BuildComponentTreeStepTest {
   }
 
   private void setAnalysisMetadataHolder(boolean isPr) {
-    Branch branch = isPr ? new PrBranch(DEFAULT_PROJECT_MAIN_BRANCH_NAME) : new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    Branch branch = isPr ? new PrBranch(DEFAULT_MAIN_BRANCH_NAME) : new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME);
     analysisMetadataHolder.setRootComponentRef(ROOT_REF)
       .setAnalysisDate(ANALYSIS_DATE)
       .setBranch(branch)
index 8b7bee5e2251f72160c822623317c9b1eb7e50be..5412282cff6afed501cbb23a0ad13417ede80a59 100644 (file)
@@ -59,7 +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;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 
 public class QualityGateEventsStepTest {
   private static final String PROJECT_VERSION = randomAlphabetic(19);
@@ -251,7 +251,7 @@ public class QualityGateEventsStepTest {
 
   @Test
   public void verify_branch_name_is_not_set_in_notification_when_main() {
-    analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
+    analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME));
 
     when(measureRepository.getRawMeasure(PROJECT_COMPONENT, alertStatusMetric))
       .thenReturn(of(Measure.newMeasureBuilder().setQualityGateStatus(OK_QUALITY_GATE_STATUS).createNoValue()));
index f725c5437b227b204c5c2a852256d2887d566e26..57acd1de9aea3363825ef8a24fe7f8e94878a70d 100644 (file)
@@ -55,7 +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.BranchDto.DEFAULT_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;
@@ -622,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(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
+    analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME));
     return dto;
   }
 
index d3e154885581c0e0219e959f33bff769a8aed335..eefe48604f2c557e488f311db6462f013be6344b 100644 (file)
@@ -98,7 +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.BranchDto.DEFAULT_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;
@@ -128,7 +128,7 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
     .setRoot(PROJECT);
   @Rule
   public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule()
-    .setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME))
+    .setBranch(new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME))
     .setAnalysisDate(new Date(ANALYSE_DATE));
   @Rule
   public TemporaryFolder temp = new TemporaryFolder();
index a1eaf07b4c2bdc027d11f7b0c90aad3299b76328..e0d0a867ae6dbe88d1221b87a855ae97e92789bd 100644 (file)
@@ -43,14 +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;
+import static org.sonar.db.component.BranchDto.DEFAULT_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(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+  static final Branch DEFAULT_BRANCH = new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME);
 
   @Rule
   public DbTester db = DbTester.create(System2.INSTANCE);
index 9690ef6f783272d2803a83c7ebfcb07e62ef47ec..8f4a8a868df576404fd116dc7d1a2fd3df3880e7 100644 (file)
@@ -56,7 +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.BranchDto.DEFAULT_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;
@@ -97,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(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
+    analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME));
     BranchPersister branchPersister = mock(BranchPersister.class);
     ProjectPersister projectPersister = mock(ProjectPersister.class);
     underTest = new PersistComponentsStep(dbClient, treeRootHolder, system2, disabledComponentsHolder, analysisMetadataHolder, branchPersister, projectPersister);
index 7e6226006045b92dcc1e9a5c90df3200cb475c59..4ad64c220499c4f315f1306f0f3393e2a05896e8 100644 (file)
@@ -127,7 +127,7 @@ public class ExportBranchesStepTest {
     assertThat(branches).hasSize(3);
     ProjectDump.Branch mainBranch = branches.get(PROJECT_UUID);
     assertThat(mainBranch).isNotNull();
-    assertThat(mainBranch.getKee()).isEqualTo(BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    assertThat(mainBranch.getKee()).isEqualTo(BranchDto.DEFAULT_MAIN_BRANCH_NAME);
     assertThat(mainBranch.getProjectUuid()).isEqualTo(PROJECT_UUID);
     assertThat(mainBranch.getMergeBranchUuid()).isEmpty();
     assertThat(mainBranch.getBranchType()).isEqualTo("BRANCH");
index e0eb96b5ba945392912b1dd859639368b45a4b8a..9904d006028e76584b072bdc905279311828625a 100644 (file)
@@ -30,8 +30,7 @@ import org.sonar.db.protobuf.DbProjectBranches;
 import static com.google.common.base.Preconditions.checkArgument;
 
 public class BranchDto {
-  public static final String DEFAULT_PROJECT_MAIN_BRANCH_NAME = "main";
-  public static final String DEFAULT_APPLICATION_MAIN_BRANCH_NAME = "master";
+  public static final String DEFAULT_MAIN_BRANCH_NAME = "main";
 
   /**
    * Maximum length of column "kee"
index f9b8a6e69777b06adbc57ae761e69479b48b8bb9..49ee5c197608546ae523f5fd26c3427cad7393aa 100644 (file)
@@ -82,7 +82,7 @@ import static org.sonar.api.resources.Qualifiers.PROJECT;
 import static org.sonar.api.resources.Qualifiers.SUBVIEW;
 import static org.sonar.api.resources.Qualifiers.VIEW;
 import static org.sonar.api.utils.DateUtils.parseDate;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_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.newApplication;
@@ -235,7 +235,7 @@ public class ComponentDaoTest {
     ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("my_branch").setBranchType(BRANCH));
     ComponentDto file = db.components().insertComponent(newFileDto(branch));
 
-    assertThat(underTest.selectByKeyAndBranch(dbSession, project.getKey(), DEFAULT_PROJECT_MAIN_BRANCH_NAME).get().uuid()).isEqualTo(project.uuid());
+    assertThat(underTest.selectByKeyAndBranch(dbSession, project.getKey(), DEFAULT_MAIN_BRANCH_NAME).get().uuid()).isEqualTo(project.uuid());
     assertThat(underTest.selectByKeyAndBranch(dbSession, branch.getKey(), "my_branch").get().uuid()).isEqualTo(branch.uuid());
     assertThat(underTest.selectByKeyAndBranch(dbSession, file.getKey(), "my_branch").get().uuid()).isEqualTo(file.uuid());
     assertThat(underTest.selectByKeyAndBranch(dbSession, "unknown", "my_branch")).isNotPresent();
index 5e9fabdafb0bcbd7f123ec756604b2eed304269c..818740dd386e14a7e4e203b3a5578139721c0588 100644 (file)
@@ -44,7 +44,7 @@ import static java.util.Collections.singletonList;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.groups.Tuple.tuple;
 import static org.sonar.api.measures.Metric.ValueType.INT;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
 import static org.sonar.db.measure.MeasureTesting.newLiveMeasure;
@@ -333,11 +333,11 @@ public class LiveMeasureDaoTest {
     List<LargestBranchNclocDto> results = underTest.getLargestBranchNclocPerProject(db.getSession());
 
     assertThat(results).hasSize(5);
-    assertLocForProject(results.get(0), "projectWithTieOnBranchSize", DEFAULT_PROJECT_MAIN_BRANCH_NAME, 250);
+    assertLocForProject(results.get(0), "projectWithTieOnBranchSize", DEFAULT_MAIN_BRANCH_NAME, 250);
     assertLocForProject(results.get(1), "projectWithTieOnOtherBranches", "tieBranch1", 230);
     assertLocForProject(results.get(2), "projectWithBranchBiggerThanMaster", "notMasterBranch", 200);
-    assertLocForProject(results.get(3), "simpleProject", DEFAULT_PROJECT_MAIN_BRANCH_NAME, 10);
-    assertLocForProject(results.get(4), "projectWithLinesButNoLoc", DEFAULT_PROJECT_MAIN_BRANCH_NAME, 0);
+    assertLocForProject(results.get(3), "simpleProject", DEFAULT_MAIN_BRANCH_NAME, 10);
+    assertLocForProject(results.get(4), "projectWithLinesButNoLoc", DEFAULT_MAIN_BRANCH_NAME, 0);
   }
 
   @Test
index 251bd2a73632f1d79c4c6bb79e4bcc570c9c77ef..b9d6e5c8b82dfd898f71a6acb23f746c4d611514 100644 (file)
@@ -28,8 +28,7 @@ import org.sonar.db.project.ProjectDto;
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
-import static org.sonar.db.component.BranchDto.DEFAULT_APPLICATION_MAIN_BRANCH_NAME;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_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.ComponentDto.formatUuidPathFromParent;
@@ -219,9 +218,7 @@ public class ComponentTesting {
   public static BranchDto newBranchDto(ComponentDto branchComponent, BranchType branchType) {
     boolean isMain = branchComponent.getMainBranchProjectUuid() == null;
     String projectUuid = isMain ? branchComponent.uuid() : branchComponent.getMainBranchProjectUuid();
-    String defaultBranchName = branchComponent.qualifier() != null && branchComponent.qualifier().equals("APP") ?
-      DEFAULT_APPLICATION_MAIN_BRANCH_NAME : DEFAULT_PROJECT_MAIN_BRANCH_NAME;
-    String key = isMain ? defaultBranchName : "branch_" + randomAlphanumeric(248);
+    String key = isMain ? DEFAULT_MAIN_BRANCH_NAME : "branch_" + randomAlphanumeric(248);
 
     return new BranchDto()
       .setKey(key)
index bd93736002b340c79a72524089d7c419f43b8f6c..586aecb607933dd2a813d87fce6805e7f807e536 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.server.project;
 import org.sonar.api.config.Configuration;
 
 import static org.sonar.core.config.CorePropertyDefinitions.SONAR_PROJECTCREATION_MAINBRANCHNAME;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 
 public class DefaultBranchNameResolver {
 
@@ -33,6 +33,6 @@ public class DefaultBranchNameResolver {
   }
 
   public String getEffectiveMainBranchName() {
-    return configuration.get(SONAR_PROJECTCREATION_MAINBRANCHNAME).orElse(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    return configuration.get(SONAR_PROJECTCREATION_MAINBRANCHNAME).orElse(DEFAULT_MAIN_BRANCH_NAME);
   }
 }
index e77377b038fd2e4a8afd53944c8e2a4c21ab0781..90b7368f99d8fa5090a73833e232e0926528ca30 100644 (file)
@@ -55,7 +55,7 @@ import static org.sonar.api.resources.Qualifiers.APP;
 import static org.sonar.api.utils.DateUtils.addDays;
 import static org.sonar.api.utils.DateUtils.parseDateTime;
 import static org.sonar.api.web.UserRole.USER;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_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.newModuleDto;
@@ -609,12 +609,12 @@ public class IssueQueryFactoryTest {
 
     assertThat(underTest.create(new SearchRequest()
       .setProjects(singletonList(project.getKey()))
-      .setBranch(DEFAULT_PROJECT_MAIN_BRANCH_NAME)))
+      .setBranch(DEFAULT_MAIN_BRANCH_NAME)))
       .extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
       .containsOnly(project.uuid(), singletonList(project.uuid()), true);
     assertThat(underTest.create(new SearchRequest()
       .setComponents(singletonList(project.getKey()))
-      .setBranch(DEFAULT_PROJECT_MAIN_BRANCH_NAME)))
+      .setBranch(DEFAULT_MAIN_BRANCH_NAME)))
       .extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch)
       .containsOnly(project.uuid(), singletonList(project.uuid()), true);
   }
index baeb217f15a8b4fa304f901c54a54a2045009964..c405f0cbb94b642289112d7103bcbdefc83d1fb5 100644 (file)
@@ -106,7 +106,7 @@ public class ComponentUpdater {
   public ComponentDto createApplicationOrPortfolio(DbSession dbSession, NewComponent newComponent, @Nullable String userUuid,
     @Nullable String userLogin) {
     ComponentDto componentDto = createWithoutCommit(dbSession, newComponent, userUuid, userLogin,
-      BranchDto.DEFAULT_APPLICATION_MAIN_BRANCH_NAME, c -> {});
+      defaultBranchNameResolver.getEffectiveMainBranchName(), c -> {});
     commitAndIndex(dbSession, componentDto);
     return componentDto;
   }
index bf7ffd17cfd64c7e462182de90275eba25c31f39..c66a1a700e7492a9f99d3e8ddc2f821ec50bc86c 100644 (file)
@@ -64,7 +64,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.sonar.db.alm.integration.pat.AlmPatsTesting.newAlmPatDto;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.permission.GlobalPermission.PROVISION_PROJECTS;
 import static org.sonar.db.permission.GlobalPermission.SCAN;
 
@@ -99,7 +99,7 @@ public class ImportAzureProjectActionTest {
   public void before() {
     when(projectDefaultVisibility.get(any())).thenReturn(Visibility.PRIVATE);
     when(projectKeyGenerator.generateUniqueProjectKey(any(), any())).thenReturn(GENERATED_PROJECT_KEY);
-    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_MAIN_BRANCH_NAME);
   }
 
   @Test
@@ -178,7 +178,7 @@ public class ImportAzureProjectActionTest {
       .findFirst();
 
     assertThat(mainBranch).isPresent();
-    assertThat(mainBranch.get().getKey()).hasToString(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    assertThat(mainBranch.get().getKey()).hasToString(DEFAULT_MAIN_BRANCH_NAME);
   }
 
   @Test
index 634a9c098f101440a95e7e78e12ee4030bd70549..4cd9c618ea904cb8b942246e4bba11454a970c5d 100644 (file)
@@ -71,7 +71,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.sonar.db.alm.integration.pat.AlmPatsTesting.newAlmPatDto;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.permission.GlobalPermission.PROVISION_PROJECTS;
 import static org.sonar.db.permission.GlobalPermission.SCAN;
 
@@ -110,7 +110,7 @@ public class ImportBitbucketServerProjectActionTest {
   public void before() {
     when(projectDefaultVisibility.get(any())).thenReturn(Visibility.PRIVATE);
     when(projectKeyGenerator.generateUniqueProjectKey(any(), any())).thenReturn(GENERATED_PROJECT_KEY);
-    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_MAIN_BRANCH_NAME);
   }
 
   @Test
@@ -274,7 +274,7 @@ public class ImportBitbucketServerProjectActionTest {
     Collection<BranchDto> branchDtos = db.getDbClient().branchDao().selectByProject(db.getSession(), projectDto.get());
     List<BranchDto> collect = branchDtos.stream().filter(BranchDto::isMain).collect(Collectors.toList());
     String mainBranchName = collect.iterator().next().getKey();
-    assertThat(mainBranchName).isEqualTo(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    assertThat(mainBranchName).isEqualTo(DEFAULT_MAIN_BRANCH_NAME);
   }
 
   @Test
index d4268f54c2c987b60165609765a4f439983898d0..92173fb9cf0c7c0fd2809bcd58389cdf67d38827 100644 (file)
@@ -57,7 +57,7 @@ import static org.assertj.core.api.Assertions.tuple;
 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.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.server.almintegration.ws.ImportHelper.PARAM_ALM_SETTING;
 import static org.sonar.server.almintegration.ws.github.ImportGithubProjectAction.PARAM_ORGANIZATION;
 import static org.sonar.server.almintegration.ws.github.ImportGithubProjectAction.PARAM_REPOSITORY_KEY;
@@ -90,7 +90,7 @@ public class ImportGithubProjectActionTest {
   @Before
   public void before() {
     when(projectDefaultVisibility.get(any())).thenReturn(Visibility.PRIVATE);
-    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_MAIN_BRANCH_NAME);
   }
 
   @Test
index dff38677e51b344925df61b50e7147c1f92b43a5..d12efd1328f644091e1ede9861491d2a29eb9f6c 100644 (file)
@@ -57,7 +57,7 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.permission.GlobalPermission.PROVISION_PROJECTS;
 import static org.sonar.server.tester.UserSessionRule.standalone;
 
@@ -90,7 +90,7 @@ public class ImportGitLabProjectActionTest {
   @Before
   public void before() {
     when(projectDefaultVisibility.get(any())).thenReturn(Visibility.PRIVATE);
-    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_MAIN_BRANCH_NAME);
   }
 
   @Test
@@ -193,7 +193,7 @@ public class ImportGitLabProjectActionTest {
 
     Assertions.assertThat(db.getDbClient().branchDao().selectByProject(db.getSession(), projectDto.get()))
       .extracting(BranchDto::getKey, BranchDto::isMain)
-      .containsExactlyInAnyOrder(tuple(DEFAULT_PROJECT_MAIN_BRANCH_NAME, true));
+      .containsExactlyInAnyOrder(tuple(DEFAULT_MAIN_BRANCH_NAME, true));
   }
 
 
index dbf169475904eaad28ce6cacf19ef0188dedcbe4..82e915362ec2ceaf2dbbc7459d6b56e63d6309d3 100644 (file)
@@ -57,7 +57,7 @@ import static org.sonar.api.utils.DateUtils.dateToLong;
 import static org.sonar.api.utils.DateUtils.parseDateTime;
 import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.component.BranchType.BRANCH;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 import static org.sonar.test.JsonAssert.assertJson;
@@ -162,7 +162,7 @@ public class ListActionTest {
 
     assertThat(response.getBranchesList())
       .extracting(Branch::getName, Branch::getIsMain, Branch::getType)
-      .containsExactlyInAnyOrder(tuple(DEFAULT_PROJECT_MAIN_BRANCH_NAME, true, BranchType.BRANCH));
+      .containsExactlyInAnyOrder(tuple(DEFAULT_MAIN_BRANCH_NAME, true, BranchType.BRANCH));
   }
 
   @Test
@@ -195,7 +195,7 @@ public class ListActionTest {
     assertThat(response.getBranchesList())
       .extracting(Branch::getName, Branch::getType)
       .containsExactlyInAnyOrder(
-        tuple(DEFAULT_PROJECT_MAIN_BRANCH_NAME, BranchType.BRANCH),
+        tuple(DEFAULT_MAIN_BRANCH_NAME, BranchType.BRANCH),
         tuple("feature/foo", BranchType.BRANCH),
         tuple("feature/bar", BranchType.BRANCH));
   }
@@ -259,7 +259,7 @@ public class ListActionTest {
     assertThat(response.getBranchesList())
       .extracting(Branch::getName, Branch::getType)
       .containsExactlyInAnyOrder(
-        tuple("master", BranchType.BRANCH),
+        tuple("main", BranchType.BRANCH),
         tuple("feature/foo", BranchType.BRANCH),
         tuple("feature/bar", BranchType.BRANCH));
   }
index 16174e399340d681c99398c1753b108af572b507..16c96f1378ee212741978590245da1e96b4c622f 100644 (file)
@@ -40,7 +40,7 @@ import org.sonar.server.ws.WsActionTester;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.sonar.api.resources.Qualifiers.PROJECT;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 
 public class SetAutomaticDeletionProtectionActionTest {
 
@@ -125,7 +125,7 @@ public class SetAutomaticDeletionProtectionActionTest {
 
     assertThatThrownBy(() -> tester.newRequest()
       .setParam("project", project.getKey())
-      .setParam("branch", DEFAULT_PROJECT_MAIN_BRANCH_NAME)
+      .setParam("branch", DEFAULT_MAIN_BRANCH_NAME)
       .setParam("value", "false")
       .execute())
       .isInstanceOf(IllegalArgumentException.class)
@@ -147,7 +147,7 @@ public class SetAutomaticDeletionProtectionActionTest {
 
     assertThat(db.countRowsOfTable("project_branches")).isEqualTo(2);
     Optional<BranchDto> mainBranch = db.getDbClient().branchDao().selectByUuid(db.getSession(), project.uuid());
-    assertThat(mainBranch.get().getKey()).isEqualTo(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    assertThat(mainBranch.get().getKey()).isEqualTo(DEFAULT_MAIN_BRANCH_NAME);
     assertThat(mainBranch.get().isExcludeFromPurge()).isTrue();
 
     Optional<BranchDto> branchDto = db.getDbClient().branchDao().selectByUuid(db.getSession(), branch.uuid());
index 5e39f299427432d3e457f6147785d6bc575050dd..a78b3a4ba8a5c92e1f960a6eae6351af359c941b 100644 (file)
@@ -67,7 +67,7 @@ import static org.mockito.Mockito.verifyNoInteractions;
 import static org.mockito.Mockito.when;
 import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION;
 import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.component.ComponentTesting.newModuleDto;
 import static org.sonar.db.permission.GlobalPermission.PROVISION_PROJECTS;
 import static org.sonar.db.permission.GlobalPermission.SCAN;
@@ -101,7 +101,7 @@ public class ReportSubmitterTest {
   @Before
   public void before() {
     when(projectDefaultVisibility.get(any())).thenReturn(Visibility.PUBLIC);
-    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_MAIN_BRANCH_NAME);
   }
 
   @Test
index 4809facd82352b8d1b885e5c5607943984789285..113910c3eb8b0e5b4a17a5edcfb7d368cd4ca1a7 100644 (file)
@@ -30,7 +30,7 @@ import org.sonar.server.exceptions.NotFoundException;
 import static java.lang.String.format;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.component.BranchType.PULL_REQUEST;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
@@ -218,7 +218,7 @@ public class ComponentFinderTest {
   public void get_by_key_and_branch_accept_main_branch() {
     ComponentDto project = db.components().insertPublicProject();
 
-    assertThat(underTest.getByKeyAndBranch(dbSession, project.getKey(), DEFAULT_PROJECT_MAIN_BRANCH_NAME).uuid()).isEqualTo(project.uuid());
+    assertThat(underTest.getByKeyAndBranch(dbSession, project.getKey(), DEFAULT_MAIN_BRANCH_NAME).uuid()).isEqualTo(project.uuid());
   }
 
   @Test
index fc0bb839c5329ba8887fa238f2cc29d7d469a54a..c829aee5bf6417a6a3647dba6a35c7e8fc9eb985 100644 (file)
@@ -52,8 +52,7 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.sonar.api.resources.Qualifiers.APP;
 import static org.sonar.api.resources.Qualifiers.VIEW;
-import static org.sonar.db.component.BranchDto.DEFAULT_APPLICATION_MAIN_BRANCH_NAME;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 
 public class ComponentUpdaterTest {
 
@@ -78,7 +77,7 @@ public class ComponentUpdaterTest {
 
   @Before
   public void before() {
-    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_MAIN_BRANCH_NAME);
   }
 
   @Test
@@ -108,7 +107,7 @@ public class ComponentUpdaterTest {
 
     Optional<BranchDto> branch = db.getDbClient().branchDao().selectByUuid(db.getSession(), returned.uuid());
     assertThat(branch).isPresent();
-    assertThat(branch.get().getKey()).isEqualTo(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    assertThat(branch.get().getKey()).isEqualTo(DEFAULT_MAIN_BRANCH_NAME);
     assertThat(branch.get().getMergeBranchUuid()).isNull();
     assertThat(branch.get().getBranchType()).isEqualTo(BranchType.BRANCH);
     assertThat(branch.get().getUuid()).isEqualTo(returned.uuid());
@@ -205,7 +204,7 @@ public class ComponentUpdaterTest {
     assertThat(projectIndexers.hasBeenCalled(loaded.uuid(), ProjectIndexer.Cause.PROJECT_CREATION)).isTrue();
     Optional<BranchDto> branch = db.getDbClient().branchDao().selectByUuid(db.getSession(), returned.uuid());
     assertThat(branch).isPresent();
-    assertThat(branch.get().getKey()).isEqualTo(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    assertThat(branch.get().getKey()).isEqualTo(DEFAULT_MAIN_BRANCH_NAME);
     assertThat(branch.get().getMergeBranchUuid()).isNull();
     assertThat(branch.get().getBranchType()).isEqualTo(BranchType.BRANCH);
     assertThat(branch.get().getUuid()).isEqualTo(returned.uuid());
@@ -345,6 +344,6 @@ public class ComponentUpdaterTest {
 
     Optional<BranchDto> branch = db.getDbClient().branchDao().selectByUuid(db.getSession(), app.branchUuid());
     assertThat(branch).isPresent();
-    assertThat(branch.get().getBranchKey()).isEqualTo(DEFAULT_APPLICATION_MAIN_BRANCH_NAME);
+    assertThat(branch.get().getBranchKey()).isEqualTo(DEFAULT_MAIN_BRANCH_NAME);
   }
 }
index edea80d3e3dd6b46f6888b34f206ef1bd1320be0..9b9cb44f5d127b1b39ef428890518e303b843055 100644 (file)
@@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.tuple;
 import static org.sonar.api.utils.DateUtils.formatDateTime;
 import static org.sonar.api.utils.DateUtils.parseDateTime;
 import static org.sonar.api.web.UserRole.USER;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_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.newDirectory;
@@ -292,7 +292,7 @@ public class ShowActionTest {
 
     ShowWsResponse response = ws.newRequest()
       .setParam(PARAM_COMPONENT, project.getKey())
-      .setParam(PARAM_BRANCH, DEFAULT_PROJECT_MAIN_BRANCH_NAME)
+      .setParam(PARAM_BRANCH, DEFAULT_MAIN_BRANCH_NAME)
       .executeProtobuf(ShowWsResponse.class);
 
     assertThat(response.getComponent())
index 6152d29a743ff0e33da5c023891d1441f62fa27f..971976de9e213628ebba0d8dcc56a69d267e0c00 100644 (file)
@@ -61,7 +61,7 @@ import static org.sonar.api.resources.Qualifiers.APP;
 import static org.sonar.api.resources.Qualifiers.FILE;
 import static org.sonar.api.resources.Qualifiers.PROJECT;
 import static org.sonar.api.resources.Qualifiers.UNIT_TEST_FILE;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.component.BranchType.PULL_REQUEST;
 import static org.sonar.db.component.ComponentTesting.newChildComponent;
 import static org.sonar.db.component.ComponentTesting.newDirectory;
@@ -385,7 +385,7 @@ public class TreeActionTest {
 
     TreeWsResponse response = ws.newRequest()
       .setParam(PARAM_COMPONENT, file.getKey())
-      .setParam(PARAM_BRANCH, DEFAULT_PROJECT_MAIN_BRANCH_NAME)
+      .setParam(PARAM_BRANCH, DEFAULT_MAIN_BRANCH_NAME)
       .executeProtobuf(TreeWsResponse.class);
 
     assertThat(response.getBaseComponent()).extracting(Component::getKey, Component::getBranch)
index b735139beb4ba6b95355c4ebb5d9ccaf6dd0b665..12889ff64bf417748e6dc84710cb084575b3a4fc 100644 (file)
@@ -57,7 +57,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.api.web.UserRole.USER;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
 
 public class PullActionTest {
@@ -65,7 +65,7 @@ public class PullActionTest {
   private static final long NOW = 10_000_000_000L;
   private static final long PAST = 1_000_000_000L;
 
-  private static final String DEFAULT_BRANCH = DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+  private static final String DEFAULT_BRANCH = DEFAULT_MAIN_BRANCH_NAME;
 
   @Rule
   public DbTester dbTester = DbTester.create();
index 7ec6fa652c7037e698213ed1cfe7517498312c7e..a72ac285e5bc724e63d6a050545a605c2938b353 100644 (file)
@@ -61,7 +61,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.api.web.UserRole.USER;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
 import static org.sonar.db.protobuf.DbIssues.MessageFormattingType.CODE;
 
@@ -69,7 +69,7 @@ public class PullTaintActionTest {
   private static final long NOW = 10_000_000_000L;
   private static final long PAST = 1_000_000_000L;
 
-  private static final String DEFAULT_BRANCH = DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+  private static final String DEFAULT_BRANCH = DEFAULT_MAIN_BRANCH_NAME;
   public static final DbIssues.MessageFormatting MESSAGE_FORMATTING = DbIssues.MessageFormatting.newBuilder().setStart(0).setEnd(4).setType(CODE).build();
 
   @Rule
index f22493335fd2320d64cb3498bf36136a6220dfc2..e7ea893083e0459c85eefe90bb3acac92fac4e6f 100644 (file)
@@ -66,7 +66,7 @@ import static org.sonar.api.utils.DateUtils.parseDateTime;
 import static org.sonar.api.web.UserRole.USER;
 import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
 import static org.sonar.core.util.Uuids.UUID_EXAMPLE_02;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_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.newDirectory;
@@ -669,7 +669,7 @@ public class SearchActionComponentsTest {
 
     SearchWsResponse result = ws.newRequest()
       .setParam(PARAM_COMPONENT_KEYS, project.getKey())
-      .setParam(PARAM_BRANCH, DEFAULT_PROJECT_MAIN_BRANCH_NAME)
+      .setParam(PARAM_BRANCH, DEFAULT_MAIN_BRANCH_NAME)
       .executeProtobuf(SearchWsResponse.class);
 
     assertThat(result.getIssuesList())
index 79f75484be32c0e1025e222b60ec170dfd3feed2..3db4a7538c1aff4b58f6dca7a1400d4ce15816de 100644 (file)
@@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.assertj.core.api.Assertions.tuple;
 import static org.sonar.api.utils.DateUtils.parseDateTime;
 import static org.sonar.api.web.UserRole.USER;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.component.BranchType.PULL_REQUEST;
 import static org.sonar.db.component.ComponentTesting.newFileDto;
 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
@@ -148,7 +148,7 @@ public class ComponentActionTest {
 
     ComponentWsResponse response = ws.newRequest()
       .setParam(PARAM_COMPONENT, file.getKey())
-      .setParam(PARAM_BRANCH, DEFAULT_PROJECT_MAIN_BRANCH_NAME)
+      .setParam(PARAM_BRANCH, DEFAULT_MAIN_BRANCH_NAME)
       .setParam(PARAM_METRIC_KEYS, "complexity")
       .executeProtobuf(ComponentWsResponse.class);
 
index 2ee59711b6c273592bc3e7429457d0032afaf00a..92ea44908bf3a5d62d9386e0f180fdd7c8bd4260 100644 (file)
@@ -561,7 +561,7 @@ public class ComponentTreeActionTest {
 
     ComponentTreeWsResponse response = ws.newRequest()
       .setParam(PARAM_COMPONENT, file.getKey())
-      .setParam(PARAM_BRANCH, BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME)
+      .setParam(PARAM_BRANCH, BranchDto.DEFAULT_MAIN_BRANCH_NAME)
       .setParam(PARAM_METRIC_KEYS, complexity.getKey())
       .executeProtobuf(ComponentTreeWsResponse.class);
 
index fab0c1bd5a69302eede62b51add45792fe1df2ba..13c40f9b9a91723759dc479025ef2b3762a5da93 100644 (file)
@@ -50,7 +50,7 @@ import org.sonarqube.ws.NewCodePeriods.ShowWSResponse;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.component.SnapshotTesting.newAnalysis;
 
 public class ListActionTest {
@@ -116,7 +116,7 @@ public class ListActionTest {
     assertThat(response).isNotNull();
     assertThat(response.getNewCodePeriodsCount()).isEqualTo(6);
     assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
-      .contains(DEFAULT_PROJECT_MAIN_BRANCH_NAME, "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
+      .contains(DEFAULT_MAIN_BRANCH_NAME, "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
 
     //check if global default is set
     assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
@@ -139,7 +139,7 @@ public class ListActionTest {
     assertThat(response).isNotNull();
     assertThat(response.getNewCodePeriodsCount()).isEqualTo(6);
     assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
-      .contains(DEFAULT_PROJECT_MAIN_BRANCH_NAME, "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
+      .contains(DEFAULT_MAIN_BRANCH_NAME, "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
 
     //check if global default is set
     assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
@@ -174,7 +174,7 @@ public class ListActionTest {
     assertThat(response).isNotNull();
     assertThat(response.getNewCodePeriodsCount()).isEqualTo(6);
     assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
-      .contains(DEFAULT_PROJECT_MAIN_BRANCH_NAME, "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
+      .contains(DEFAULT_MAIN_BRANCH_NAME, "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
 
     //check if project setting is set
     assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
@@ -192,7 +192,7 @@ public class ListActionTest {
     assertThat(response).isNotNull();
     assertThat(response.getNewCodePeriodsCount()).isOne();
     assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
-      .containsOnly(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+      .containsOnly(DEFAULT_MAIN_BRANCH_NAME);
 
     //check if global setting is set
     assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
@@ -228,7 +228,7 @@ public class ListActionTest {
     assertThat(response).isNotNull();
     assertThat(response.getNewCodePeriodsCount()).isEqualTo(3);
     assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
-      .contains(DEFAULT_PROJECT_MAIN_BRANCH_NAME, "OWN_SETTINGS", "GLOBAL_SETTINGS");
+      .contains(DEFAULT_MAIN_BRANCH_NAME, "OWN_SETTINGS", "GLOBAL_SETTINGS");
 
     Optional<ShowWSResponse> ownSettings = response.getNewCodePeriodsList().stream()
       .filter(s -> !s.getInherited())
@@ -283,7 +283,7 @@ public class ListActionTest {
     assertThat(response).isNotNull();
     assertThat(response.getNewCodePeriodsCount()).isEqualTo(3);
     assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
-      .contains(DEFAULT_PROJECT_MAIN_BRANCH_NAME, "OWN_SETTINGS", "PROJECT_SETTINGS");
+      .contains(DEFAULT_MAIN_BRANCH_NAME, "OWN_SETTINGS", "PROJECT_SETTINGS");
 
     Optional<ShowWSResponse> ownSettings = response.getNewCodePeriodsList().stream()
       .filter(s -> !s.getInherited())
@@ -344,7 +344,7 @@ public class ListActionTest {
     assertThat(response).isNotNull();
     assertThat(response.getNewCodePeriodsCount()).isEqualTo(2);
     assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
-      .containsOnly(DEFAULT_PROJECT_MAIN_BRANCH_NAME, "PROJECT_BRANCH");
+      .containsOnly(DEFAULT_MAIN_BRANCH_NAME, "PROJECT_BRANCH");
 
     ShowWSResponse result = response.getNewCodePeriodsList().get(0);
     assertThat(result.getType()).isEqualTo(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
index e0335b2a030472ece1de9c97a5167800318380f6..a2fca7e793249c78f25c57a4f721ddb64780bd7b 100644 (file)
@@ -54,7 +54,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.assertj.core.api.Assertions.entry;
 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.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 
 @RunWith(DataProviderRunner.class)
 public class SetActionTest {
@@ -131,7 +131,7 @@ public class SetActionTest {
 
     assertThatThrownBy(() -> ws.newRequest()
       .setParam("project", project.getKey())
-      .setParam("branch", DEFAULT_PROJECT_MAIN_BRANCH_NAME)
+      .setParam("branch", DEFAULT_MAIN_BRANCH_NAME)
       .setParam("type", "number_of_days")
       .execute())
       .isInstanceOf(IllegalArgumentException.class)
@@ -146,7 +146,7 @@ public class SetActionTest {
     assertThatThrownBy(() -> ws.newRequest()
       .setParam("project", project.getKey())
       .setParam("type", "specific_analysis")
-      .setParam("branch", DEFAULT_PROJECT_MAIN_BRANCH_NAME)
+      .setParam("branch", DEFAULT_MAIN_BRANCH_NAME)
       .execute())
       .isInstanceOf(IllegalArgumentException.class)
       .hasMessageContaining("New Code Period type 'SPECIFIC_ANALYSIS' requires a value");
@@ -160,7 +160,7 @@ public class SetActionTest {
     assertThatThrownBy(() -> ws.newRequest()
       .setParam("project", project.getKey())
       .setParam("type", "number_of_days")
-      .setParam("branch", DEFAULT_PROJECT_MAIN_BRANCH_NAME)
+      .setParam("branch", DEFAULT_MAIN_BRANCH_NAME)
       .setParam("value", "unknown")
       .execute())
       .isInstanceOf(IllegalArgumentException.class)
@@ -175,7 +175,7 @@ public class SetActionTest {
     assertThatThrownBy(() -> ws.newRequest()
       .setParam("project", project.getKey())
       .setParam("type", "specific_analysis")
-      .setParam("branch", DEFAULT_PROJECT_MAIN_BRANCH_NAME)
+      .setParam("branch", DEFAULT_MAIN_BRANCH_NAME)
       .setParam("value", "unknown")
       .execute())
       .isInstanceOf(NotFoundException.class)
@@ -195,11 +195,11 @@ public class SetActionTest {
     assertThatThrownBy(() -> ws.newRequest()
       .setParam("project", project.getKey())
       .setParam("type", "specific_analysis")
-      .setParam("branch", DEFAULT_PROJECT_MAIN_BRANCH_NAME)
+      .setParam("branch", DEFAULT_MAIN_BRANCH_NAME)
       .setParam("value", analysisBranch.getUuid())
       .execute())
       .isInstanceOf(IllegalArgumentException.class)
-      .hasMessageContaining("Analysis '" + analysisBranch.getUuid() + "' does not belong to branch '" + DEFAULT_PROJECT_MAIN_BRANCH_NAME +
+      .hasMessageContaining("Analysis '" + analysisBranch.getUuid() + "' does not belong to branch '" + DEFAULT_MAIN_BRANCH_NAME +
         "' of project '" + project.getKey() + "'");
   }
 
index 632d55617a8d7d1545cafe48272b36d7fd10eca9..5999d6849ac83ff23c2d4224d04e970dc8fbed23 100644 (file)
@@ -57,7 +57,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.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.permission.GlobalPermission.PROVISION_PROJECTS;
 import static org.sonar.server.project.Visibility.PRIVATE;
 import static org.sonar.test.JsonAssert.assertJson;
@@ -96,7 +96,7 @@ public class CreateActionTest {
   @Before
   public void before() {
     when(projectDefaultVisibility.get(any())).thenReturn(Visibility.PUBLIC);
-    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+    when(defaultBranchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_MAIN_BRANCH_NAME);
   }
 
   @Test
index 664235f34e9274a18dfbb602b33755af77224887..6a7c1701603058e46c8e5079f732163667565dd1 100644 (file)
@@ -52,7 +52,7 @@ import org.sonar.server.ws.WsActionTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
 import static org.sonar.db.newcodeperiod.NewCodePeriodType.SPECIFIC_ANALYSIS;
 import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_ANALYSIS;
 import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_BRANCH;
@@ -117,7 +117,7 @@ public class SetBaselineActionTest {
     ComponentDto project = tester.insertPrivateProject();
     SnapshotDto analysis = db.components().insertSnapshot(project);
 
-    assertThatThrownBy(() -> call(project.getKey(), DEFAULT_PROJECT_MAIN_BRANCH_NAME, analysis.getUuid()))
+    assertThatThrownBy(() -> call(project.getKey(), DEFAULT_MAIN_BRANCH_NAME, analysis.getUuid()))
       .isInstanceOf(ForbiddenException.class)
       .hasMessage("Insufficient privileges");
   }