aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce-task-projectanalysis
diff options
context:
space:
mode:
authorLukasz Jarocki <lukasz.jarocki@sonarsource.com>2022-12-15 15:20:40 +0100
committersonartech <sonartech@sonarsource.com>2022-12-15 20:03:33 +0000
commitf0582195b40b656b525d7d0df55120f899b21693 (patch)
tree17732b64859daa336fe7924e9fa1e759512afec2 /server/sonar-ce-task-projectanalysis
parentfc7657598b9f46a99cb21dc891f75ad20c8a8528 (diff)
downloadsonarqube-f0582195b40b656b525d7d0df55120f899b21693.tar.gz
sonarqube-f0582195b40b656b525d7d0df55120f899b21693.zip
SONAR-17613 changing default branch for applications to follow the setting
Diffstat (limited to 'server/sonar-ce-task-projectanalysis')
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java6
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchLoaderTest.java6
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/DefaultBranchImplTest.java6
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStepTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ReportPersistComponentsStepTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepTest.java2
11 files changed, 24 insertions, 24 deletions
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 6362ab8ca68..21e4fa952f1 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisMetadataHolderImplTest.java
@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.sonar.core.platform.EditionProvider.Edition;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
@RunWith(DataProviderRunner.class)
@@ -211,7 +211,7 @@ public class AnalysisMetadataHolderImplTest {
public void set_branch() {
AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
- underTest.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
+ underTest.setBranch(new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME));
assertThat(underTest.getBranch().getName()).isEqualTo("main");
}
@@ -226,7 +226,7 @@ public class AnalysisMetadataHolderImplTest {
@Test
public void setBranch_throws_ISE_when_called_twice() {
AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl(editionProvider);
- underTest.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
+ underTest.setBranch(new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME));
assertThatThrownBy(() -> underTest.setBranch(new DefaultBranchImpl("main")))
.isInstanceOf(IllegalStateException.class)
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchLoaderTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchLoaderTest.java
index 5f1dc0ab1ad..5dbec9ffa4e 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchLoaderTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/BranchLoaderTest.java
@@ -33,7 +33,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
public class BranchLoaderTest {
@@ -56,7 +56,7 @@ public class BranchLoaderTest {
ScannerReport.Metadata metadata = ScannerReport.Metadata.newBuilder()
.build();
DefaultBranchNameResolver branchNameResolver = mock(DefaultBranchNameResolver.class);
- when(branchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+ when(branchNameResolver.getEffectiveMainBranchName()).thenReturn(DEFAULT_MAIN_BRANCH_NAME);
new BranchLoader(metadataHolder, branchNameResolver).load(metadata);
@@ -64,7 +64,7 @@ public class BranchLoaderTest {
Branch branch = metadataHolder.getBranch();
assertThat(branch.isMain()).isTrue();
- assertThat(branch.getName()).isEqualTo(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+ assertThat(branch.getName()).isEqualTo(DEFAULT_MAIN_BRANCH_NAME);
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java
index c2ff3c08ab7..3343f266d40 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/component/ComponentUuidFactoryWithMigrationTest.java
@@ -32,10 +32,10 @@ import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.ComponentTesting;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
public class ComponentUuidFactoryWithMigrationTest {
- private final Branch mainBranch = new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+ private final Branch mainBranch = new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME);
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
private Function<String, String> pathToKey = path -> path != null ? "project:" + path : "project";
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 e8bfcd84658..e8ad33d45db 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
@@ -25,7 +25,7 @@ import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
public class DefaultBranchImplTest {
private static final String PROJECT_KEY = "P";
@@ -34,11 +34,11 @@ public class DefaultBranchImplTest {
@Test
public void default_branch_represents_the_project() {
- DefaultBranchImpl branch = new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+ DefaultBranchImpl branch = new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME);
assertThat(branch.isMain()).isTrue();
assertThat(branch.getType()).isEqualTo(BranchType.BRANCH);
- assertThat(branch.getName()).isEqualTo(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+ assertThat(branch.getName()).isEqualTo(DEFAULT_MAIN_BRANCH_NAME);
assertThat(branch.supportsCrossProjectCpd()).isTrue();
assertThat(branch.generateKey(PROJECT_KEY, null)).isEqualTo("P");
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStepTest.java
index 00ab641116e..5de85bf428e 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/BuildComponentTreeStepTest.java
@@ -56,7 +56,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
import static org.sonar.db.component.ComponentTesting.newDirectory;
import static org.sonar.db.component.ComponentTesting.newFileDto;
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
@@ -559,7 +559,7 @@ public class BuildComponentTreeStepTest {
}
private void setAnalysisMetadataHolder(boolean isPr) {
- Branch branch = isPr ? new PrBranch(DEFAULT_PROJECT_MAIN_BRANCH_NAME) : new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+ Branch branch = isPr ? new PrBranch(DEFAULT_MAIN_BRANCH_NAME) : new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME);
analysisMetadataHolder.setRootComponentRef(ROOT_REF)
.setAnalysisDate(ANALYSIS_DATE)
.setBranch(branch)
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java
index 8b7bee5e225..5412282cff6 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/QualityGateEventsStepTest.java
@@ -59,7 +59,7 @@ import static org.mockito.Mockito.when;
import static org.sonar.api.measures.CoreMetrics.ALERT_STATUS_KEY;
import static org.sonar.ce.task.projectanalysis.measure.Measure.Level.ERROR;
import static org.sonar.ce.task.projectanalysis.measure.Measure.Level.OK;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
public class QualityGateEventsStepTest {
private static final String PROJECT_VERSION = randomAlphabetic(19);
@@ -251,7 +251,7 @@ public class QualityGateEventsStepTest {
@Test
public void verify_branch_name_is_not_set_in_notification_when_main() {
- analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
+ analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME));
when(measureRepository.getRawMeasure(PROJECT_COMPONENT, alertStatusMetric))
.thenReturn(of(Measure.newMeasureBuilder().setQualityGateStatus(OK_QUALITY_GATE_STATUS).createNoValue()));
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 f725c5437b2..57acd1de9ae 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
@@ -55,7 +55,7 @@ import static org.sonar.ce.task.projectanalysis.component.Component.Type.DIRECTO
import static org.sonar.ce.task.projectanalysis.component.Component.Type.FILE;
import static org.sonar.ce.task.projectanalysis.component.Component.Type.PROJECT;
import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
import static org.sonar.db.component.ComponentDto.UUID_PATH_OF_ROOT;
import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR;
import static org.sonar.db.component.ComponentTesting.newDirectory;
@@ -622,7 +622,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest {
private ComponentDto prepareProject(Consumer<ComponentDto> populators) {
ComponentDto dto = db.components().insertPrivateProject(populators);
analysisMetadataHolder.setProject(Project.from(dto));
- analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
+ analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME));
return dto;
}
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 d3e15488558..eefe48604f2 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java
@@ -98,7 +98,7 @@ import static org.sonar.api.rules.RuleType.SECURITY_HOTSPOT;
import static org.sonar.ce.task.projectanalysis.component.Component.Type;
import static org.sonar.ce.task.projectanalysis.component.ReportComponent.builder;
import static org.sonar.ce.task.projectanalysis.step.SendIssueNotificationsStep.NOTIF_TYPES;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
import static org.sonar.db.component.BranchType.BRANCH;
import static org.sonar.db.component.BranchType.PULL_REQUEST;
import static org.sonar.db.component.ComponentTesting.newBranchComponent;
@@ -128,7 +128,7 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
.setRoot(PROJECT);
@Rule
public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule()
- .setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME))
+ .setBranch(new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME))
.setAnalysisDate(new Date(ANALYSE_DATE));
@Rule
public TemporaryFolder temp = new TemporaryFolder();
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 a1eaf07b4c2..e0d0a867ae6 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ValidateProjectStepTest.java
@@ -43,14 +43,14 @@ import org.sonar.db.component.SnapshotTesting;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
public class ValidateProjectStepTest {
static long PAST_ANALYSIS_TIME = 1_420_088_400_000L; // 2015-01-01
static long DEFAULT_ANALYSIS_TIME = 1_433_131_200_000L; // 2015-06-01
static final String PROJECT_KEY = "PROJECT_KEY";
- static final Branch DEFAULT_BRANCH = new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+ static final Branch DEFAULT_BRANCH = new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME);
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java
index 9690ef6f783..8f4a8a868df 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/ViewsPersistComponentsStepTest.java
@@ -56,7 +56,7 @@ import static org.mockito.Mockito.when;
import static org.sonar.ce.task.projectanalysis.component.ViewAttributes.Type.APPLICATION;
import static org.sonar.ce.task.projectanalysis.component.ViewAttributes.Type.PORTFOLIO;
import static org.sonar.ce.task.projectanalysis.component.ViewsComponent.builder;
-import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
import static org.sonar.db.component.ComponentTesting.newProjectCopy;
import static org.sonar.db.component.ComponentTesting.newSubPortfolio;
@@ -97,7 +97,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest {
now = DATE_FORMAT.parse("2015-06-02");
when(system2.now()).thenReturn(now.getTime());
- analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
+ analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_MAIN_BRANCH_NAME));
BranchPersister branchPersister = mock(BranchPersister.class);
ProjectPersister projectPersister = mock(ProjectPersister.class);
underTest = new PersistComponentsStep(dbClient, treeRootHolder, system2, disabledComponentsHolder, analysisMetadataHolder, branchPersister, projectPersister);
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepTest.java
index 7e622600604..4ad64c22049 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectexport/branches/ExportBranchesStepTest.java
@@ -127,7 +127,7 @@ public class ExportBranchesStepTest {
assertThat(branches).hasSize(3);
ProjectDump.Branch mainBranch = branches.get(PROJECT_UUID);
assertThat(mainBranch).isNotNull();
- assertThat(mainBranch.getKee()).isEqualTo(BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+ assertThat(mainBranch.getKee()).isEqualTo(BranchDto.DEFAULT_MAIN_BRANCH_NAME);
assertThat(mainBranch.getProjectUuid()).isEqualTo(PROJECT_UUID);
assertThat(mainBranch.getMergeBranchUuid()).isEmpty();
assertThat(mainBranch.getBranchType()).isEqualTo("BRANCH");