aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolder.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImpl.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImpl.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueTrackingDelegator.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java26
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImplTest.java32
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImplTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/MergeAndTargetBranchComponentUuidsTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/SiblingComponentsWithOpenIssuesTest.java16
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java6
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueTrackingDelegatorTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/NewEffortAggregatorTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactoryTest.java16
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java8
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java26
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderRule.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/MutableAnalysisMetadataHolderRule.java4
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchType.java5
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java8
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDao.java2
-rw-r--r--server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java44
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDtoTest.java8
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java12
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrollForFileMoveComponentDaoTest.java3
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java10
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java8
-rw-r--r--server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java2
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest.java2
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/webhook/BranchTest.java8
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/webhook/ProjectAnalysisTest.java4
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java10
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java4
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java12
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/badge/ws/ProjectBadgesSupport.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/branch/ws/ListAction.java8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ComponentUpdater.java2
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ListAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/UnsetAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/resources/org/sonar/server/branch/ws/list-example.json4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java16
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java14
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/pr/ws/ListActionTest.java14
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/ws/ListActionTest.java33
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/BranchReportSubmitterTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ComponentUpdaterTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsTest.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/live/LiveQualityGateComputerImplTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/ListActionTest.java14
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/DeleteActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SetBaselineActionTest.java16
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/UnsetBaselineActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java2
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTesterTest.java10
67 files changed, 268 insertions, 247 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolder.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolder.java
index 086071988bc..c94f3b760ba 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolder.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolder.java
@@ -75,7 +75,7 @@ public interface AnalysisMetadataHolder {
*
* @throws IllegalStateException if branch has not been set
*/
- boolean isLongLivingBranch();
+ boolean isBranch();
/**
* Convenience method equivalent to do the check using {@link #getBranch()}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImpl.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImpl.java
index 23e427ba198..6c8139fe06c 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImpl.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImpl.java
@@ -247,10 +247,10 @@ public class AnalysisMetadataHolderImpl implements MutableAnalysisMetadataHolder
}
@Override
- public boolean isLongLivingBranch() {
+ public boolean isBranch() {
checkState(this.branch.isInitialized(), BRANCH_NOT_SET);
Branch prop = branch.getProperty();
- return prop != null && prop.getType() == BranchType.LONG;
+ return prop != null && prop.getType() == BranchType.BRANCH;
}
@Override
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImpl.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImpl.java
index 938740db97b..1829e0e6133 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImpl.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImpl.java
@@ -41,7 +41,7 @@ public class DefaultBranchImpl implements Branch {
@Override
public BranchType getType() {
- return BranchType.LONG;
+ return BranchType.BRANCH;
}
@Override
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueTrackingDelegator.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueTrackingDelegator.java
index 8d0c0ca910c..a5aaa2fecae 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueTrackingDelegator.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IssueTrackingDelegator.java
@@ -64,7 +64,7 @@ public class IssueTrackingDelegator {
private boolean isFirstAnalysisSecondaryBranch() {
if (analysisMetadataHolder.isFirstAnalysis()) {
Branch branch = analysisMetadataHolder.getBranch();
- return !branch.isMain() && branch.getType() == BranchType.LONG;
+ return !branch.isMain();
}
return false;
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java
index 13e7537e265..f5e98063e4f 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStep.java
@@ -69,7 +69,7 @@ public class LoadPeriodsStep implements ComputationStep {
@Override
public void execute(ComputationStep.Context context) {
- if (analysisMetadataHolder.isFirstAnalysis() || !analysisMetadataHolder.isLongLivingBranch()) {
+ if (analysisMetadataHolder.isFirstAnalysis() || !analysisMetadataHolder.isBranch()) {
periodsHolder.setPeriod(null);
return;
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java
index b521410775a..d444d5b468a 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java
@@ -445,4 +445,30 @@ public class AnalysisMetadataHolderImplTest {
underTest.setScmRevision(" ");
assertThat(underTest.getScmRevision()).isEmpty();
}
+
+ @Test
+ public void isBranch_returns_true_for_initialized_branch() {
+ Branch branch = mock(Branch.class);
+ when(branch.getType()).thenReturn(BranchType.BRANCH);
+ underTest.setBranch(branch);
+
+ assertThat(underTest.isBranch()).isTrue();
+ }
+
+ @Test
+ public void isBranch_returns_false_for_pr() {
+ Branch branch = mock(Branch.class);
+ when(branch.getType()).thenReturn(BranchType.PULL_REQUEST);
+ underTest.setBranch(branch);
+
+ assertThat(underTest.isBranch()).isFalse();
+ }
+
+ @Test
+ public void isBranch_throws_ISE_for_not_initialized_branch() {
+ expectedException.expect(IllegalStateException.class);
+ expectedException.expectMessage("Branch has not been set");
+
+ underTest.isBranch();
+ }
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java
index c0cdb3289c2..c50d632457f 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java
@@ -115,7 +115,7 @@ public class PostProjectAnalysisTasksExecutorTest {
CONDITION_1, ConditionStatus.create(ConditionStatus.EvaluationStatus.OK, "value"),
CONDITION_2, ConditionStatus.NO_VALUE_STATUS));
Branch branch = mock(Branch.class);
- when(branch.getType()).thenReturn(BranchType.LONG);
+ when(branch.getType()).thenReturn(BranchType.BRANCH);
analysisMetadataHolder
.setBranch(branch)
.setOrganizationsEnabled(new Random().nextBoolean())
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImplTest.java
index a57200de042..48691fc20ab 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchPersisterImplTest.java
@@ -45,13 +45,13 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
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.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.db.component.BranchType.PULL_REQUEST;
@RunWith(DataProviderRunner.class)
public class BranchPersisterImplTest {
private final static Component MAIN = builder(PROJECT, 1).setUuid("PROJECT_UUID").setKey("PROJECT_KEY").build();
- private final static Component BRANCH = builder(PROJECT, 1).setUuid("BRANCH_UUID").setKey("BRANCH_KEY").build();
+ private final static Component BRANCH1 = builder(PROJECT, 1).setUuid("BRANCH_UUID").setKey("BRANCH_KEY").build();
@Rule
public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule();
@@ -66,7 +66,7 @@ public class BranchPersisterImplTest {
@Test
public void persist_fails_with_ISE_if_no_component_for_main_branches() {
- analysisMetadataHolder.setBranch(createBranch(LONG, true, "master"));
+ analysisMetadataHolder.setBranch(createBranch(BRANCH, true, "master"));
treeRootHolder.setRoot(MAIN);
expectMissingComponentISE();
@@ -75,9 +75,9 @@ public class BranchPersisterImplTest {
}
@Test
- public void persist_fails_with_ISE_if_no_component_for_long_branches() {
- analysisMetadataHolder.setBranch(createBranch(LONG, false, "foo"));
- treeRootHolder.setRoot(BRANCH);
+ public void persist_fails_with_ISE_if_no_component_for_branches() {
+ analysisMetadataHolder.setBranch(createBranch(BRANCH, false, "foo"));
+ treeRootHolder.setRoot(BRANCH1);
expectMissingComponentISE();
@@ -87,7 +87,7 @@ public class BranchPersisterImplTest {
@Test
public void persist_fails_with_ISE_if_no_component_for_pull_request() {
analysisMetadataHolder.setBranch(createBranch(BranchType.PULL_REQUEST, false, "12"));
- treeRootHolder.setRoot(BRANCH);
+ treeRootHolder.setRoot(BRANCH1);
expectMissingComponentISE();
@@ -96,17 +96,17 @@ public class BranchPersisterImplTest {
@Test
@UseDataProvider("nullOrNotNullString")
- public void persist_creates_row_in_PROJECTS_BRANCHES_for_long_branch(@Nullable String mergeBranchUuid) {
+ public void persist_creates_row_in_PROJECTS_BRANCHES_for_branch(@Nullable String mergeBranchUuid) {
String branchName = "branch";
// add project and branch in table PROJECTS
ComponentDto mainComponent = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), MAIN.getUuid()).setDbKey(MAIN.getKey());
- ComponentDto component = ComponentTesting.newProjectBranch(mainComponent, new BranchDto().setUuid(BRANCH.getUuid()).setKey(BRANCH.getKey()).setBranchType(LONG));
+ ComponentDto component = ComponentTesting.newProjectBranch(mainComponent, new BranchDto().setUuid(BRANCH1.getUuid()).setKey(BRANCH1.getKey()).setBranchType(BRANCH));
dbTester.getDbClient().componentDao().insert(dbTester.getSession(), mainComponent, component);
dbTester.commit();
// set project in metadata
- treeRootHolder.setRoot(BRANCH);
- analysisMetadataHolder.setBranch(createBranch(LONG, false, branchName, mergeBranchUuid));
+ treeRootHolder.setRoot(BRANCH1);
+ analysisMetadataHolder.setBranch(createBranch(BRANCH, false, branchName, mergeBranchUuid));
analysisMetadataHolder.setProject(Project.from(mainComponent));
underTest.persist(dbTester.getSession());
@@ -114,9 +114,9 @@ public class BranchPersisterImplTest {
dbTester.getSession().commit();
assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(2);
- Optional<BranchDto> branchDto = dbTester.getDbClient().branchDao().selectByUuid(dbTester.getSession(), BRANCH.getUuid());
+ Optional<BranchDto> branchDto = dbTester.getDbClient().branchDao().selectByUuid(dbTester.getSession(), BRANCH1.getUuid());
assertThat(branchDto).isPresent();
- assertThat(branchDto.get().getBranchType()).isEqualTo(LONG);
+ assertThat(branchDto.get().getBranchType()).isEqualTo(BRANCH);
assertThat(branchDto.get().getKey()).isEqualTo(branchName);
assertThat(branchDto.get().getMergeBranchUuid()).isEqualTo(mergeBranchUuid);
assertThat(branchDto.get().getProjectUuid()).isEqualTo(MAIN.getUuid());
@@ -137,11 +137,11 @@ public class BranchPersisterImplTest {
// add project and branch in table PROJECTS
ComponentDto mainComponent = ComponentTesting.newPrivateProjectDto(dbTester.organizations().insert(), MAIN.getUuid()).setDbKey(MAIN.getKey());
- ComponentDto component = ComponentTesting.newProjectBranch(mainComponent, new BranchDto().setUuid(BRANCH.getUuid()).setKey(BRANCH.getKey()).setBranchType(PULL_REQUEST));
+ ComponentDto component = ComponentTesting.newProjectBranch(mainComponent, new BranchDto().setUuid(BRANCH1.getUuid()).setKey(BRANCH1.getKey()).setBranchType(PULL_REQUEST));
dbTester.getDbClient().componentDao().insert(dbTester.getSession(), mainComponent, component);
dbTester.commit();
// set project in metadata
- treeRootHolder.setRoot(BRANCH);
+ treeRootHolder.setRoot(BRANCH1);
analysisMetadataHolder.setBranch(createBranch(PULL_REQUEST, false, pullRequestId, "mergeBanchUuid"));
analysisMetadataHolder.setProject(Project.from(mainComponent));
analysisMetadataHolder.setPullRequestKey(pullRequestId);
@@ -151,7 +151,7 @@ public class BranchPersisterImplTest {
dbTester.getSession().commit();
assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(2);
- Optional<BranchDto> branchDto = dbTester.getDbClient().branchDao().selectByUuid(dbTester.getSession(), BRANCH.getUuid());
+ Optional<BranchDto> branchDto = dbTester.getDbClient().branchDao().selectByUuid(dbTester.getSession(), BRANCH1.getUuid());
assertThat(branchDto).isPresent();
assertThat(branchDto.get().getBranchType()).isEqualTo(PULL_REQUEST);
assertThat(branchDto.get().getKey()).isEqualTo(pullRequestId);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImplTest.java
index e4e03069ad6..9d857162444 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImplTest.java
@@ -41,7 +41,7 @@ public class DefaultBranchImplTest {
DefaultBranchImpl branch = new DefaultBranchImpl();
assertThat(branch.isMain()).isTrue();
- assertThat(branch.getType()).isEqualTo(BranchType.LONG);
+ assertThat(branch.getType()).isEqualTo(BranchType.BRANCH);
assertThat(branch.getName()).isEqualTo(BranchDto.DEFAULT_MAIN_BRANCH_NAME);
assertThat(branch.supportsCrossProjectCpd()).isTrue();
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/MergeAndTargetBranchComponentUuidsTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/MergeAndTargetBranchComponentUuidsTest.java
index 6327da50216..ea992792b54 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/MergeAndTargetBranchComponentUuidsTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/MergeAndTargetBranchComponentUuidsTest.java
@@ -132,7 +132,7 @@ public class MergeAndTargetBranchComponentUuidsTest {
@Test
public void should_skip_target_components_init_on_branches() {
when(branch.getMergeBranchUuid()).thenReturn(branch1.uuid());
- when(branch.getType()).thenReturn(BranchType.LONG);
+ when(branch.getType()).thenReturn(BranchType.BRANCH);
when(branch.getTargetBranchName()).thenThrow(new IllegalStateException("Unsupported on branches"));
db.components().insertSnapshot(newAnalysis(branch1));
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/SiblingComponentsWithOpenIssuesTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/SiblingComponentsWithOpenIssuesTest.java
index fbc178d595f..ea3771ae782 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/SiblingComponentsWithOpenIssuesTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/SiblingComponentsWithOpenIssuesTest.java
@@ -66,7 +66,7 @@ public class SiblingComponentsWithOpenIssuesTest {
public void setUp() {
ComponentDto project = db.components().insertMainBranch();
- long1 = db.components().insertProjectBranch(project, b -> b.setKey("long1"), b -> b.setBranchType(BranchType.LONG));
+ long1 = db.components().insertProjectBranch(project, b -> b.setKey("long1"), b -> b.setBranchType(BranchType.BRANCH));
long1short1 = db.components().insertProjectBranch(project,
b -> b.setKey("long1short1"),
b -> b.setBranchType(BranchType.SHORT),
@@ -98,7 +98,7 @@ public class SiblingComponentsWithOpenIssuesTest {
.setDbKey(fileKey + ":BRANCH:long1short2"));
db.issues().insertIssue(IssueTesting.newIssue(rule, long1short2, fileXWithOneResolvedIssueOnLong1Short2).setStatus("RESOLVED"));
- long2 = db.components().insertProjectBranch(project, b -> b.setKey("long2"), b -> b.setBranchType(BranchType.LONG));
+ long2 = db.components().insertProjectBranch(project, b -> b.setKey("long2"), b -> b.setBranchType(BranchType.BRANCH));
ComponentDto long2short1 = db.components().insertProjectBranch(project,
b -> b.setKey("long2short1"),
b -> b.setBranchType(BranchType.SHORT),
@@ -117,7 +117,7 @@ public class SiblingComponentsWithOpenIssuesTest {
@Test
public void should_find_sibling_components_with_open_issues_for_long1() {
setRoot(long1);
- setBranch(BranchType.LONG);
+ setBranch(BranchType.BRANCH);
assertThat(underTest.getUuids(fileWithNoIssuesOnLong1.getKey())).isEmpty();
assertThat(underTest.getUuids(fileWithOneOpenIssueOnLong1Short1.getKey())).containsOnly(fileWithOneOpenIssueOnLong1Short1.uuid());
@@ -149,7 +149,7 @@ public class SiblingComponentsWithOpenIssuesTest {
@Test
public void should_find_sibling_components_with_open_issues_for_long2() {
setRoot(long2);
- setBranch(BranchType.LONG);
+ setBranch(BranchType.BRANCH);
underTest = new SiblingComponentsWithOpenIssues(treeRootHolder, metadataHolder, db.getDbClient());
@@ -162,7 +162,7 @@ public class SiblingComponentsWithOpenIssuesTest {
public void should_find_sibling_components_with_open_issues_from_short() {
ComponentDto project = db.components().insertMainBranch();
setRoot(project);
- setBranch(BranchType.LONG);
+ setBranch(BranchType.BRANCH);
ComponentDto branch = db.components().insertProjectBranch(project,
b -> b.setBranchType(BranchType.SHORT),
@@ -182,7 +182,7 @@ public class SiblingComponentsWithOpenIssuesTest {
public void should_find_sibling_components_with_open_issues_from_pullrequest() {
ComponentDto project = db.components().insertMainBranch();
setRoot(project);
- setBranch(BranchType.LONG);
+ setBranch(BranchType.BRANCH);
ComponentDto pullRequest = db.components().insertProjectBranch(project,
b -> b.setBranchType(BranchType.PULL_REQUEST),
@@ -202,10 +202,10 @@ public class SiblingComponentsWithOpenIssuesTest {
public void should_not_find_sibling_components_on_derived_long() {
ComponentDto project = db.components().insertMainBranch();
setRoot(project);
- setBranch(BranchType.LONG);
+ setBranch(BranchType.BRANCH);
ComponentDto derivedLongBranch = db.components().insertProjectBranch(project,
- b -> b.setBranchType(BranchType.LONG),
+ b -> b.setBranchType(BranchType.BRANCH),
b -> b.setMergeBranchUuid(project.uuid()));
RuleDefinitionDto rule = db.rules().insert();
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java
index b3b72b9c7c5..1764988f0ca 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitorTest.java
@@ -160,7 +160,7 @@ public class IntegrateIssuesVisitorTest {
@Test
public void process_new_issue() {
- when(analysisMetadataHolder.isLongLivingBranch()).thenReturn(true);
+ when(analysisMetadataHolder.isBranch()).thenReturn(true);
ScannerReport.Issue reportIssue = ScannerReport.Issue.newBuilder()
.setMsg("the message")
.setRuleRepository("xoo")
@@ -265,11 +265,11 @@ public class IntegrateIssuesVisitorTest {
when(mergeBranchComponentsUuids.getMergeBranchComponentUuid(FILE_KEY)).thenReturn(FILE_UUID_ON_BRANCH);
when(mergeAndTargetBranchComponentUuids.getMergeBranchName()).thenReturn("master");
- when(analysisMetadataHolder.isLongLivingBranch()).thenReturn(true);
+ when(analysisMetadataHolder.isBranch()).thenReturn(true);
when(analysisMetadataHolder.isFirstAnalysis()).thenReturn(true);
Branch branch = mock(Branch.class);
when(branch.isMain()).thenReturn(false);
- when(branch.getType()).thenReturn(BranchType.LONG);
+ when(branch.getType()).thenReturn(BranchType.BRANCH);
when(analysisMetadataHolder.getBranch()).thenReturn(branch);
RuleKey ruleKey = RuleTesting.XOO_X1;
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueTrackingDelegatorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueTrackingDelegatorTest.java
index 8bbc04981dc..afff9006c86 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueTrackingDelegatorTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/IssueTrackingDelegatorTest.java
@@ -74,7 +74,7 @@ public class IssueTrackingDelegatorTest {
@Test
public void delegate_merge_tracker() {
Branch branch = mock(Branch.class);
- when(branch.getType()).thenReturn(BranchType.LONG);
+ when(branch.getType()).thenReturn(BranchType.BRANCH);
when(branch.isMain()).thenReturn(false);
when(analysisMetadataHolder.getBranch()).thenReturn(branch);
when(analysisMetadataHolder.isFirstAnalysis()).thenReturn(true);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/NewEffortAggregatorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/NewEffortAggregatorTest.java
index aa80737f60b..11a933e45bd 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/NewEffortAggregatorTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/issue/NewEffortAggregatorTest.java
@@ -262,7 +262,7 @@ public class NewEffortAggregatorTest {
@Test
public void no_measures_if_no_periods() {
Branch branch = mock(Branch.class);
- when(branch.getType()).thenReturn(BranchType.LONG);
+ when(branch.getType()).thenReturn(BranchType.BRANCH);
analysisMetadataHolder.setBranch(branch);
periodsHolder.setPeriod(null);
DefaultIssue unresolved = newCodeSmellIssue(10);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactoryTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactoryTest.java
index 8be9a43e11a..990f8f37cb2 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactoryTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/NotificationFactoryTest.java
@@ -569,7 +569,7 @@ public class NotificationFactoryTest {
public static Object[][] noBranchNameBranches() {
Branch mainBranch = mock(Branch.class);
when(mainBranch.isMain()).thenReturn(true);
- when(mainBranch.getType()).thenReturn(BranchType.LONG);
+ when(mainBranch.getType()).thenReturn(BranchType.BRANCH);
Branch pr = mock(Branch.class);
when(pr.isMain()).thenReturn(false);
when(pr.getType()).thenReturn(BranchType.PULL_REQUEST);
@@ -580,7 +580,7 @@ public class NotificationFactoryTest {
}
@Test
- public void newIssuesChangesNotification_creates_project_from_TreeRootHolder_and_branch_name_from_long_branch() {
+ public void newIssuesChangesNotification_creates_project_from_TreeRootHolder_and_branch_name_from_branch() {
RuleKey ruleKey = RuleKey.of("foo", "bar");
DefaultIssue issue = new DefaultIssue()
.setRuleKey(ruleKey)
@@ -592,7 +592,7 @@ public class NotificationFactoryTest {
ruleRepository.add(ruleKey);
treeRootHolder.setRoot(project);
analysisMetadata.setAnalysisDate(new Random().nextLong());
- analysisMetadata.setBranch(newBranch(BranchType.LONG, branchName));
+ analysisMetadata.setBranch(newBranch(BranchType.BRANCH, branchName));
IssuesChangesNotification expected = mock(IssuesChangesNotification.class);
when(issuesChangesSerializer.serialize(any(IssuesChangesNotificationBuilder.class))).thenReturn(expected);
@@ -622,7 +622,7 @@ public class NotificationFactoryTest {
ruleRepository.add(ruleKey);
treeRootHolder.setRoot(project);
analysisMetadata.setAnalysisDate(new Random().nextLong());
- analysisMetadata.setBranch(newBranch(BranchType.LONG, branchName));
+ analysisMetadata.setBranch(newBranch(BranchType.BRANCH, branchName));
IssuesChangesNotification expected = mock(IssuesChangesNotification.class);
when(issuesChangesSerializer.serialize(any(IssuesChangesNotificationBuilder.class))).thenReturn(expected);
@@ -650,7 +650,7 @@ public class NotificationFactoryTest {
ruleRepository.add(ruleKey);
treeRootHolder.setRoot(project);
analysisMetadata.setAnalysisDate(new Random().nextLong());
- analysisMetadata.setBranch(newBranch(BranchType.LONG, randomAlphabetic(12)));
+ analysisMetadata.setBranch(newBranch(BranchType.BRANCH, randomAlphabetic(12)));
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Can not find DTO for assignee uuid " + assigneeUuid);
@@ -673,7 +673,7 @@ public class NotificationFactoryTest {
ruleRepository.add(ruleKey);
treeRootHolder.setRoot(project);
analysisMetadata.setAnalysisDate(new Random().nextLong());
- analysisMetadata.setBranch(newBranch(BranchType.LONG, randomAlphabetic(12)));
+ analysisMetadata.setBranch(newBranch(BranchType.BRANCH, randomAlphabetic(12)));
IssuesChangesNotification expected = mock(IssuesChangesNotification.class);
when(issuesChangesSerializer.serialize(any(IssuesChangesNotificationBuilder.class))).thenReturn(expected);
@@ -703,7 +703,7 @@ public class NotificationFactoryTest {
ruleRepository.add(ruleKey);
treeRootHolder.setRoot(project);
analysisMetadata.setAnalysisDate(analysisDate);
- analysisMetadata.setBranch(newBranch(BranchType.LONG, randomAlphabetic(12)));
+ analysisMetadata.setBranch(newBranch(BranchType.BRANCH, randomAlphabetic(12)));
IssuesChangesNotification expected = mock(IssuesChangesNotification.class);
when(issuesChangesSerializer.serialize(any(IssuesChangesNotificationBuilder.class))).thenReturn(expected);
@@ -733,7 +733,7 @@ public class NotificationFactoryTest {
.forEach(ruleKey -> ruleRepository.add(ruleKey));
treeRootHolder.setRoot(project);
analysisMetadata.setAnalysisDate(analysisDate);
- analysisMetadata.setBranch(newBranch(BranchType.LONG, randomAlphabetic(12)));
+ analysisMetadata.setBranch(newBranch(BranchType.BRANCH, randomAlphabetic(12)));
IssuesChangesNotification expected = mock(IssuesChangesNotification.class);
when(issuesChangesSerializer.serialize(any(IssuesChangesNotificationBuilder.class))).thenReturn(expected);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java
index 42a454aecc9..01966886f92 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/LoadPeriodsStepTest.java
@@ -105,7 +105,7 @@ public class LoadPeriodsStepTest extends BaseStepTest {
organization = dbTester.organizations().insert();
project = dbTester.components().insertMainBranch(organization);
- when(analysisMetadataHolder.isLongLivingBranch()).thenReturn(true);
+ when(analysisMetadataHolder.isBranch()).thenReturn(true);
when(analysisMetadataHolder.isFirstAnalysis()).thenReturn(false);
when(analysisMetadataHolder.getAnalysisDate()).thenReturn(analysisDate.toInstant().toEpochMilli());
}
@@ -122,11 +122,11 @@ public class LoadPeriodsStepTest extends BaseStepTest {
@Test
public void no_period_if_not_LLB() {
- when(analysisMetadataHolder.isLongLivingBranch()).thenReturn(false);
+ when(analysisMetadataHolder.isBranch()).thenReturn(false);
underTest.execute(new TestComputationStepContext());
verify(analysisMetadataHolder).isFirstAnalysis();
- verify(analysisMetadataHolder).isLongLivingBranch();
+ verify(analysisMetadataHolder).isBranch();
assertThat(periodsHolder.hasPeriod()).isFalse();
verifyNoMoreInteractions(analysisMetadataHolder);
}
@@ -356,7 +356,7 @@ public class LoadPeriodsStepTest extends BaseStepTest {
@Test
@UseDataProvider("anyValidLeakPeriodSettingValue")
public void leak_period_setting_is_ignored_for_PR(NewCodePeriodType type, @Nullable String value) {
- when(analysisMetadataHolder.isLongLivingBranch()).thenReturn(false);
+ when(analysisMetadataHolder.isBranch()).thenReturn(false);
dbTester.newCodePeriods().insert(type, value);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java
index 643a92eac97..00be77b18c8 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java
@@ -662,7 +662,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
@Override
public BranchType getType() {
- return BranchType.LONG;
+ return BranchType.BRANCH;
}
@Override
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java
index ff3f8d5cd9f..265bfdb37d7 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java
@@ -95,7 +95,7 @@ import static org.mockito.Mockito.when;
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.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.db.component.BranchType.PULL_REQUEST;
import static org.sonar.db.component.ComponentTesting.newBranchDto;
import static org.sonar.db.component.ComponentTesting.newFileDto;
@@ -247,14 +247,14 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
}
@Test
- public void send_global_new_issues_notification_on_long_branch() {
+ public void send_global_new_issues_notification_on_branch() {
ComponentDto project = newPrivateProjectDto(newOrganizationDto());
- ComponentDto branch = setUpBranch(project, LONG);
+ ComponentDto branch = setUpBranch(project, BRANCH);
issueCache.newAppender().append(
new DefaultIssue().setType(randomRuleType).setEffort(ISSUE_DURATION).setCreationDate(new Date(ANALYSE_DATE))).close();
when(notificationService.hasProjectSubscribersForTypes(branch.uuid(), NOTIF_TYPES)).thenReturn(true);
analysisMetadataHolder.setProject(Project.from(project));
- analysisMetadataHolder.setBranch(newBranch(BranchType.LONG));
+ analysisMetadataHolder.setBranch(newBranch(BranchType.BRANCH));
TestComputationStepContext context = new TestComputationStepContext();
underTest.execute(context);
@@ -285,14 +285,14 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
}
@Test
- public void do_not_send_global_new_issues_notification_on_long_branch_if_issue_has_been_backdated() {
+ public void do_not_send_global_new_issues_notification_on_branch_if_issue_has_been_backdated() {
ComponentDto project = newPrivateProjectDto(newOrganizationDto());
- ComponentDto branch = setUpBranch(project, LONG);
+ ComponentDto branch = setUpBranch(project, BRANCH);
issueCache.newAppender().append(
new DefaultIssue().setType(randomRuleType).setEffort(ISSUE_DURATION).setCreationDate(new Date(ANALYSE_DATE - FIVE_MINUTES_IN_MS))).close();
when(notificationService.hasProjectSubscribersForTypes(branch.uuid(), NOTIF_TYPES)).thenReturn(true);
analysisMetadataHolder.setProject(Project.from(project));
- analysisMetadataHolder.setBranch(newBranch(BranchType.LONG));
+ analysisMetadataHolder.setBranch(newBranch(BranchType.BRANCH));
TestComputationStepContext context = new TestComputationStepContext();
underTest.execute(context);
@@ -548,16 +548,16 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
}
@Test
- public void send_issues_change_notification_on_long_branch() {
- sendIssueChangeNotificationOnLongBranch(ANALYSE_DATE);
+ public void send_issues_change_notification_on_branch() {
+ sendIssueChangeNotificationOnBranch(ANALYSE_DATE);
}
@Test
- public void send_issues_change_notification_on_long_branch_even_if_issue_is_backdated() {
- sendIssueChangeNotificationOnLongBranch(ANALYSE_DATE - FIVE_MINUTES_IN_MS);
+ public void send_issues_change_notification_on_branch_even_if_issue_is_backdated() {
+ sendIssueChangeNotificationOnBranch(ANALYSE_DATE - FIVE_MINUTES_IN_MS);
}
- private void sendIssueChangeNotificationOnLongBranch(long issueCreatedAt) {
+ private void sendIssueChangeNotificationOnBranch(long issueCreatedAt) {
ComponentDto project = newPrivateProjectDto(newOrganizationDto());
ComponentDto branch = newProjectBranch(project, newBranchDto(project).setKey(BRANCH_NAME));
ComponentDto file = newFileDto(branch);
@@ -575,7 +575,7 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
when(notificationService.hasProjectSubscribersForTypes(project.uuid(), NOTIF_TYPES)).thenReturn(true);
IssuesChangesNotification issuesChangesNotification = mock(IssuesChangesNotification.class);
when(notificationFactory.newIssuesChangesNotification(anySet(), anyMap())).thenReturn(issuesChangesNotification);
- analysisMetadataHolder.setBranch(newBranch(BranchType.LONG));
+ analysisMetadataHolder.setBranch(newBranch(BranchType.BRANCH));
underTest.execute(new TestComputationStepContext());
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java
index 7deeb5f2b04..598b4f34003 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java
@@ -88,7 +88,7 @@ public class ValidateProjectStepTest {
public void dont_fail_for_long_forked_from_master_with_modules() {
ComponentDto masterProject = dbTester.components().insertMainBranch();
dbClient.componentDao().insert(dbTester.getSession(), ComponentTesting.newModuleDto(masterProject));
- setBranch(BranchType.LONG, masterProject.uuid());
+ setBranch(BranchType.BRANCH, masterProject.uuid());
dbTester.getSession().commit();
treeRootHolder.setRoot(ReportComponent.builder(Component.Type.PROJECT, 1).setUuid("DEFG")
diff --git a/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderRule.java b/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderRule.java
index 2e2f96a9626..1858d25a7f7 100644
--- a/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderRule.java
+++ b/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderRule.java
@@ -251,9 +251,9 @@ public class AnalysisMetadataHolderRule extends ExternalResource implements Muta
}
@Override
- public boolean isLongLivingBranch() {
+ public boolean isBranch() {
Branch property = this.branch.getProperty();
- return property != null && property.getType() == BranchType.LONG;
+ return property != null && property.getType() == BranchType.BRANCH;
}
@Override
diff --git a/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/MutableAnalysisMetadataHolderRule.java b/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/MutableAnalysisMetadataHolderRule.java
index 3a137ba3d86..893c8a489f3 100644
--- a/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/MutableAnalysisMetadataHolderRule.java
+++ b/server/sonar-ce-task-projectanalysis/src/testFixtures/java/org/sonar/ce/task/projectanalysis/analysis/MutableAnalysisMetadataHolderRule.java
@@ -195,8 +195,8 @@ public class MutableAnalysisMetadataHolderRule extends ExternalResource implemen
}
@Override
- public boolean isLongLivingBranch() {
- return delegate.isLongLivingBranch();
+ public boolean isBranch() {
+ return delegate.isBranch();
}
@Override
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchType.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchType.java
index 852476d08d3..fd105f7492f 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchType.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchType.java
@@ -22,11 +22,6 @@ package org.sonar.db.component;
public enum BranchType {
/**
- * Long-lived branch
- */
- LONG,
-
- /**
* Short-lived branch
*/
SHORT,
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java
index 42c83faa85d..348cbbd9ce3 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/measure/LiveMeasureDao.java
@@ -98,13 +98,13 @@ public class LiveMeasureDao implements Dao {
/**
* Example:
- * If Main Branch = 0 LOCs (provisioned but never analyzed) and the "largest long-lived branch" is 120 LOCs, I'm expecting to consider the value 120.
- * If Main Branch = 100 LOCs and the "largest long-lived branch" is 120 LOCs, I'm expecting to consider the value 120.
- * If Main Branch = 100 LOCs and the "largest long-lived branch" is 80 LOCs, I'm expecting to consider the value 100.
+ * If Main Branch = 0 LOCs (provisioned but never analyzed) and the "largest branch" is 120 LOCs, I'm expecting to consider the value 120.
+ * If Main Branch = 100 LOCs and the "largest branch" is 120 LOCs, I'm expecting to consider the value 120.
+ * If Main Branch = 100 LOCs and the "largest branch" is 80 LOCs, I'm expecting to consider the value 100.
*/
public long sumNclocOfBiggestLongLivingBranch(DbSession dbSession, SumNclocDbQuery dbQuery) {
Long ncloc = mapper(dbSession).sumNclocOfBiggestLongLivingBranch(
- NCLOC_KEY, KeyType.BRANCH, BranchType.LONG, dbQuery.getOrganizationUuid(), dbQuery.getOnlyPrivateProjects(), dbQuery.getProjectUuidToExclude());
+ NCLOC_KEY, KeyType.BRANCH, BranchType.BRANCH, dbQuery.getOrganizationUuid(), dbQuery.getOnlyPrivateProjects(), dbQuery.getProjectUuidToExclude());
return ncloc == null ? 0L : ncloc;
}
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDao.java
index 39e1b1f6533..6d720cf9bb7 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDao.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/organization/OrganizationDao.java
@@ -145,7 +145,7 @@ public class OrganizationDao implements Dao {
public List<OrganizationWithNclocDto> selectOrganizationsWithNcloc(DbSession dbSession, List<String> organizationUuids) {
List<OrganizationWithNclocDto> result = new ArrayList<>();
executeLargeUpdates(organizationUuids, chunk ->
- result.addAll(getMapper(dbSession).selectOrganizationsWithNcloc(NCLOC_KEY, chunk, KeyType.BRANCH, BranchType.LONG))
+ result.addAll(getMapper(dbSession).selectOrganizationsWithNcloc(NCLOC_KEY, chunk, KeyType.BRANCH, BranchType.BRANCH))
);
return result;
}
diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
index d33ff6a42bb..6b9fc43381f 100644
--- a/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
+++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/component/ComponentMapper.xml
@@ -43,7 +43,7 @@
where
(p.kee=#{dbKey,jdbcType=VARCHAR} OR p.kee=#{key,jdbcType=VARCHAR})
and pb.kee=#{branch,jdbcType=VARCHAR}
- and (pb.branch_type='LONG' or pb.branch_type='SHORT')
+ and (pb.branch_type='BRANCH')
</select>
<select id="selectPrByKeyAndBranchKey" parameterType="String" resultType="Component">
@@ -775,7 +775,7 @@
where
m.name = 'ncloc'
and b.key_type = 'BRANCH'
- and b.branch_type = 'LONG'
+ and b.branch_type = 'BRANCH'
and p.enabled = ${_true}
and p.private = ${_true}
and p.scope = 'PRJ'
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java
index 1e844b6df59..bcda3987cb7 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java
@@ -61,7 +61,7 @@ public class BranchDaoTest {
BranchDto dto = new BranchDto();
dto.setProjectUuid("U1");
dto.setUuid("U2");
- dto.setBranchType(BranchType.LONG);
+ dto.setBranchType(BranchType.BRANCH);
dto.setKey("feature/foo");
underTest.insert(dbSession, dto);
@@ -70,7 +70,7 @@ public class BranchDaoTest {
assertThat(map).contains(
entry("projectUuid", "U1"),
entry("uuid", "U2"),
- entry("branchType", "LONG"),
+ entry("branchType", "BRANCH"),
entry("kee", "feature/foo"),
entry("mergeBranchUuid", null),
entry("pullRequestBinary", null),
@@ -83,14 +83,14 @@ public class BranchDaoTest {
BranchDto dto = new BranchDto();
dto.setProjectUuid("U1");
dto.setUuid("U1");
- dto.setBranchType(BranchType.LONG);
+ dto.setBranchType(BranchType.BRANCH);
dto.setKey("feature");
underTest.insert(dbSession, dto);
BranchDto dto2 = new BranchDto();
dto2.setProjectUuid("U2");
dto2.setUuid("U2");
- dto2.setBranchType(BranchType.LONG);
+ dto2.setBranchType(BranchType.BRANCH);
dto2.setKey("branch");
underTest.insert(dbSession, dto2);
@@ -98,7 +98,7 @@ public class BranchDaoTest {
BranchDto loaded = underTest.selectByBranchKey(dbSession, "U1", "master").get();
assertThat(loaded.getMergeBranchUuid()).isNull();
assertThat(loaded.getProjectUuid()).isEqualTo("U1");
- assertThat(loaded.getBranchType()).isEqualTo(BranchType.LONG);
+ assertThat(loaded.getBranchType()).isEqualTo(BranchType.BRANCH);
}
@Test
@@ -106,7 +106,7 @@ public class BranchDaoTest {
BranchDto dto = new BranchDto();
dto.setProjectUuid("U1");
dto.setUuid("U1");
- dto.setBranchType(BranchType.LONG);
+ dto.setBranchType(BranchType.BRANCH);
dto.setKey("feature");
dto.setExcludeFromPurge(false);
underTest.insert(dbSession, dto);
@@ -146,7 +146,7 @@ public class BranchDaoTest {
BranchDto dto = new BranchDto();
dto.setProjectUuid(repeat("a", 50));
dto.setUuid(repeat("b", 50));
- dto.setBranchType(BranchType.LONG);
+ dto.setBranchType(BranchType.BRANCH);
dto.setKey(repeat("c", 255));
dto.setMergeBranchUuid(repeat("d", 50));
@@ -233,7 +233,7 @@ public class BranchDaoTest {
BranchDto dto = new BranchDto();
dto.setProjectUuid("U1");
dto.setUuid("U2");
- dto.setBranchType(BranchType.LONG);
+ dto.setBranchType(BranchType.BRANCH);
dto.setKey("foo");
underTest.insert(dbSession, dto);
@@ -242,13 +242,13 @@ public class BranchDaoTest {
// the fields that can't be updated. New values are ignored.
dto.setProjectUuid("ignored");
- dto.setBranchType(BranchType.LONG);
+ dto.setBranchType(BranchType.BRANCH);
underTest.upsert(dbSession, dto);
BranchDto loaded = underTest.selectByBranchKey(dbSession, "U1", "foo").get();
assertThat(loaded.getMergeBranchUuid()).isEqualTo("U3");
assertThat(loaded.getProjectUuid()).isEqualTo("U1");
- assertThat(loaded.getBranchType()).isEqualTo(BranchType.LONG);
+ assertThat(loaded.getBranchType()).isEqualTo(BranchType.BRANCH);
}
@Test
@@ -278,7 +278,7 @@ public class BranchDaoTest {
// the fields that can't be updated. New values are ignored.
dto.setProjectUuid("ignored");
- dto.setBranchType(BranchType.LONG);
+ dto.setBranchType(BranchType.BRANCH);
underTest.upsert(dbSession, dto);
BranchDto loaded = underTest.selectByPullRequestKey(dbSession, "U1", "foo").get();
@@ -352,14 +352,14 @@ public class BranchDaoTest {
BranchDto mainBranch = new BranchDto();
mainBranch.setProjectUuid("U1");
mainBranch.setUuid("U1");
- mainBranch.setBranchType(BranchType.LONG);
+ mainBranch.setBranchType(BranchType.BRANCH);
mainBranch.setKey("master");
underTest.insert(dbSession, mainBranch);
BranchDto featureBranch = new BranchDto();
featureBranch.setProjectUuid("U1");
featureBranch.setUuid("U2");
- featureBranch.setBranchType(BranchType.LONG);
+ featureBranch.setBranchType(BranchType.BRANCH);
featureBranch.setKey("feature/foo");
featureBranch.setMergeBranchUuid("U3");
underTest.insert(dbSession, featureBranch);
@@ -381,14 +381,14 @@ public class BranchDaoTest {
BranchDto mainBranch = new BranchDto();
mainBranch.setProjectUuid("U1");
mainBranch.setUuid("U1");
- mainBranch.setBranchType(BranchType.LONG);
+ mainBranch.setBranchType(BranchType.BRANCH);
mainBranch.setKey("master");
underTest.insert(dbSession, mainBranch);
BranchDto featureBranch = new BranchDto();
featureBranch.setProjectUuid("U1");
featureBranch.setUuid("U2");
- featureBranch.setBranchType(BranchType.LONG);
+ featureBranch.setBranchType(BranchType.BRANCH);
featureBranch.setKey("feature/foo");
featureBranch.setMergeBranchUuid("U3");
underTest.insert(dbSession, featureBranch);
@@ -410,7 +410,7 @@ public class BranchDaoTest {
BranchDto mainBranch = new BranchDto();
mainBranch.setProjectUuid("U1");
mainBranch.setUuid("U1");
- mainBranch.setBranchType(BranchType.LONG);
+ mainBranch.setBranchType(BranchType.BRANCH);
mainBranch.setKey("master");
underTest.insert(dbSession, mainBranch);
@@ -479,15 +479,15 @@ public class BranchDaoTest {
@Test
public void countByTypeAndCreationDate() {
- assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.LONG, 0L)).isEqualTo(0);
+ assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.BRANCH, 0L)).isEqualTo(0);
ComponentDto project = db.components().insertPrivateProject();
- ComponentDto longBranch1 = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.LONG));
- ComponentDto longBranch2 = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.LONG));
+ ComponentDto branch1 = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.BRANCH));
+ ComponentDto branch2 = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.BRANCH));
ComponentDto pr = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.PULL_REQUEST));
- assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.LONG, 0L)).isEqualTo(2);
- assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.LONG, NOW)).isEqualTo(2);
- assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.LONG, NOW + 100)).isEqualTo(0);
+ assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.BRANCH, 0L)).isEqualTo(2);
+ assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.BRANCH, NOW)).isEqualTo(2);
+ assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.BRANCH, NOW + 100)).isEqualTo(0);
assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.PULL_REQUEST, 0L)).isEqualTo(1);
assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.PULL_REQUEST, NOW)).isEqualTo(1);
assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.PULL_REQUEST, NOW + 100)).isEqualTo(0);
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDtoTest.java
index 1be09437991..2b31b06ba99 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDtoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDtoTest.java
@@ -54,12 +54,12 @@ public class BranchDtoTest {
underTest.setUuid("U1");
underTest.setProjectUuid("U2");
underTest.setKey("K1");
- underTest.setBranchType(BranchType.LONG);
+ underTest.setBranchType(BranchType.BRANCH);
underTest.setMergeBranchUuid("U3");
underTest.setExcludeFromPurge(true);
assertThat(underTest.toString()).isEqualTo("BranchDto{uuid='U1', " +
- "projectUuid='U2', kee='K1', keyType=null, branchType=LONG, mergeBranchUuid='U3', excludeFromPurge=true}");
+ "projectUuid='U2', kee='K1', keyType=null, branchType=BRANCH, mergeBranchUuid='U3', excludeFromPurge=true}");
}
@Test
@@ -67,7 +67,7 @@ public class BranchDtoTest {
underTest.setUuid("U1");
underTest.setProjectUuid("U2");
underTest.setKey("K1");
- underTest.setBranchType(BranchType.LONG);
+ underTest.setBranchType(BranchType.BRANCH);
underTest.setMergeBranchUuid("U3");
BranchDto toCompare = new BranchDto();
@@ -75,7 +75,7 @@ public class BranchDtoTest {
toCompare.setUuid("U1");
toCompare.setProjectUuid("U2");
toCompare.setKey("K1");
- toCompare.setBranchType(BranchType.LONG);
+ toCompare.setBranchType(BranchType.BRANCH);
toCompare.setMergeBranchUuid("U3");
assertThat(underTest).isEqualTo(toCompare);
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
index 15b1acc9eec..1fef8b8d36d 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java
@@ -71,7 +71,7 @@ import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.api.resources.Qualifiers.APP;
import static org.sonar.api.resources.Qualifiers.PROJECT;
import static org.sonar.api.utils.DateUtils.parseDate;
-import static org.sonar.db.component.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.db.component.BranchType.PULL_REQUEST;
import static org.sonar.db.component.ComponentTesting.newBranchDto;
import static org.sonar.db.component.ComponentTesting.newDirectory;
@@ -221,7 +221,7 @@ public class ComponentDaoTest {
@Test
public void selectByKeyAndBranch() {
ComponentDto project = db.components().insertMainBranch();
- ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("my_branch").setBranchType(LONG));
+ 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(), "master").get().uuid()).isEqualTo(project.uuid());
@@ -1617,12 +1617,12 @@ public class ComponentDaoTest {
long recentTime = 3_000_000_000L;
// project with only a non-main and old analyzed branch
ComponentDto oldProject = db.components().insertMainBranch();
- ComponentDto oldProjectBranch = db.components().insertProjectBranch(oldProject, newBranchDto(oldProject).setBranchType(BranchType.LONG));
+ ComponentDto oldProjectBranch = db.components().insertProjectBranch(oldProject, newBranchDto(oldProject).setBranchType(BRANCH));
db.components().insertSnapshot(oldProjectBranch, s -> s.setLast(true).setCreatedAt(aLongTimeAgo));
// project with only a old main branch and a recent non-main branch
ComponentDto recentProject = db.components().insertMainBranch();
- ComponentDto recentProjectBranch = db.components().insertProjectBranch(recentProject, newBranchDto(recentProject).setBranchType(BranchType.LONG));
+ ComponentDto recentProjectBranch = db.components().insertProjectBranch(recentProject, newBranchDto(recentProject).setBranchType(BRANCH));
db.components().insertSnapshot(recentProjectBranch, s -> s.setCreatedAt(recentTime).setLast(true));
db.components().insertSnapshot(recentProjectBranch, s -> s.setCreatedAt(aLongTimeAgo).setLast(false));
@@ -1969,8 +1969,8 @@ public class ComponentDaoTest {
final ComponentDto project1 = db.components().insertMainBranch(organizationDto, b -> b.setName("foo"));
insertMeasure(20d, project1, metric);
- // long branch of project1 - returned
- insertMeasure(30d, db.components().insertProjectBranch(project1, b -> b.setBranchType(BranchType.LONG)), metric);
+ // branch of project1 - returned
+ insertMeasure(30d, db.components().insertProjectBranch(project1, b -> b.setBranchType(BRANCH)), metric);
// project2 - returned
insertMeasure(10d, db.components().insertMainBranch(organizationDto, b -> b.setName("bar")), metric);
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrollForFileMoveComponentDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrollForFileMoveComponentDaoTest.java
index 65cab2dfd1c..593917fbe8b 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrollForFileMoveComponentDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrollForFileMoveComponentDaoTest.java
@@ -176,8 +176,7 @@ public class ScrollForFileMoveComponentDaoTest {
@DataProvider
public static Object[][] branchTypes() {
return new Object[][] {
- {BranchType.LONG},
- {BranchType.SHORT},
+ {BranchType.BRANCH},
{BranchType.PULL_REQUEST}
};
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java
index fffce192a76..84009ae162c 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java
@@ -198,7 +198,7 @@ public class IssueDaoTest {
ComponentDto project = db.components().insertMainBranch();
ComponentDto projectBranch = db.components().insertProjectBranch(project,
b -> b.setKey("feature/foo")
- .setBranchType(BranchType.LONG));
+ .setBranchType(BranchType.BRANCH));
ComponentDto file = db.components().insertComponent(newFileDto(projectBranch));
@@ -220,7 +220,7 @@ public class IssueDaoTest {
ComponentDto project = db.components().insertMainBranch();
ComponentDto projectBranch = db.components().insertProjectBranch(project,
b -> b.setKey("feature/foo")
- .setBranchType(BranchType.LONG));
+ .setBranchType(BranchType.BRANCH));
ComponentDto file = db.components().insertComponent(newFileDto(projectBranch));
IssueDto fpIssue = db.issues().insert(rule, projectBranch, file, i -> i.setStatus("RESOLVED").setResolution("FALSE-POSITIVE"));
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
index 7d35e0ce13f..7f4071d45e4 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java
@@ -278,9 +278,9 @@ public class LiveMeasureDaoTest {
db.measures().insertLiveMeasure(simpleProject, ncloc, m -> m.setValue(10d));
ComponentDto projectWithBiggerLongLivingBranch = db.components().insertMainBranch(organization);
- ComponentDto bigLongLivingLongBranch = db.components().insertProjectBranch(projectWithBiggerLongLivingBranch, b -> b.setBranchType(BranchType.LONG));
+ ComponentDto bigBranch = db.components().insertProjectBranch(projectWithBiggerLongLivingBranch, b -> b.setBranchType(BranchType.BRANCH));
db.measures().insertLiveMeasure(projectWithBiggerLongLivingBranch, ncloc, m -> m.setValue(100d));
- db.measures().insertLiveMeasure(bigLongLivingLongBranch, ncloc, m -> m.setValue(200d));
+ db.measures().insertLiveMeasure(bigBranch, ncloc, m -> m.setValue(200d));
ComponentDto projectWithLinesButNoLoc = db.components().insertMainBranch(organization);
db.measures().insertLiveMeasure(projectWithLinesButNoLoc, lines, m -> m.setValue(365d));
@@ -317,12 +317,12 @@ public class LiveMeasureDaoTest {
db.measures().insertLiveMeasure(simpleProject, ncloc, m -> m.setValue(10d));
ComponentDto projectWithBiggerLongLivingBranch = db.components().insertMainBranch(organization);
- ComponentDto bigLongLivingBranch = db.components().insertProjectBranch(projectWithBiggerLongLivingBranch, b -> b.setBranchType(BranchType.LONG));
+ ComponentDto bigBranch = db.components().insertProjectBranch(projectWithBiggerLongLivingBranch, b -> b.setBranchType(BranchType.BRANCH));
db.measures().insertLiveMeasure(projectWithBiggerLongLivingBranch, ncloc, m -> m.setValue(100d));
- db.measures().insertLiveMeasure(bigLongLivingBranch, ncloc, m -> m.setValue(200d));
+ db.measures().insertLiveMeasure(bigBranch, ncloc, m -> m.setValue(200d));
ComponentDto projectToExclude = db.components().insertMainBranch(organization);
- ComponentDto projectToExcludeBranch = db.components().insertProjectBranch(projectToExclude, b -> b.setBranchType(BranchType.LONG));
+ ComponentDto projectToExcludeBranch = db.components().insertProjectBranch(projectToExclude, b -> b.setBranchType(BranchType.BRANCH));
db.measures().insertLiveMeasure(projectToExclude, ncloc, m -> m.setValue(300d));
db.measures().insertLiveMeasure(projectToExcludeBranch, ncloc, m -> m.setValue(400d));
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java
index 43c79c32c17..e023c37d88e 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/AuthorizationDaoTest.java
@@ -1220,7 +1220,7 @@ public class AuthorizationDaoTest {
@Test
public void keepAuthorizedLoginsOnProject_return_correct_users_on_branch() {
ComponentDto project = db.components().insertPrivateProject(organization);
- ComponentDto branch = db.components().insertProjectBranch(project, c -> c.setBranchType(BranchType.LONG));
+ ComponentDto branch = db.components().insertProjectBranch(project, c -> c.setBranchType(BranchType.BRANCH));
GroupDto userGroup = db.users().insertGroup(organization, "USERS");
GroupDto adminGroup = db.users().insertGroup(organization, "ADMIN");
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java
index 627981dc371..ac8ee748a01 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentDbTester.java
@@ -30,7 +30,7 @@ import org.sonar.db.organization.OrganizationDto;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Arrays.asList;
-import static org.sonar.db.component.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
public class ComponentDbTester {
private final DbTester db;
@@ -252,7 +252,7 @@ public class ComponentDbTester {
}
public final ComponentDto insertMainBranch(ComponentDto project) {
- BranchDto branchDto = ComponentTesting.newBranchDto(project, LONG);
+ BranchDto branchDto = ComponentTesting.newBranchDto(project, BRANCH);
insertComponent(project);
dbClient.branchDao().insert(dbSession, branchDto);
db.commit();
@@ -262,7 +262,7 @@ public class ComponentDbTester {
@SafeVarargs
public final ComponentDto insertMainBranch(OrganizationDto organization, String mainBranchName, Consumer<ComponentDto>... dtoPopulators) {
ComponentDto project = ComponentTesting.newPrivateProjectDto(organization);
- BranchDto branchDto = ComponentTesting.newBranchDto(project, LONG).setKey(mainBranchName);
+ BranchDto branchDto = ComponentTesting.newBranchDto(project, BRANCH).setKey(mainBranchName);
Arrays.stream(dtoPopulators).forEach(dtoPopulator -> dtoPopulator.accept(project));
insertComponent(project);
dbClient.branchDao().insert(dbSession, branchDto);
@@ -273,7 +273,7 @@ public class ComponentDbTester {
@SafeVarargs
public final ComponentDto insertProjectBranch(ComponentDto project, Consumer<BranchDto>... dtoPopulators) {
// MainBranchProjectUuid will be null if it's a main branch
- BranchDto branchDto = ComponentTesting.newBranchDto(firstNonNull(project.getMainBranchProjectUuid(), project.projectUuid()), LONG);
+ BranchDto branchDto = ComponentTesting.newBranchDto(firstNonNull(project.getMainBranchProjectUuid(), project.projectUuid()), BRANCH);
Arrays.stream(dtoPopulators).forEach(dtoPopulator -> dtoPopulator.accept(branchDto));
ComponentDto branch = ComponentTesting.newProjectBranch(project, branchDto);
insertComponent(branch);
diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
index 95f6c9aa54e..5031f4f025b 100644
--- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
+++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/component/ComponentTesting.java
@@ -233,7 +233,7 @@ public class ComponentTesting {
}
public static BranchDto newBranchDto(ComponentDto project) {
- return newBranchDto(project.projectUuid(), BranchType.LONG);
+ return newBranchDto(project.projectUuid(), BranchType.BRANCH);
}
public static BranchDto newBranchDto(ComponentDto branchComponent, BranchType branchType) {
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest.java
index adf551ef4c3..ca0edcb214e 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v80/PopulateNewCodePeriodTableTest.java
@@ -200,7 +200,7 @@ public class PopulateNewCodePeriodTableTest {
"PROJECT_UUID", "pb-uuid-" + mainBranchUid,
"KEE", "pb-key-" + uid,
"KEY_TYPE", "TSR",
- "BRANCH_TYPE", "LONG",
+ "BRANCH_TYPE", "BRANCH",
"MERGE_BRANCH_UUID", "mb-uuid-" + mainBranchUid,
"MANUAL_BASELINE_ANALYSIS_UUID", manualBaseline,
"CREATED_AT", System2.INSTANCE.now(),
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java b/server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java
index db2d8c8a034..774b98ccd8a 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java
@@ -123,7 +123,7 @@ public class WebhookPayloadFactoryImpl implements WebhookPayloadFactory {
private String branchUrlOf(Project project, Branch branch) {
Branch.Type branchType = branch.getType();
- if (branchType == Branch.Type.LONG || branchType == Branch.Type.SHORT) {
+ if (branchType == Branch.Type.BRANCH) {
if (branch.isMain()) {
return projectUrlOf(project);
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/BranchTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/BranchTest.java
index b4b7e252392..1cc99d60ea4 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/BranchTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/BranchTest.java
@@ -30,7 +30,7 @@ public class BranchTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private Branch underTest = new Branch(true, "b", Branch.Type.LONG);
+ private Branch underTest = new Branch(true, "b", Branch.Type.BRANCH);
@Test
public void constructor_throws_NPE_if_type_is_null() {
@@ -44,12 +44,12 @@ public class BranchTest {
public void verify_getters() {
assertThat(underTest.isMain()).isTrue();
assertThat(underTest.getName()).contains("b");
- assertThat(underTest.getType()).isEqualTo(Branch.Type.LONG);
+ assertThat(underTest.getType()).isEqualTo(Branch.Type.BRANCH);
- Branch underTestWithNull = new Branch(false, null, Branch.Type.LONG);
+ Branch underTestWithNull = new Branch(false, null, Branch.Type.BRANCH);
assertThat(underTestWithNull.isMain()).isFalse();
assertThat(underTestWithNull.getName()).isEmpty();
- assertThat(underTestWithNull.getType()).isEqualTo(Branch.Type.LONG);
+ assertThat(underTestWithNull.getType()).isEqualTo(Branch.Type.BRANCH);
}
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/ProjectAnalysisTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/ProjectAnalysisTest.java
index a704f352d67..b011eec1f1f 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/ProjectAnalysisTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/ProjectAnalysisTest.java
@@ -39,7 +39,7 @@ public class ProjectAnalysisTest {
private final CeTask ceTask = new CeTask("id", CeTask.Status.SUCCESS);
private final Project project = new Project("uuid", "key", "name");
private final Analysis analysis = new Analysis("analysis_uuid", 1_500L, "sha1");
- private final Branch branch = new Branch(true, "name", Branch.Type.LONG);
+ private final Branch branch = new Branch(true, "name", Branch.Type.BRANCH);
private final EvaluatedQualityGate qualityGate = EvaluatedQualityGate.newBuilder()
.setQualityGate(new QualityGate("id", "name", emptySet()))
.setStatus(Metric.Level.ERROR)
@@ -148,6 +148,6 @@ public class ProjectAnalysisTest {
@Test
public void verify_toString() {
assertThat(underTest.toString()).isEqualTo(
- "ProjectAnalysis{project=Project{uuid='uuid', key='key', name='name'}, ceTask=CeTask{id='id', status=SUCCESS}, branch=Branch{main=true, name='name', type=LONG}, qualityGate=EvaluatedQualityGate{qualityGate=QualityGate{id=id, name='name', conditions=[]}, status=ERROR, evaluatedConditions=[]}, updatedAt=1, properties={a=b}, analysis=Analysis{uuid='analysis_uuid', date=1500, revision=sha1}}");
+ "ProjectAnalysis{project=Project{uuid='uuid', key='key', name='name'}, ceTask=CeTask{id='id', status=SUCCESS}, branch=Branch{main=true, name='name', type=BRANCH}, qualityGate=EvaluatedQualityGate{qualityGate=QualityGate{id=id, name='name', conditions=[]}, status=ERROR, evaluatedConditions=[]}, updatedAt=1, properties={a=b}, analysis=Analysis{uuid='analysis_uuid', date=1500, revision=sha1}}");
}
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java
index d8534ce4335..b33aec78e8f 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java
@@ -270,16 +270,16 @@ public class WebhookPayloadFactoryImplTest {
}
@Test
- public void create_payload_on_long_branch() {
+ public void create_payload_on_branch() {
CeTask task = new CeTask("#1", CeTask.Status.SUCCESS);
- ProjectAnalysis analysis = newAnalysis(task, null, new Branch(false, "feature/foo", Branch.Type.LONG), 1_500_000_000_000L, emptyMap());
+ ProjectAnalysis analysis = newAnalysis(task, null, new Branch(false, "feature/foo", Branch.Type.BRANCH), 1_500_000_000_000L, emptyMap());
WebhookPayload payload = underTest.create(analysis);
assertJson(payload.getJson())
.isSimilarTo("{" +
"\"branch\": {" +
" \"name\": \"feature/foo\"" +
- " \"type\": \"LONG\"" +
+ " \"type\": \"BRANCH\"" +
" \"isMain\": false," +
" \"url\": \"http://foo/dashboard?id=P1&branch=feature%2Ffoo\"" +
"}" +
@@ -289,13 +289,13 @@ public class WebhookPayloadFactoryImplTest {
@Test
public void create_payload_on_main_branch_without_name() {
CeTask task = new CeTask("#1", CeTask.Status.SUCCESS);
- ProjectAnalysis analysis = newAnalysis(task, null, new Branch(true, null, Branch.Type.LONG), 1_500_000_000_000L, emptyMap());
+ ProjectAnalysis analysis = newAnalysis(task, null, new Branch(true, null, Branch.Type.BRANCH), 1_500_000_000_000L, emptyMap());
WebhookPayload payload = underTest.create(analysis);
assertJson(payload.getJson())
.isSimilarTo("{" +
"\"branch\": {" +
- " \"type\": \"LONG\"" +
+ " \"type\": \"BRANCH\"" +
" \"isMain\": true," +
" \"url\": \"http://foo/dashboard?id=P1\"" +
"}" +
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java
index 5141a356757..c7dd10533ef 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java
@@ -59,7 +59,7 @@ import static org.sonar.api.measures.CoreMetrics.LINES_KEY;
import static org.sonar.api.measures.CoreMetrics.NCLOC_KEY;
import static org.sonar.api.measures.CoreMetrics.NCLOC_LANGUAGE_DISTRIBUTION_KEY;
import static org.sonar.core.platform.EditionProvider.Edition.DEVELOPER;
-import static org.sonar.db.component.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.db.component.BranchType.PULL_REQUEST;
public class TelemetryDataLoaderImplTest {
@@ -149,7 +149,7 @@ public class TelemetryDataLoaderImplTest {
server.setId("AU-TpxcB-iU5OvuD2FL7").setVersion("7.5.4");
MetricDto ncloc = db.measures().insertMetric(m -> m.setKey(NCLOC_KEY));
ComponentDto project = db.components().insertMainBranch(db.getDefaultOrganization());
- ComponentDto branch1 = db.components().insertProjectBranch(project, b -> b.setBranchType(LONG));
+ ComponentDto branch1 = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH));
ComponentDto pr = db.components().insertProjectBranch(project, b -> b.setBranchType(PULL_REQUEST));
db.measures().insertLiveMeasure(project, ncloc, m -> m.setValue(10d));
db.measures().insertLiveMeasure(branch1, ncloc, m -> m.setValue(20d));
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java
index 1f33d63519b..cbc18717ad6 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/webhook/WebhookQGChangeEventListenerTest.java
@@ -65,7 +65,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import static org.sonar.core.util.stream.MoreCollectors.toArrayList;
-import static org.sonar.db.component.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.db.component.ComponentTesting.newBranchDto;
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
@@ -146,7 +146,7 @@ public class WebhookQGChangeEventListenerTest {
public void onIssueChanges_calls_webhook_for_changeEvent_with_webhook_enabled(@Nullable EvaluatedQualityGate newQualityGate) {
OrganizationDto organization = dbTester.organizations().insert();
ComponentDto project = dbTester.components().insertPublicProject(organization);
- ComponentAndBranch branch = insertProjectBranch(project, BranchType.LONG, "foo");
+ ComponentAndBranch branch = insertProjectBranch(project, BRANCH, "foo");
SnapshotDto analysis = insertAnalysisTask(branch);
Configuration configuration = mock(Configuration.class);
mockPayloadSupplierConsumedByWebhooks();
@@ -165,7 +165,7 @@ public class WebhookQGChangeEventListenerTest {
new Project(project.uuid(), project.getKey(), project.name()),
null,
new Analysis(analysis.getUuid(), analysis.getCreatedAt(), analysis.getRevision()),
- new Branch(false, "foo", Branch.Type.LONG),
+ new Branch(false, "foo", Branch.Type.BRANCH),
newQualityGate,
null,
properties));
@@ -187,8 +187,8 @@ public class WebhookQGChangeEventListenerTest {
}
@Test
- public void onIssueChanges_calls_webhook_on_long_branch() {
- onIssueChangesCallsWebhookOnBranch(BranchType.LONG);
+ public void onIssueChanges_calls_webhook_on_branch() {
+ onIssueChangesCallsWebhookOnBranch(BRANCH);
}
@Test
@@ -277,7 +277,7 @@ public class WebhookQGChangeEventListenerTest {
public ComponentAndBranch insertMainBranch(OrganizationDto organization) {
ComponentDto project = newPrivateProjectDto(organization);
- BranchDto branch = newBranchDto(project, LONG).setKey("master");
+ BranchDto branch = newBranchDto(project, BRANCH).setKey("master");
dbTester.components().insertComponent(project);
dbClient.branchDao().insert(dbTester.getSession(), branch);
dbTester.commit();
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/badge/ws/ProjectBadgesSupport.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/badge/ws/ProjectBadgesSupport.java
index 5c39e89c6ce..fc412158045 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/badge/ws/ProjectBadgesSupport.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/badge/ws/ProjectBadgesSupport.java
@@ -33,7 +33,7 @@ import org.sonar.server.user.UserSession;
import static org.sonar.api.resources.Qualifiers.APP;
import static org.sonar.api.resources.Qualifiers.PROJECT;
import static org.sonar.api.web.UserRole.USER;
-import static org.sonar.db.component.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
@@ -81,7 +81,7 @@ public class ProjectBadgesSupport {
if (project.isPrivate()) {
throw generateInvalidProjectExcpetion();
}
- if (branch.isPresent() && !branch.get().getBranchType().equals(LONG)) {
+ if (branch.isPresent() && !branch.get().getBranchType().equals(BRANCH)) {
throw generateInvalidProjectExcpetion();
}
if (!project.qualifier().equals(PROJECT) && !project.qualifier().equals(APP)) {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/branch/ws/ListAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/branch/ws/ListAction.java
index 60f0df556af..710ed203fa6 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/branch/ws/ListAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/branch/ws/ListAction.java
@@ -40,7 +40,6 @@ import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.SnapshotDto;
import org.sonar.db.measure.LiveMeasureDto;
import org.sonar.server.component.ComponentFinder;
-import org.sonar.server.issue.index.IssueIndex;
import org.sonar.server.user.UserSession;
import org.sonar.server.ws.WsUtils;
import org.sonarqube.ws.Common;
@@ -57,7 +56,6 @@ import static org.sonar.api.web.UserRole.USER;
import static org.sonar.core.util.stream.MoreCollectors.toList;
import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex;
import static org.sonar.db.component.BranchType.BRANCH;
-import static org.sonar.db.component.BranchType.LONG;
import static org.sonar.db.permission.OrganizationPermission.SCAN;
import static org.sonar.server.branch.ws.BranchesWs.addProjectParam;
import static org.sonar.server.branch.ws.ProjectBranchesParameters.ACTION_LIST;
@@ -71,13 +69,11 @@ public class ListAction implements BranchWsAction {
private final DbClient dbClient;
private final UserSession userSession;
private final ComponentFinder componentFinder;
- private final IssueIndex issueIndex;
- public ListAction(DbClient dbClient, UserSession userSession, ComponentFinder componentFinder, IssueIndex issueIndex) {
+ public ListAction(DbClient dbClient, UserSession userSession, ComponentFinder componentFinder) {
this.dbClient = dbClient;
this.userSession = userSession;
this.componentFinder = componentFinder;
- this.issueIndex = issueIndex;
}
@Override
@@ -103,7 +99,7 @@ public class ListAction implements BranchWsAction {
checkArgument(ALLOWED_QUALIFIERS.contains(project.qualifier()), "Invalid project");
Collection<BranchDto> branches = dbClient.branchDao().selectByComponent(dbSession, project).stream()
- .filter(b -> b.getBranchType() == LONG || b.getBranchType() == BRANCH)
+ .filter(b -> b.getBranchType() == BRANCH)
.collect(toList());
List<String> branchUuids = branches.stream().map(BranchDto::getUuid).collect(toList());
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 f39283fef5f..fdd8e7f1f74 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
@@ -128,7 +128,7 @@ public class ComponentUpdater {
private void createMainBranch(DbSession session, String componentUuid) {
BranchDto branch = new BranchDto()
- .setBranchType(BranchType.LONG)
+ .setBranchType(BranchType.BRANCH)
.setUuid(componentUuid)
.setKey(BranchDto.DEFAULT_MAIN_BRANCH_NAME)
.setMergeBranchUuid(null)
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ListAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ListAction.java
index 325f0877114..a241e885d64 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ListAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ListAction.java
@@ -44,7 +44,7 @@ import org.sonarqube.ws.NewCodePeriods;
import org.sonarqube.ws.NewCodePeriods.ListWSResponse;
import static org.sonar.core.util.stream.MoreCollectors.toList;
-import static org.sonar.db.component.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
import static org.sonarqube.ws.NewCodePeriods.ShowWSResponse.newBuilder;
@@ -85,7 +85,7 @@ public class ListAction implements NewCodePeriodsWsAction {
ComponentDto project = componentFinder.getByKey(dbSession, projectKey);
userSession.checkComponentPermission(UserRole.ADMIN, project);
Collection<BranchDto> branches = dbClient.branchDao().selectByComponent(dbSession, project).stream()
- .filter(b -> b.getBranchType() == LONG)
+ .filter(b -> b.getBranchType() == BRANCH)
.collect(toList());
List<NewCodePeriodDto> newCodePeriods = newCodePeriodDao.selectAllByProject(dbSession, project.uuid());
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java
index bb35dec2f02..5deddae5f89 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/SetAction.java
@@ -207,8 +207,8 @@ public class SetAction implements NewCodePeriodsWsAction {
BranchDto branchDto = dbClient.branchDao().selectByUuid(dbSession, project.uuid())
.orElseThrow(() -> new NotFoundException(format("Branch '%s' is not found", branchKey)));
- checkArgument(branchDto.getBranchType() == BranchType.LONG,
- "Not a long-living branch: '%s'", branchKey);
+ checkArgument(branchDto.getBranchType() == BranchType.BRANCH,
+ "Not a branch: '%s'", branchKey);
return project;
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java
index 0460b4d7535..03c192343ec 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ShowAction.java
@@ -172,8 +172,8 @@ public class ShowAction implements NewCodePeriodsWsAction {
BranchDto branchDto = dbClient.branchDao().selectByUuid(dbSession, project.uuid())
.orElseThrow(() -> new NotFoundException(format("Branch '%s' is not found", branchKey)));
- checkArgument(branchDto.getBranchType() == BranchType.LONG,
- "Not a long-living branch: '%s'", branchKey);
+ checkArgument(branchDto.getBranchType() == BranchType.BRANCH,
+ "Not a branch: '%s'", branchKey);
return project;
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/UnsetAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/UnsetAction.java
index 74338892126..e6fd4b309e2 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/UnsetAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/UnsetAction.java
@@ -126,8 +126,8 @@ public class UnsetAction implements NewCodePeriodsWsAction {
BranchDto branchDto = dbClient.branchDao().selectByUuid(dbSession, project.uuid())
.orElseThrow(() -> new NotFoundException(format("Branch '%s' is not found", branchKey)));
- checkArgument(branchDto.getBranchType() == BranchType.LONG,
- "Not a long-living branch: '%s'", branchKey);
+ checkArgument(branchDto.getBranchType() == BranchType.BRANCH,
+ "Not a branch: '%s'", branchKey);
return project;
}
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/branch/ws/list-example.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/branch/ws/list-example.json
index a9a0c47d8af..252fef00796 100644
--- a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/branch/ws/list-example.json
+++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/branch/ws/list-example.json
@@ -3,7 +3,7 @@
{
"name": "feature/foo",
"isMain": false,
- "type": "LONG",
+ "type": "BRANCH",
"status": {
"qualityGateStatus": "OK"
},
@@ -13,7 +13,7 @@
{
"name": "master",
"isMain": true,
- "type": "LONG",
+ "type": "BRANCH",
"status": {
"qualityGateStatus": "ERROR"
},
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java
index bb958a69c7d..a2127dacd3b 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/MeasureActionTest.java
@@ -64,7 +64,7 @@ import static org.sonar.api.measures.Metric.ValueType.PERCENT;
import static org.sonar.api.measures.Metric.ValueType.RATING;
import static org.sonar.api.measures.Metric.ValueType.WORK_DUR;
import static org.sonar.api.web.UserRole.USER;
-import static org.sonar.db.component.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.server.badge.ws.SvgGenerator.Color.DEFAULT;
import static org.sonar.server.badge.ws.SvgGenerator.Color.QUALITY_GATE_ERROR;
import static org.sonar.server.badge.ws.SvgGenerator.Color.QUALITY_GATE_OK;
@@ -220,12 +220,12 @@ public class MeasureActionTest {
userSession.registerComponents(project);
MetricDto metric = db.measures().insertMetric(m -> m.setKey(BUGS_KEY).setValueType(INT.name()));
db.measures().insertLiveMeasure(project, metric, m -> m.setValue(5_000d));
- ComponentDto longBranch = db.components().insertProjectBranch(project, b -> b.setBranchType(LONG));
- db.measures().insertLiveMeasure(longBranch, metric, m -> m.setValue(10_000d));
+ ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH));
+ db.measures().insertLiveMeasure(branch, metric, m -> m.setValue(10_000d));
TestResponse response = ws.newRequest()
- .setParam("project", longBranch.getKey())
- .setParam("branch", longBranch.getBranch())
+ .setParam("project", branch.getKey())
+ .setParam("branch", branch.getBranch())
.setParam("metric", metric.getKey())
.execute();
@@ -234,8 +234,8 @@ public class MeasureActionTest {
// Second call with If-None-Match must return 304
response = ws.newRequest()
.setHeader("If-None-Match", response.getHeader("ETag"))
- .setParam("project", longBranch.getKey())
- .setParam("branch", longBranch.getBranch())
+ .setParam("project", branch.getKey())
+ .setParam("branch", branch.getBranch())
.setParam("metric", metric.getKey())
.execute();
@@ -277,7 +277,7 @@ public class MeasureActionTest {
@Test
public void return_error_if_branch_does_not_exist() throws ParseException {
ComponentDto project = db.components().insertMainBranch();
- ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.LONG));
+ ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.BRANCH));
userSession.addProjectPermission(USER, project);
MetricDto metric = db.measures().insertMetric(m -> m.setKey(BUGS_KEY));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java
index b4589e9fa58..95dc13cf633 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/badge/ws/QualityGateActionTest.java
@@ -50,7 +50,7 @@ import static org.sonar.api.measures.Metric.Level.ERROR;
import static org.sonar.api.measures.Metric.Level.OK;
import static org.sonar.api.measures.Metric.ValueType.LEVEL;
import static org.sonar.api.web.UserRole.USER;
-import static org.sonar.db.component.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
public class QualityGateActionTest {
@@ -145,17 +145,17 @@ public class QualityGateActionTest {
}
@Test
- public void quality_gate_on_long_living_branch() {
+ public void quality_gate_on_branch() {
ComponentDto project = db.components().insertMainBranch(p -> p.setPrivate(false));
userSession.registerComponents(project);
MetricDto metric = createQualityGateMetric();
db.measures().insertLiveMeasure(project, metric, m -> m.setData(OK.name()));
- ComponentDto longBranch = db.components().insertProjectBranch(project, b -> b.setBranchType(LONG));
- db.measures().insertLiveMeasure(longBranch, metric, m -> m.setData(ERROR.name()));
+ ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH));
+ db.measures().insertLiveMeasure(branch, metric, m -> m.setData(ERROR.name()));
TestResponse response = ws.newRequest()
- .setParam("project", longBranch.getKey())
- .setParam("branch", longBranch.getBranch())
+ .setParam("project", branch.getKey())
+ .setParam("branch", branch.getBranch())
.execute();
checkResponse(response, ERROR);
@@ -227,7 +227,7 @@ public class QualityGateActionTest {
public void return_error_on_not_existing_branch() throws ParseException {
ComponentDto project = db.components().insertMainBranch(p -> p.setPrivate(false));
userSession.registerComponents(project);
- ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(LONG));
+ ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH));
TestResponse response = ws.newRequest()
.setParam("project", branch.getKey())
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/pr/ws/ListActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/pr/ws/ListActionTest.java
index 6c4027f55f5..7edb9261848 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/pr/ws/ListActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/branch/pr/ws/ListActionTest.java
@@ -68,7 +68,7 @@ import static org.sonar.api.utils.DateUtils.dateToLong;
import static org.sonar.api.utils.DateUtils.parseDateTime;
import static org.sonar.api.web.UserRole.CODEVIEWER;
import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION;
-import static org.sonar.db.component.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.db.component.BranchType.PULL_REQUEST;
import static org.sonar.db.component.SnapshotTesting.newAnalysis;
import static org.sonar.server.branch.pr.ws.PullRequestsWsParameters.PARAM_PROJECT;
@@ -113,11 +113,11 @@ public class ListActionTest {
@Test
public void json_example() {
ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("sonarqube"));
- ComponentDto longLivingBranch = db.components().insertProjectBranch(project, b -> b.setKey("feature/foo").setBranchType(LONG));
+ ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("feature/foo").setBranchType(BRANCH));
ComponentDto pullRequest = db.components().insertProjectBranch(project,
b -> b.setKey("123")
.setBranchType(PULL_REQUEST)
- .setMergeBranchUuid(longLivingBranch.uuid())
+ .setMergeBranchUuid(branch.uuid())
.setPullRequestData(DbProjectBranches.PullRequestData.newBuilder()
.setBranch("feature/bar")
.setTitle("Add feature X")
@@ -176,7 +176,7 @@ public class ListActionTest {
ComponentDto project = db.components().insertMainBranch();
userSession.logIn().addProjectPermission(UserRole.USER, project);
ComponentDto longLivingBranch = db.components().insertProjectBranch(project,
- b -> b.setKey("long").setBranchType(BranchType.LONG));
+ b -> b.setKey("long").setBranchType(BranchType.BRANCH));
ComponentDto pullRequestOnLong = db.components().insertProjectBranch(project,
b -> b.setKey("pull_request_on_long")
.setBranchType(PULL_REQUEST)
@@ -243,7 +243,7 @@ public class ListActionTest {
public void status_on_pull_requests() {
ComponentDto project = db.components().insertMainBranch();
userSession.logIn().addProjectPermission(UserRole.USER, project);
- ComponentDto longLivingBranch = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.LONG));
+ ComponentDto longLivingBranch = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.BRANCH));
ComponentDto pullRequest = db.components().insertProjectBranch(project,
b -> b.setKey("pr-123")
.setBranchType(PULL_REQUEST)
@@ -276,7 +276,7 @@ public class ListActionTest {
public void status_on_pull_request_with_no_issue() {
ComponentDto project = db.components().insertMainBranch();
userSession.logIn().addProjectPermission(UserRole.USER, project);
- ComponentDto longLivingBranch = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.LONG));
+ ComponentDto longLivingBranch = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.BRANCH));
db.components().insertProjectBranch(project,
b -> b.setKey("pr-123")
.setBranchType(PULL_REQUEST)
@@ -309,7 +309,7 @@ public class ListActionTest {
.setMergeBranchUuid(project.uuid())
.setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch("feature/pr1").build()));
- ComponentDto longLivingBranch2 = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.LONG));
+ ComponentDto longLivingBranch2 = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.BRANCH));
ComponentDto pullRequest2 = db.components().insertProjectBranch(project,
b -> b.setKey("pr2")
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 fd7ff55cf8e..05602ca09af 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
@@ -36,11 +36,9 @@ import org.sonar.db.rule.RuleDefinitionDto;
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.es.EsTester;
import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.issue.index.IssueIndex;
import org.sonar.server.issue.index.IssueIndexer;
import org.sonar.server.issue.index.IssueIteratorFactory;
import org.sonar.server.permission.index.PermissionIndexerTester;
-import org.sonar.server.permission.index.WebAuthorizationTypeSupport;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.Common.BranchType;
@@ -60,7 +58,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.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.db.component.SnapshotTesting.newAnalysis;
import static org.sonar.test.JsonAssert.assertJson;
@@ -77,12 +75,11 @@ public class ListActionTest {
private ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(PROJECT);
private IssueIndexer issueIndexer = new IssueIndexer(es.client(), db.getDbClient(), new IssueIteratorFactory(db.getDbClient()));
- private IssueIndex issueIndex = new IssueIndex(es.client(), System2.INSTANCE, userSession, new WebAuthorizationTypeSupport(userSession));
private PermissionIndexerTester permissionIndexerTester = new PermissionIndexerTester(es, issueIndexer);
private MetricDto qualityGateStatus;
- public WsActionTester ws = new WsActionTester(new ListAction(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), resourceTypes), issueIndex));
+ public WsActionTester ws = new WsActionTester(new ListAction(db.getDbClient(), userSession, new ComponentFinder(db.getDbClient(), resourceTypes)));
@Before
public void setUp() throws Exception {
@@ -107,7 +104,7 @@ public class ListActionTest {
db.measures().insertLiveMeasure(project, qualityGateStatus, m -> m.setData("ERROR"));
ComponentDto branch = db.components()
- .insertProjectBranch(project, b -> b.setKey("feature/foo").setBranchType(LONG));
+ .insertProjectBranch(project, b -> b.setKey("feature/foo").setBranchType(BRANCH));
db.getDbClient().snapshotDao().insert(db.getSession(),
newAnalysis(branch).setLast(true).setCreatedAt(parseDateTime("2017-04-03T13:37:00+0100").getTime()));
db.measures().insertLiveMeasure(branch, qualityGateStatus, m -> m.setData("OK"));
@@ -136,7 +133,7 @@ public class ListActionTest {
db.measures().insertLiveMeasure(project, qualityGateStatus, m -> m.setData("ERROR"));
ComponentDto branch = db.components()
- .insertProjectBranch(project, b -> b.setKey("feature/foo").setBranchType(LONG));
+ .insertProjectBranch(project, b -> b.setKey("feature/foo").setBranchType(BRANCH));
db.getDbClient().snapshotDao().insert(db.getSession(),
newAnalysis(branch).setLast(true).setCreatedAt(parseDateTime("2017-04-03T13:37:00+0100").getTime()));
db.measures().insertLiveMeasure(branch, qualityGateStatus, m -> m.setData("OK"));
@@ -166,7 +163,7 @@ public class ListActionTest {
assertThat(response.getBranchesList())
.extracting(Branch::getName, Branch::getIsMain, Branch::getType)
- .containsExactlyInAnyOrder(tuple("master", true, BranchType.LONG));
+ .containsExactlyInAnyOrder(tuple("master", true, BranchType.BRANCH));
}
@Test
@@ -181,7 +178,7 @@ public class ListActionTest {
assertThat(response.getBranchesList())
.extracting(Branch::getName, Branch::getIsMain, Branch::getType)
- .containsExactlyInAnyOrder(tuple("head", true, BranchType.LONG));
+ .containsExactlyInAnyOrder(tuple("head", true, BranchType.BRANCH));
}
@Test
@@ -211,16 +208,16 @@ public class ListActionTest {
assertThat(response.getBranchesList())
.extracting(Branch::getName, Branch::getType)
.containsExactlyInAnyOrder(
- tuple("master", BranchType.LONG),
- tuple("feature/foo", BranchType.LONG),
- tuple("feature/bar", BranchType.LONG));
+ tuple("master", BranchType.BRANCH),
+ tuple("feature/foo", BranchType.BRANCH),
+ tuple("feature/bar", BranchType.BRANCH));
}
@Test
public void status_on_branch() {
ComponentDto project = db.components().insertMainBranch();
userSession.logIn().addProjectPermission(USER, project);
- ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(org.sonar.db.component.BranchType.LONG));
+ ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(org.sonar.db.component.BranchType.BRANCH));
db.measures().insertLiveMeasure(branch, qualityGateStatus, m -> m.setData("OK"));
ListWsResponse response = ws.newRequest()
@@ -238,7 +235,7 @@ public class ListActionTest {
ComponentDto project = db.components().insertMainBranch();
userSession.logIn().addProjectPermission(USER, project);
- ComponentDto branch2 = db.components().insertProjectBranch(project, b -> b.setBranchType(org.sonar.db.component.BranchType.LONG));
+ ComponentDto branch2 = db.components().insertProjectBranch(project, b -> b.setBranchType(org.sonar.db.component.BranchType.BRANCH));
db.getDbClient().snapshotDao().insert(db.getSession(),
newAnalysis(branch2).setCreatedAt(lastAnalysisBranch));
db.commit();
@@ -253,8 +250,8 @@ public class ListActionTest {
.extracting(ProjectBranches.Branch::getType, ProjectBranches.Branch::hasAnalysisDate,
b -> "".equals(b.getAnalysisDate()) ? null : dateToLong(parseDateTime(b.getAnalysisDate())))
.containsExactlyInAnyOrder(
- tuple(BranchType.LONG, false, null),
- tuple(BranchType.LONG, true, lastAnalysisBranch));
+ tuple(BranchType.BRANCH, false, null),
+ tuple(BranchType.BRANCH, true, lastAnalysisBranch));
}
@Test
@@ -271,8 +268,8 @@ public class ListActionTest {
assertThat(response.getBranchesList())
.extracting(Branch::getName, Branch::getType)
.containsExactlyInAnyOrder(
- tuple("feature/foo", BranchType.LONG),
- tuple("feature/bar", BranchType.LONG));
+ tuple("feature/foo", BranchType.BRANCH),
+ tuple("feature/bar", BranchType.BRANCH));
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/BranchReportSubmitterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/BranchReportSubmitterTest.java
index 9768b0cb0fe..248443423f6 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/BranchReportSubmitterTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ce/queue/BranchReportSubmitterTest.java
@@ -281,7 +281,7 @@ public class BranchReportSubmitterTest {
when(mainComponentKey.getMainBranchComponentKey()).thenReturn(mainComponentKey);
BranchSupport.ComponentKey componentKey = mockComponentKey(branch.getKey(), branch.getDbKey());
- when(componentKey.getBranch()).thenReturn(Optional.ofNullable(branch).map(b -> new BranchSupport.Branch(b.name(), BranchType.LONG)));
+ when(componentKey.getBranch()).thenReturn(Optional.ofNullable(branch).map(b -> new BranchSupport.Branch(b.name(), BranchType.BRANCH)));
when(componentKey.getMainBranchComponentKey()).thenReturn(mainComponentKey);
return componentKey;
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 c8edc8156fa..96621c0d255 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
@@ -103,7 +103,7 @@ public class ComponentUpdaterTest {
assertThat(branch).isPresent();
assertThat(branch.get().getKey()).isEqualTo(BranchDto.DEFAULT_MAIN_BRANCH_NAME);
assertThat(branch.get().getMergeBranchUuid()).isNull();
- assertThat(branch.get().getBranchType()).isEqualTo(BranchType.LONG);
+ assertThat(branch.get().getBranchType()).isEqualTo(BranchType.BRANCH);
assertThat(branch.get().getUuid()).isEqualTo(returned.uuid());
assertThat(branch.get().getProjectUuid()).isEqualTo(returned.uuid());
}
@@ -176,7 +176,7 @@ public class ComponentUpdaterTest {
assertThat(branch).isPresent();
assertThat(branch.get().getKey()).isEqualTo(BranchDto.DEFAULT_MAIN_BRANCH_NAME);
assertThat(branch.get().getMergeBranchUuid()).isNull();
- assertThat(branch.get().getBranchType()).isEqualTo(BranchType.LONG);
+ assertThat(branch.get().getBranchType()).isEqualTo(BranchType.BRANCH);
assertThat(branch.get().getUuid()).isEqualTo(returned.uuid());
assertThat(branch.get().getProjectUuid()).isEqualTo(returned.uuid());
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java
index 0ceba09e481..7fede101ced 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java
@@ -366,11 +366,11 @@ public class BulkChangeActionTest {
}
@Test
- public void send_notification_on_long_branch() {
+ public void send_notification_on_branch() {
UserDto user = db.users().insertUser();
userSession.logIn(user);
ComponentDto project = db.components().insertMainBranch();
- ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("feature").setBranchType(BranchType.LONG));
+ ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("feature").setBranchType(BranchType.BRANCH));
ComponentDto fileOnBranch = db.components().insertComponent(newFileDto(branch));
addUserProjectPermissions(user, project, USER, ISSUE_ADMIN);
RuleDefinitionDto rule = db.rules().insert();
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java
index ed5ffae90c8..c1aebaf3780 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/IssueUpdaterTest.java
@@ -62,7 +62,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import static org.sonar.api.issue.Issue.RESOLUTION_FIXED;
import static org.sonar.api.rule.Severity.BLOCKER;
import static org.sonar.api.rule.Severity.MAJOR;
-import static org.sonar.db.component.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.db.component.ComponentTesting.newFileDto;
import static org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.projectBranchOf;
import static org.sonar.server.issue.notification.IssuesChangesNotificationBuilderTesting.projectOf;
@@ -174,10 +174,10 @@ public class IssueUpdaterTest {
}
@Test
- public void verify_notification_on_long_branch() {
+ public void verify_notification_on_branch() {
RuleDto rule = db.rules().insertRule();
ComponentDto project = db.components().insertMainBranch();
- ComponentDto branch = db.components().insertProjectBranch(project, t -> t.setBranchType(LONG));
+ ComponentDto branch = db.components().insertProjectBranch(project, t -> t.setBranchType(BRANCH));
ComponentDto file = db.components().insertComponent(newFileDto(branch));
RuleType randomTypeExceptHotspot = RuleType.values()[nextInt(RuleType.values().length - 1)];
DefaultIssue issue = db.issues().insertIssue(IssueTesting.newIssue(rule.getDefinition(), branch, file)
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 33e9deff62a..0edc1c7d2f2 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
@@ -65,7 +65,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.BranchType.LONG;
+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;
import static org.sonar.db.component.ComponentTesting.newFileDto;
@@ -656,7 +656,7 @@ public class SearchActionComponentsTest {
ComponentDto file = db.components().insertComponent(newFileDto(project));
IssueDto issue = db.issues().insertIssue(newIssue(rule, project, file));
- ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(LONG));
+ ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH));
ComponentDto branchFile = db.components().insertComponent(newFileDto(branch));
IssueDto branchIssue = db.issues().insertIssue(newIssue(rule, branch, branchFile));
allowAnyoneOnProjects(project);
@@ -693,7 +693,7 @@ public class SearchActionComponentsTest {
ComponentDto project = db.components().insertPrivateProject();
ComponentDto projectFile = db.components().insertComponent(newFileDto(project));
IssueDto projectIssue = db.issues().insertIssue(newIssue(rule, project, projectFile));
- ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(LONG));
+ ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH));
ComponentDto branchFile = db.components().insertComponent(newFileDto(branch));
IssueDto branchIssue = db.issues().insertIssue(newIssue(rule, branch, branchFile));
allowAnyoneOnProjects(project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/live/LiveQualityGateComputerImplTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/live/LiveQualityGateComputerImplTest.java
index 5aaeae0796f..e220365d9ab 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/live/LiveQualityGateComputerImplTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/live/LiveQualityGateComputerImplTest.java
@@ -87,10 +87,10 @@ public class LiveQualityGateComputerImplTest {
}
@Test
- public void loadQualityGate_on_long_branch_returns_organization_default_gate() {
+ public void loadQualityGate_on_branch_returns_organization_default_gate() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertPublicProject(organization);
- BranchDto branch = newBranchDto(project).setBranchType(BranchType.LONG);
+ BranchDto branch = newBranchDto(project).setBranchType(BranchType.BRANCH);
db.components().insertProjectBranch(project, branch);
MetricDto metric = db.measures().insertMetric();
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 d10fb78e535..5e8b889ddb4 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
@@ -103,10 +103,10 @@ public class ListActionTest {
}
@Test
- public void list_only_LLB() {
+ public void list_only_branches() {
ComponentDto project = componentDb.insertMainBranch();
- createBranches(project, 5, BranchType.LONG);
+ createBranches(project, 5, BranchType.BRANCH);
createBranches(project, 3, BranchType.PULL_REQUEST);
logInAsProjectAdministrator(project);
@@ -118,7 +118,7 @@ public class ListActionTest {
assertThat(response).isNotNull();
assertThat(response.getNewCodePeriodsCount()).isEqualTo(6);
assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
- .contains("master", "LONG_0", "LONG_1", "LONG_2", "LONG_3", "LONG_4");
+ .contains("master", "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
//check if global default is set
assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
@@ -130,7 +130,7 @@ public class ListActionTest {
ComponentDto project = componentDb.insertMainBranch();
tester.insert(new NewCodePeriodDto().setType(NewCodePeriodType.SPECIFIC_ANALYSIS).setValue("uuid"));
- createBranches(project, 5, BranchType.LONG);
+ createBranches(project, 5, BranchType.BRANCH);
logInAsProjectAdministrator(project);
@@ -141,7 +141,7 @@ public class ListActionTest {
assertThat(response).isNotNull();
assertThat(response.getNewCodePeriodsCount()).isEqualTo(6);
assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
- .contains("master", "LONG_0", "LONG_1", "LONG_2", "LONG_3", "LONG_4");
+ .contains("master", "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
//check if global default is set
assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
@@ -164,7 +164,7 @@ public class ListActionTest {
.setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
.setValue("project_uuid"));
- createBranches(projectWithOwnSettings, 5, BranchType.LONG);
+ createBranches(projectWithOwnSettings, 5, BranchType.BRANCH);
logInAsProjectAdministrator(projectWithOwnSettings, projectWithGlobalSettings);
@@ -176,7 +176,7 @@ public class ListActionTest {
assertThat(response).isNotNull();
assertThat(response.getNewCodePeriodsCount()).isEqualTo(6);
assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
- .contains("master", "LONG_0", "LONG_1", "LONG_2", "LONG_3", "LONG_4");
+ .contains("master", "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
//check if project setting is set
assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/DeleteActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/DeleteActionTest.java
index ba123e555d6..dac90d6591f 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/DeleteActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/DeleteActionTest.java
@@ -41,7 +41,7 @@ import org.sonar.server.ws.WsActionTester;
import static com.google.common.collect.Lists.newArrayList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.tuple;
-import static org.sonar.db.component.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.db.component.ComponentTesting.newBranchDto;
import static org.sonar.db.component.SnapshotDto.STATUS_PROCESSED;
import static org.sonar.db.component.SnapshotDto.STATUS_UNPROCESSED;
@@ -101,7 +101,7 @@ public class DeleteActionTest {
String analysisUuid = RandomStringUtils.randomAlphabetic(12);
ComponentDto project = db.components().insertPrivateProject();
SnapshotDto analysis = db.components().insertSnapshot(newAnalysis(project).setUuid(analysisUuid).setLast(false));
- BranchDto branch = newBranchDto(project, LONG);
+ BranchDto branch = newBranchDto(project, BRANCH);
db.getDbClient().branchDao().insert(db.getSession(), branch);
db.newCodePeriods().insert(new NewCodePeriodDto()
.setProjectUuid(project.uuid())
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java
index 0feb9ea79f5..3d34e71d317 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java
@@ -72,7 +72,7 @@ import static org.assertj.core.api.Assertions.tuple;
import static org.sonar.api.utils.DateUtils.formatDate;
import static org.sonar.api.utils.DateUtils.formatDateTime;
import static org.sonar.api.utils.DateUtils.parseDateTime;
-import static org.sonar.db.component.BranchType.LONG;
+import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.db.component.ComponentTesting.newBranchDto;
import static org.sonar.db.component.ComponentTesting.newFileDto;
import static org.sonar.db.component.SnapshotTesting.newAnalysis;
@@ -146,7 +146,7 @@ public class SearchActionTest {
.setCreatedAt(parseDateTime("2015-11-11T10:00:00+0100").getTime())
.setProjectVersion("1.2")
.setBuildString("1.2.0.321"));
- BranchDto branchDto = newBranchDto(project, LONG);
+ BranchDto branchDto = newBranchDto(project, BRANCH);
db.getDbClient().branchDao().insert(db.getSession(), branchDto);
db.newCodePeriods().insert(new NewCodePeriodDto()
.setProjectUuid(project.uuid())
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 63a5d294579..9925c080044 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
@@ -79,7 +79,7 @@ public class SetBaselineActionTest {
public void set_baseline_on_main_branch(@Nullable String branchName) {
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
BranchDto branch = new BranchDto()
- .setBranchType(BranchType.LONG)
+ .setBranchType(BranchType.BRANCH)
.setProjectUuid(project.uuid())
.setUuid(project.uuid())
.setKey("master");
@@ -107,7 +107,7 @@ public class SetBaselineActionTest {
@Test
public void set_baseline_on_long_living_branch() {
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
- BranchDto branch = ComponentTesting.newBranchDto(project.projectUuid(), BranchType.LONG);
+ BranchDto branch = ComponentTesting.newBranchDto(project.projectUuid(), BranchType.BRANCH);
db.components().insertProjectBranch(project, branch);
ComponentDto branchComponentDto = ComponentTesting.newProjectBranch(project, branch);
SnapshotDto analysis = db.components().insertSnapshot(branchComponentDto);
@@ -123,7 +123,7 @@ public class SetBaselineActionTest {
@Test
public void fail_when_user_is_not_admin() {
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
- BranchDto branch = ComponentTesting.newBranchDto(project.projectUuid(), BranchType.LONG);
+ BranchDto branch = ComponentTesting.newBranchDto(project.projectUuid(), BranchType.BRANCH);
db.components().insertProjectBranch(project, branch);
ComponentDto branchComponentDto = ComponentTesting.newProjectBranch(project, branch);
SnapshotDto analysis = db.components().insertSnapshot(branchComponentDto);
@@ -162,7 +162,7 @@ public class SetBaselineActionTest {
@UseDataProvider("nonexistentParamsAndFailureMessage")
public void fail_with_IAE_when_required_param_nonexistent(Map<String, String> nonexistentParams, String regex) {
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
- BranchDto branch = ComponentTesting.newBranchDto(project.projectUuid(), BranchType.LONG);
+ BranchDto branch = ComponentTesting.newBranchDto(project.projectUuid(), BranchType.BRANCH);
db.components().insertProjectBranch(project, branch);
ComponentDto branchComponentDto = ComponentTesting.newProjectBranch(project, branch);
SnapshotDto analysis = db.components().insertSnapshot(branchComponentDto);
@@ -194,14 +194,14 @@ public class SetBaselineActionTest {
@Test
public void fail_when_branch_does_not_belong_to_project() {
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
- BranchDto branch = ComponentTesting.newBranchDto(project.projectUuid(), BranchType.LONG);
+ BranchDto branch = ComponentTesting.newBranchDto(project.projectUuid(), BranchType.BRANCH);
db.components().insertProjectBranch(project, branch);
ComponentDto branchComponentDto = ComponentTesting.newProjectBranch(project, branch);
SnapshotDto analysis = db.components().insertSnapshot(branchComponentDto);
logInAsProjectAdministrator(project);
ComponentDto otherProject = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
- BranchDto otherBranch = ComponentTesting.newBranchDto(otherProject.projectUuid(), BranchType.LONG);
+ BranchDto otherBranch = ComponentTesting.newBranchDto(otherProject.projectUuid(), BranchType.BRANCH);
db.components().insertProjectBranch(otherProject, otherBranch);
ComponentTesting.newProjectBranch(otherProject, otherBranch);
@@ -215,7 +215,7 @@ public class SetBaselineActionTest {
public void fail_when_analysis_does_not_belong_to_main_branch_of_project() {
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
BranchDto branch = new BranchDto()
- .setBranchType(BranchType.LONG)
+ .setBranchType(BranchType.BRANCH)
.setProjectUuid(project.uuid())
.setUuid(project.uuid())
.setKey("master");
@@ -236,7 +236,7 @@ public class SetBaselineActionTest {
@Test
public void fail_when_analysis_does_not_belong_to_non_main_branch_of_project() {
ComponentDto project = ComponentTesting.newPrivateProjectDto(db.organizations().insert());
- BranchDto branch = ComponentTesting.newBranchDto(project.projectUuid(), BranchType.LONG);
+ BranchDto branch = ComponentTesting.newBranchDto(project.projectUuid(), BranchType.BRANCH);
db.components().insertProjectBranch(project, branch);
logInAsProjectAdministrator(project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/UnsetBaselineActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/UnsetBaselineActionTest.java
index 9270eabfd4f..0ca70cb77f3 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/UnsetBaselineActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projectanalysis/ws/UnsetBaselineActionTest.java
@@ -229,7 +229,7 @@ public class UnsetBaselineActionTest {
@Test
public void fail_with_NotFoundException_when_branch_is_pull_request() {
ComponentDto project = newPrivateProjectDto(db.organizations().insert());
- BranchDto branch = newBranchDto(project.projectUuid(), BranchType.LONG);
+ BranchDto branch = newBranchDto(project.projectUuid(), BranchType.BRANCH);
db.components().insertProjectBranch(project, branch);
ComponentDto pullRequest = newProjectBranch(project, branch);
logInAsProjectAdministrator(project);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java
index 6dd5b4ae903..34c6843bbda 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java
@@ -268,19 +268,19 @@ public class ComponentActionTest {
}
@Test
- public void quality_gate_for_a_long_living_branch() {
+ public void quality_gate_for_a_branch() {
OrganizationDto organization = db.organizations().insert(o -> o.setKey("my-org"));
db.qualityGates().createDefaultQualityGate(organization);
ComponentDto project = db.components().insertPrivateProject(organization);
- ComponentDto longLivingBranch = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.LONG));
+ ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.BRANCH));
QualityGateDto qualityGateDto = db.qualityGates().insertQualityGate(organization, qg -> qg.setName("Sonar way"));
db.qualityGates().associateProjectToQualityGate(project, qualityGateDto);
userSession.addProjectPermission(UserRole.USER, project);
init();
String json = ws.newRequest()
- .setParam("componentKey", longLivingBranch.getKey())
- .setParam("branch", longLivingBranch.getBranch())
+ .setParam("componentKey", branch.getKey())
+ .setParam("branch", branch.getBranch())
.execute()
.getInput();
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java
index e210aae821a..bb2eb9cc85a 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java
@@ -412,7 +412,7 @@ public class PostProjectAnalysisTaskTester {
public static final class BranchBuilder {
private boolean isMain = true;
private String name = null;
- private Branch.Type type = Branch.Type.LONG;
+ private Branch.Type type = Branch.Type.BRANCH;
private BranchBuilder() {
// prevents instantiation outside PostProjectAnalysisTaskTester
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTesterTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTesterTest.java
index e0d8d3cb093..6b95538150f 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTesterTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTesterTest.java
@@ -33,6 +33,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.sonar.api.ce.posttask.Branch.Type.BRANCH;
public class PostProjectAnalysisTaskTesterTest {
@Rule
@@ -173,7 +174,7 @@ public class PostProjectAnalysisTaskTesterTest {
PostProjectAnalysisTask projectAnalysisTask = mock(PostProjectAnalysisTask.class);
doAnswer(i -> {
PostProjectAnalysisTask.Context context = i.getArgument(0);
- expected.forEach((k,v) -> context.getLogStatistics().add(k, v));
+ expected.forEach((k, v) -> context.getLogStatistics().add(k, v));
return null;
}).when(projectAnalysisTask).finished(any(PostProjectAnalysisTask.Context.class));
PostProjectAnalysisTaskTester underTest = PostProjectAnalysisTaskTester.of(projectAnalysisTask);
@@ -184,6 +185,13 @@ public class PostProjectAnalysisTaskTesterTest {
assertThat(underTest.getLogStatistics()).isEqualTo(expected);
}
+ @Test
+ public void branch_builder_builds_branch_of_type_branch_by_default() {
+ Branch branch = PostProjectAnalysisTaskTester.newBranchBuilder().build();
+
+ assertThat(branch.getType()).isEqualTo(BRANCH);
+ }
+
private static class CaptorPostProjectAnalysisTask implements PostProjectAnalysisTask {
private ProjectAnalysis projectAnalysis;