diff options
author | Lukasz Jarocki <lukasz.jarocki@sonarsource.com> | 2022-12-15 15:20:40 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-12-15 20:03:33 +0000 |
commit | f0582195b40b656b525d7d0df55120f899b21693 (patch) | |
tree | 17732b64859daa336fe7924e9fa1e759512afec2 /server/sonar-webserver-webapi | |
parent | fc7657598b9f46a99cb21dc891f75ad20c8a8528 (diff) | |
download | sonarqube-f0582195b40b656b525d7d0df55120f899b21693.tar.gz sonarqube-f0582195b40b656b525d7d0df55120f899b21693.zip |
SONAR-17613 changing default branch for applications to follow the setting
Diffstat (limited to 'server/sonar-webserver-webapi')
21 files changed, 60 insertions, 61 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentUpdater.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentUpdater.java index baeb217f15a..c405f0cbb94 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentUpdater.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentUpdater.java @@ -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; } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/azure/ImportAzureProjectActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/azure/ImportAzureProjectActionTest.java index bf7ffd17cfd..c66a1a700e7 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/azure/ImportAzureProjectActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/azure/ImportAzureProjectActionTest.java @@ -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 diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/bitbucketserver/ImportBitbucketServerProjectActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/bitbucketserver/ImportBitbucketServerProjectActionTest.java index 634a9c098f1..4cd9c618ea9 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/bitbucketserver/ImportBitbucketServerProjectActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/bitbucketserver/ImportBitbucketServerProjectActionTest.java @@ -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 diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionTest.java index d4268f54c2c..92173fb9cf0 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/github/ImportGithubProjectActionTest.java @@ -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 diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/gitlab/ImportGitLabProjectActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/gitlab/ImportGitLabProjectActionTest.java index dff38677e51..d12efd1328f 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/gitlab/ImportGitLabProjectActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/almintegration/ws/gitlab/ImportGitLabProjectActionTest.java @@ -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)); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/ws/ListActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/ws/ListActionTest.java index dbf16947590..82e915362ec 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/ws/ListActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/ws/ListActionTest.java @@ -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)); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/ws/SetAutomaticDeletionProtectionActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/ws/SetAutomaticDeletionProtectionActionTest.java index 16174e39934..16c96f1378e 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/ws/SetAutomaticDeletionProtectionActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/ws/SetAutomaticDeletionProtectionActionTest.java @@ -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()); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/ReportSubmitterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/ReportSubmitterTest.java index 5e39f299427..a78b3a4ba8a 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/ReportSubmitterTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/ReportSubmitterTest.java @@ -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 diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentFinderTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentFinderTest.java index 4809facd823..113910c3eb8 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentFinderTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentFinderTest.java @@ -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 diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentUpdaterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentUpdaterTest.java index fc0bb839c53..c829aee5bf6 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentUpdaterTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentUpdaterTest.java @@ -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); } } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/ShowActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/ShowActionTest.java index edea80d3e3d..9b9cb44f5d1 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/ShowActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/ShowActionTest.java @@ -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()) diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/TreeActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/TreeActionTest.java index 6152d29a743..971976de9e2 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/TreeActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/TreeActionTest.java @@ -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) diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullActionTest.java index b735139beb4..12889ff64bf 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullActionTest.java @@ -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(); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullTaintActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullTaintActionTest.java index 7ec6fa652c7..a72ac285e5b 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullTaintActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/PullTaintActionTest.java @@ -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 diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java index f22493335fd..e7ea893083e 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java @@ -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()) diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java index 79f75484be3..3db4a7538c1 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java @@ -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); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java index 2ee59711b6c..92ea44908bf 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java @@ -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); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/ListActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/ListActionTest.java index fab0c1bd5a6..13c40f9b9a9 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/ListActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/ListActionTest.java @@ -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); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/SetActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/SetActionTest.java index e0335b2a030..a2fca7e7932 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/SetActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/SetActionTest.java @@ -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() + "'"); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/CreateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/CreateActionTest.java index 632d55617a8..5999d6849ac 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/CreateActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/CreateActionTest.java @@ -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 diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SetBaselineActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SetBaselineActionTest.java index 664235f34e9..6a7c1701603 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SetBaselineActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SetBaselineActionTest.java @@ -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"); } |