aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/test/java/org/sonar/scanner
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2019-10-30 15:55:17 -0500
committerSonarTech <sonartech@sonarsource.com>2019-12-09 20:46:14 +0100
commit1beafb82821b593010abb721a4d20e60a962e098 (patch)
tree5378e8068c65e8f224b3a6dbb11e28a0bff8a2c1 /sonar-scanner-engine/src/test/java/org/sonar/scanner
parent8d8bafa84419df39eedeb8fe95af916c792219fb (diff)
downloadsonarqube-1beafb82821b593010abb721a4d20e60a962e098.tar.gz
sonarqube-1beafb82821b593010abb721a4d20e60a962e098.zip
SONAR-12624 Scanner no longer supports short living branches
Diffstat (limited to 'sonar-scanner-engine/src/test/java/org/sonar/scanner')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/branch/BranchMediumTest.java16
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/log/LogListenerTest.java18
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ChangedLinesPublisherTest.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java35
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java30
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/BranchConfigurationProviderTest.java12
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesTest.java11
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmChangedFilesProviderTest.java14
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorStorageTest.java8
12 files changed, 59 insertions, 97 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java
index be6be13b727..8025b03034b 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java
@@ -380,7 +380,7 @@ public class ScannerMediumTester extends ExternalResource {
private static class FakeBranchConfiguration implements BranchConfiguration {
- private BranchType branchType = BranchType.LONG;
+ private BranchType branchType = BranchType.BRANCH;
private String branchName = null;
private String branchTarget = null;
private String longLivingSonarReferenceBranch = null;
@@ -410,7 +410,7 @@ public class ScannerMediumTester extends ExternalResource {
@Override
public String pullRequestKey() {
- throw new UnsupportedOperationException();
+ return "1'";
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/branch/BranchMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/branch/BranchMediumTest.java
index f376d56999e..d71063345e7 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/branch/BranchMediumTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/branch/BranchMediumTest.java
@@ -75,7 +75,7 @@ public class BranchMediumTest {
}
@Test
- public void should_not_skip_report_for_unchanged_files_in_short_branch() {
+ public void should_not_skip_report_for_unchanged_files_in_pr() {
// sanity check, normally report gets generated
AnalysisResult result = getResult(tester);
final DefaultInputFile file = (DefaultInputFile) result.inputFile(FILE_PATH);
@@ -85,11 +85,11 @@ public class BranchMediumTest {
assertThat(result.getReportReader().hasCoverage(fileId)).isTrue();
assertThat(result.getReportReader().readFileSource(fileId)).isNotNull();
- // file is not skipped for short branches (need coverage, duplications coming soon)
- AnalysisResult result2 = getResult(tester.setBranchType(BranchType.SHORT));
- final DefaultInputFile fileOnShortBranch = (DefaultInputFile) result2.inputFile(FILE_PATH);
- assertThat(result2.getReportComponent(fileOnShortBranch)).isNotNull();
- fileId = fileOnShortBranch.scannerId();
+ // file is not skipped for pull requests (need coverage, duplications coming soon)
+ AnalysisResult result2 = getResult(tester.setBranchType(BranchType.PULL_REQUEST));
+ final DefaultInputFile fileInPr = (DefaultInputFile) result2.inputFile(FILE_PATH);
+ assertThat(result2.getReportComponent(fileInPr)).isNotNull();
+ fileId = fileInPr.scannerId();
assertThat(result2.getReportReader().readChangesets(fileId)).isNull();
assertThat(result2.getReportReader().hasCoverage(fileId)).isTrue();
assertThat(result2.getReportReader().readFileSource(fileId)).isNull();
@@ -104,11 +104,11 @@ public class BranchMediumTest {
.setBranchName(branchName)
.setBranchTarget(branchTarget)
.setLongLivingSonarReferenceBranch(branchTarget)
- .setBranchType(BranchType.SHORT));
+ .setBranchType(BranchType.BRANCH));
ScannerReport.Metadata metadata = result.getReportReader().readMetadata();
assertThat(metadata.getBranchName()).isEqualTo(branchName);
- assertThat(metadata.getBranchType()).isEqualTo(ScannerReport.Metadata.BranchType.SHORT);
+ assertThat(metadata.getBranchType()).isEqualTo(ScannerReport.Metadata.BranchType.BRANCH);
assertThat(metadata.getMergeBranchName()).isEqualTo(branchTarget);
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/log/LogListenerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/log/LogListenerTest.java
index 74cdb214654..efccd3517bf 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/log/LogListenerTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/log/LogListenerTest.java
@@ -24,6 +24,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -67,7 +68,6 @@ public class LogListenerTest {
.setLogOutput(new SimpleLogListener());
private File baseDir;
-
private ImmutableMap.Builder<String, String> builder;
@BeforeClass
@@ -87,13 +87,13 @@ public class LogListenerTest {
}
@Before
- public void prepare() throws IOException {
+ public void prepare() {
stdOutTarget = new ByteArrayOutputStream();
stdErrTarget = new ByteArrayOutputStream();
System.setOut(new PrintStream(stdOutTarget));
System.setErr(new PrintStream(stdErrTarget));
// logger from the batch might write to it asynchronously
- logOutput = Collections.synchronizedList(new LinkedList<LogEvent>());
+ logOutput = Collections.synchronizedList(new LinkedList<>());
logOutputStr = new StringBuilder();
baseDir = temp.getRoot();
@@ -130,12 +130,12 @@ public class LogListenerTest {
}
@Test
- public void testChangeLogForAnalysis() throws IOException, InterruptedException {
+ public void testChangeLogForAnalysis() throws IOException {
File srcDir = new File(baseDir, "src");
srcDir.mkdir();
File xooFile = new File(srcDir, "sample.xoo");
- FileUtils.write(xooFile, "Sample xoo\ncontent");
+ FileUtils.write(xooFile, "Sample xoo\ncontent", StandardCharsets.UTF_8);
tester.newAnalysis()
.properties(builder
@@ -158,7 +158,7 @@ public class LogListenerTest {
srcDir.mkdir();
File xooFile = new File(srcDir, "sample.xoo");
- FileUtils.write(xooFile, "Sample xoo\ncontent");
+ FileUtils.write(xooFile, "Sample xoo\ncontent", StandardCharsets.UTF_8);
tester.newAnalysis()
.properties(builder
@@ -182,7 +182,7 @@ public class LogListenerTest {
srcDir.mkdir();
File xooFile = new File(srcDir, "sample.xoo");
- FileUtils.write(xooFile, "Sample xoo\ncontent");
+ FileUtils.write(xooFile, "Sample xoo\ncontent", StandardCharsets.UTF_8);
tester.newAnalysis()
.properties(builder
@@ -209,7 +209,7 @@ public class LogListenerTest {
File xooFile = new File(srcDir, "sample.xoo");
FileUtils.write(xooFile, "Sample xoo\ncontent");
File xooFileMeasure = new File(srcDir, "sample.xoo.measures");
- FileUtils.write(xooFileMeasure, "foo:bar");
+ FileUtils.write(xooFileMeasure, "foo:bar", StandardCharsets.UTF_8);
try {
tester.newAnalysis()
@@ -228,7 +228,7 @@ public class LogListenerTest {
for (LogEvent e : logOutput) {
if (e.level == Level.ERROR) {
assertThat(e.msg).contains("Error processing line 1 of file", "src" + File.separator + "sample.xoo.measures",
- "java.lang.IllegalStateException: Unknow metric with key: foo",
+ "java.lang.IllegalStateException: Unknown metric with key: foo",
"at org.sonar.xoo.lang.MeasureSensor.saveMeasure");
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ChangedLinesPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ChangedLinesPublisherTest.java
index 76d4f2285e7..9a2716d9bc6 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ChangedLinesPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ChangedLinesPublisherTest.java
@@ -66,7 +66,7 @@ public class ChangedLinesPublisherTest {
@Before
public void setUp() {
writer = new ScannerReportWriter(temp.getRoot());
- when(branchConfiguration.isShortOrPullRequest()).thenReturn(true);
+ when(branchConfiguration.isPullRequest()).thenReturn(true);
when(scmConfiguration.isDisabled()).thenReturn(false);
when(scmConfiguration.provider()).thenReturn(provider);
when(branchConfiguration.targetBranchName()).thenReturn(TARGET_BRANCH);
@@ -83,7 +83,7 @@ public class ChangedLinesPublisherTest {
@Test
public void skip_if_not_pr_or_slb() {
- when(branchConfiguration.isShortOrPullRequest()).thenReturn(false);
+ when(branchConfiguration.isPullRequest()).thenReturn(false);
publisher.publish(writer);
verifyZeroInteractions(inputComponentStore, inputModuleHierarchy, provider);
assertNotPublished();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java
index 0cd108c71df..6ee51409a7d 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ComponentsPublisherTest.java
@@ -129,7 +129,7 @@ public class ComponentsPublisherTest {
@Test
public void publish_unchanged_components_even_in_short_branches() throws IOException {
- when(branchConfiguration.isShortOrPullRequest()).thenReturn(true);
+ when(branchConfiguration.isPullRequest()).thenReturn(true);
ProjectInfo projectInfo = mock(ProjectInfo.class);
when(projectInfo.getAnalysisDate()).thenReturn(DateUtils.parseDate("2012-12-12"));
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
index 9fab83409fb..cdff80a8414 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/MetadataPublisherTest.java
@@ -38,14 +38,14 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
+import org.sonar.api.batch.fs.internal.DefaultInputModule;
+import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.api.batch.scm.ScmProvider;
import org.sonar.scanner.ProjectInfo;
import org.sonar.scanner.bootstrap.ScannerPlugin;
import org.sonar.scanner.bootstrap.ScannerPluginRepository;
import org.sonar.scanner.cpd.CpdSettings;
-import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.scanner.fs.InputModuleHierarchy;
-import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.scanner.protocol.output.ScannerReportReader;
import org.sonar.scanner.protocol.output.ScannerReportWriter;
@@ -221,28 +221,13 @@ public class MetadataPublisherTest {
}
@Test
- public void write_long_lived_branch_info() throws Exception {
- String branchName = "long-lived";
- when(branches.branchName()).thenReturn(branchName);
- when(branches.branchType()).thenReturn(BranchType.LONG);
-
- File outputDir = temp.newFolder();
- underTest.publish(new ScannerReportWriter(outputDir));
+ public void write_branch_info() throws Exception {
+ String branchName = "name";
+ String targetName = "target";
- ScannerReportReader reader = new ScannerReportReader(outputDir);
- ScannerReport.Metadata metadata = reader.readMetadata();
- assertThat(metadata.getBranchName()).isEqualTo(branchName);
- assertThat(metadata.getBranchType()).isEqualTo(ScannerReport.Metadata.BranchType.LONG);
- }
-
- @Test
- public void write_short_lived_branch_info() throws Exception {
- String branchName = "feature";
- String targetBranchName = "short-lived";
- String longLivingSonarReferenceBranch = "long-lived";
when(branches.branchName()).thenReturn(branchName);
- when(branches.targetBranchName()).thenReturn(targetBranchName);
- when(branches.longLivingSonarReferenceBranch()).thenReturn(longLivingSonarReferenceBranch);
+ when(branches.branchType()).thenReturn(BranchType.BRANCH);
+ when(branches.targetBranchName()).thenReturn(targetName);
File outputDir = temp.newFolder();
underTest.publish(new ScannerReportWriter(outputDir));
@@ -250,9 +235,9 @@ public class MetadataPublisherTest {
ScannerReportReader reader = new ScannerReportReader(outputDir);
ScannerReport.Metadata metadata = reader.readMetadata();
assertThat(metadata.getBranchName()).isEqualTo(branchName);
- assertThat(metadata.getBranchType()).isEqualTo(ScannerReport.Metadata.BranchType.SHORT);
- assertThat(metadata.getMergeBranchName()).isEqualTo(longLivingSonarReferenceBranch);
- assertThat(metadata.getTargetBranchName()).isEqualTo(targetBranchName);
+ assertThat(metadata.getBranchType()).isEqualTo(ScannerReport.Metadata.BranchType.BRANCH);
+ assertThat(metadata.getMergeBranchName()).isEmpty();
+ assertThat(metadata.getTargetBranchName()).isEqualTo(targetName);
}
@Test
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
index dee94ded490..a35094b32c8 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
@@ -57,9 +57,8 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.sonar.scanner.scan.branch.BranchType.LONG;
+import static org.sonar.scanner.scan.branch.BranchType.BRANCH;
import static org.sonar.scanner.scan.branch.BranchType.PULL_REQUEST;
-import static org.sonar.scanner.scan.branch.BranchType.SHORT;
public class ReportPublisherTest {
@@ -139,9 +138,9 @@ public class ReportPublisherTest {
}
@Test
- public void dump_public_url_if_defined_for_long_living_branches() throws IOException {
+ public void dump_public_url_if_defined_for_branches() throws IOException {
when(server.getPublicRootUrl()).thenReturn("https://publicserver/sonarqube");
- when(branchConfiguration.branchType()).thenReturn(LONG);
+ when(branchConfiguration.branchType()).thenReturn(BRANCH);
when(branchConfiguration.branchName()).thenReturn("branch-6.7");
ReportPublisher underTest = new ReportPublisher(properties, wsClient, server, contextPublisher, moduleHierarchy, mode, mock(TempFolder.class),
new ReportPublisherStep[0], branchConfiguration, reportMetadataHolder);
@@ -158,25 +157,6 @@ public class ReportPublisherTest {
}
@Test
- public void dump_public_url_if_defined_for_short_living_branches() throws IOException {
- when(server.getPublicRootUrl()).thenReturn("https://publicserver/sonarqube");
- when(branchConfiguration.branchType()).thenReturn(SHORT);
- when(branchConfiguration.branchName()).thenReturn("branch-6.7");
- ReportPublisher underTest = new ReportPublisher(properties, wsClient, server, contextPublisher, moduleHierarchy, mode, mock(TempFolder.class),
- new ReportPublisherStep[0], branchConfiguration, reportMetadataHolder);
-
- underTest.prepareAndDumpMetadata("TASK-123");
-
- assertThat(readFileToString(properties.metadataFilePath().toFile(), StandardCharsets.UTF_8)).isEqualTo(
- "projectKey=org.sonarsource.sonarqube:sonarqube\n" +
- "serverUrl=https://publicserver/sonarqube\n" +
- "serverVersion=6.4\n" +
- "dashboardUrl=https://publicserver/sonarqube/dashboard?id=org.sonarsource.sonarqube%3Asonarqube&branch=branch-6.7&resolved=false\n" +
- "ceTaskId=TASK-123\n" +
- "ceTaskUrl=https://publicserver/sonarqube/api/ce/task?id=TASK-123\n");
- }
-
- @Test
public void dump_public_url_if_defined_for_pull_request() throws IOException {
when(server.getPublicRootUrl()).thenReturn("https://publicserver/sonarqube");
when(branchConfiguration.branchName()).thenReturn("Bitbucket cloud Widget");
@@ -300,7 +280,7 @@ public class ReportPublisherTest {
String branchName = "feature";
when(branchConfiguration.branchName()).thenReturn(branchName);
- when(branchConfiguration.branchType()).thenReturn(SHORT);
+ when(branchConfiguration.branchType()).thenReturn(BRANCH);
WsResponse response = mock(WsResponse.class);
@@ -323,7 +303,7 @@ public class ReportPublisherTest {
assertThat(wsRequest.getParameters().getValues("organization")).containsExactly(orgName);
assertThat(wsRequest.getParameters().getValues("projectKey")).containsExactly("org.sonarsource.sonarqube:sonarqube");
assertThat(wsRequest.getParameters().getValues("characteristic"))
- .containsExactlyInAnyOrder("branch=" + branchName, "branchType=" + SHORT.name());
+ .containsExactlyInAnyOrder("branch=" + branchName, "branchType=" + BRANCH.name());
}
@Test
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java
index 0dd61ad9ccf..7a4ece81a86 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/DefaultActiveRulesLoaderTest.java
@@ -61,7 +61,7 @@ public class DefaultActiveRulesLoaderTest {
public void setUp() {
wsClient = mock(DefaultScannerWsClient.class);
BranchConfiguration branchConfig = mock(BranchConfiguration.class);
- when(branchConfig.isShortOrPullRequest()).thenReturn(false);
+ when(branchConfig.isPullRequest()).thenReturn(false);
loader = new DefaultActiveRulesLoader(wsClient);
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/BranchConfigurationProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/BranchConfigurationProviderTest.java
index b77274c5d1a..9fb7cdd8d77 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/BranchConfigurationProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/BranchConfigurationProviderTest.java
@@ -29,9 +29,7 @@ import org.mockito.Captor;
import org.mockito.MockitoAnnotations;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.scanner.bootstrap.GlobalServerSettings;
import org.sonar.scanner.scan.ProjectConfiguration;
-import org.sonar.scanner.scan.ProjectServerSettings;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.eq;
@@ -45,11 +43,11 @@ public class BranchConfigurationProviderTest {
private BranchConfiguration config = mock(BranchConfiguration.class);
private ProjectBranches branches = mock(ProjectBranches.class);
private ProjectPullRequests pullRequests = mock(ProjectPullRequests.class);
- private ProjectReactor reactor = mock(ProjectReactor.class);;
- private Map<String, String> projectSettings = new HashMap<>();;
+ private ProjectReactor reactor = mock(ProjectReactor.class);
+ ;
+ private Map<String, String> projectSettings = new HashMap<>();
+ ;
private ProjectDefinition root = mock(ProjectDefinition.class);
- private GlobalServerSettings globalServerSettings = mock(GlobalServerSettings.class);
- private ProjectServerSettings projectServerSettings = mock(ProjectServerSettings.class);
@Captor
private ArgumentCaptor<Supplier<Map<String, String>>> settingsCaptor;
@@ -81,6 +79,6 @@ public class BranchConfigurationProviderTest {
BranchConfiguration result = provider.provide(null, projectConfiguration, branches, pullRequests);
assertThat(result.targetBranchName()).isNull();
- assertThat(result.branchType()).isEqualTo(BranchType.LONG);
+ assertThat(result.branchType()).isEqualTo(BranchType.BRANCH);
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesTest.java
index 40c6c59ee59..ee3967947f5 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesTest.java
@@ -34,14 +34,13 @@ import static org.assertj.core.api.Assertions.assertThat;
@RunWith(DataProviderRunner.class)
public class ProjectBranchesTest {
- private static final BranchInfo mainBranch = new BranchInfo("main", BranchType.LONG, true, null);
- private static final BranchInfo shortBranch = new BranchInfo("short", BranchType.SHORT, false, null);
- private static final BranchInfo longBranch = new BranchInfo("long", BranchType.LONG, false, null);
+ private static final BranchInfo mainBranch = new BranchInfo("main", BranchType.BRANCH, true, null);
+ private static final BranchInfo branch = new BranchInfo("branch", BranchType.BRANCH, false, null);
private static final BranchInfo pullRequest = new BranchInfo("pull-request", BranchType.PULL_REQUEST, false, null);
- private static final List<BranchInfo> nonMainBranches = Arrays.asList(shortBranch, longBranch, pullRequest);
+ private static final List<BranchInfo> nonMainBranches = Arrays.asList(branch, pullRequest);
- private static final List<BranchInfo> allBranches = Arrays.asList(shortBranch, longBranch, pullRequest, mainBranch);
+ private static final List<BranchInfo> allBranches = Arrays.asList(branch, pullRequest, mainBranch);
private final ProjectBranches underTest = new ProjectBranches(allBranches);
@@ -63,7 +62,7 @@ public class ProjectBranchesTest {
@DataProvider
public static Object[][] branchNamesAndBranches() {
return allBranches.stream()
- .map(b -> new Object[]{b.name(), b})
+ .map(b -> new Object[] {b.name(), b})
.toArray(Object[][]::new);
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmChangedFilesProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmChangedFilesProviderTest.java
index 0e4205c45e8..b6953f8b850 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmChangedFilesProviderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scm/ScmChangedFilesProviderTest.java
@@ -65,7 +65,7 @@ public class ScmChangedFilesProviderTest {
@Test
public void testNoScmProvider() {
- when(branchConfiguration.isShortOrPullRequest()).thenReturn(true);
+ when(branchConfiguration.isPullRequest()).thenReturn(true);
when(branchConfiguration.targetBranchName()).thenReturn("target");
ScmChangedFiles scmChangedFiles = provider.provide(scmConfiguration, branchConfiguration, project);
@@ -77,7 +77,7 @@ public class ScmChangedFilesProviderTest {
@Test
public void testFailIfRelativePath() {
when(branchConfiguration.targetBranchName()).thenReturn("target");
- when(branchConfiguration.isShortOrPullRequest()).thenReturn(true);
+ when(branchConfiguration.isPullRequest()).thenReturn(true);
when(scmConfiguration.provider()).thenReturn(scmProvider);
when(scmProvider.branchChangedFiles("target", rootBaseDir)).thenReturn(Collections.singleton(Paths.get("changedFile")));
@@ -89,7 +89,7 @@ public class ScmChangedFilesProviderTest {
@Test
public void testProviderDoesntSupport() {
when(branchConfiguration.targetBranchName()).thenReturn("target");
- when(branchConfiguration.isShortOrPullRequest()).thenReturn(true);
+ when(branchConfiguration.isPullRequest()).thenReturn(true);
when(scmConfiguration.provider()).thenReturn(scmProvider);
when(scmProvider.branchChangedFiles("target", rootBaseDir)).thenReturn(null);
ScmChangedFiles scmChangedFiles = provider.provide(scmConfiguration, branchConfiguration, project);
@@ -100,7 +100,7 @@ public class ScmChangedFilesProviderTest {
@Test
public void testNoOpInNonShortLivedBranch() {
- when(branchConfiguration.isShortOrPullRequest()).thenReturn(false);
+ when(branchConfiguration.isPullRequest()).thenReturn(false);
ScmChangedFiles scmChangedFiles = provider.provide(scmConfiguration, branchConfiguration, project);
assertThat(scmChangedFiles.get()).isNull();
@@ -117,7 +117,7 @@ public class ScmChangedFilesProviderTest {
};
when(scmConfiguration.provider()).thenReturn(legacy);
- when(branchConfiguration.isShortOrPullRequest()).thenReturn(true);
+ when(branchConfiguration.isPullRequest()).thenReturn(true);
when(branchConfiguration.targetBranchName()).thenReturn("target");
ScmChangedFiles scmChangedFiles = provider.provide(scmConfiguration, branchConfiguration, project);
@@ -129,7 +129,7 @@ public class ScmChangedFilesProviderTest {
@Test
public void testReturnChangedFiles() {
when(branchConfiguration.targetBranchName()).thenReturn("target");
- when(branchConfiguration.isShortOrPullRequest()).thenReturn(true);
+ when(branchConfiguration.isPullRequest()).thenReturn(true);
when(scmConfiguration.provider()).thenReturn(scmProvider);
when(scmProvider.branchChangedFiles("target", rootBaseDir)).thenReturn(Collections.singleton(Paths.get("changedFile").toAbsolutePath()));
ScmChangedFiles scmChangedFiles = provider.provide(scmConfiguration, branchConfiguration, project);
@@ -142,7 +142,7 @@ public class ScmChangedFilesProviderTest {
public void testCacheObject() {
provider.provide(scmConfiguration, branchConfiguration, project);
provider.provide(scmConfiguration, branchConfiguration, project);
- verify(branchConfiguration).isShortOrPullRequest();
+ verify(branchConfiguration).isPullRequest();
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorStorageTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorStorageTest.java
index 264e666429f..c37b3543b15 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorStorageTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sensor/DefaultSensorStorageTest.java
@@ -175,7 +175,7 @@ public class DefaultSensorStorageTest {
@Test
public void should_skip_issue_on_short_branch_when_file_status_is_SAME() {
InputFile file = new TestInputFileBuilder("foo", "src/Foo.php").setStatus(InputFile.Status.SAME).build();
- when(branchConfiguration.isShortOrPullRequest()).thenReturn(true);
+ when(branchConfiguration.isPullRequest()).thenReturn(true);
DefaultIssue issue = new DefaultIssue(project).at(new DefaultIssueLocation().on(file));
underTest.store(issue);
@@ -199,7 +199,7 @@ public class DefaultSensorStorageTest {
DefaultInputFile file = new TestInputFileBuilder("foo", "src/Foo.php")
.setContents("// comment")
.setStatus(InputFile.Status.SAME).build();
- when(branchConfiguration.isShortOrPullRequest()).thenReturn(true);
+ when(branchConfiguration.isPullRequest()).thenReturn(true);
DefaultHighlighting highlighting = new DefaultHighlighting(underTest).onFile(file).highlight(0, 1, TypeOfText.KEYWORD);
underTest.store(highlighting);
@@ -225,7 +225,7 @@ public class DefaultSensorStorageTest {
@Test
public void should_not_skip_file_measures_on_short_lived_branch_or_pull_request_when_file_status_is_SAME() {
DefaultInputFile file = new TestInputFileBuilder("foo", "src/Foo.php").setStatus(InputFile.Status.SAME).build();
- when(branchConfiguration.isShortOrPullRequest()).thenReturn(true);
+ when(branchConfiguration.isPullRequest()).thenReturn(true);
underTest.store(new DefaultMeasure()
.on(file)
@@ -243,7 +243,7 @@ public class DefaultSensorStorageTest {
.setStatus(InputFile.Status.SAME)
.setContents("foo")
.build();
- when(branchConfiguration.isShortOrPullRequest()).thenReturn(true);
+ when(branchConfiguration.isPullRequest()).thenReturn(true);
underTest.store(new DefaultSignificantCode()
.onFile(file)