aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2018-11-26 16:36:06 +0100
committersonartech <sonartech@sonarsource.com>2019-01-16 09:43:03 +0100
commitcc9d2163a0feb24e4139db55bb616368122a18d4 (patch)
treee21b1f7a959ff65e8f67f7a731638d4a2bbbdd31 /sonar-scanner-engine/src/test/java/org/sonar/scanner/rule
parent38abb93944c9e0887bed470595882ef1822e4b2c (diff)
downloadsonarqube-cc9d2163a0feb24e4139db55bb616368122a18d4.tar.gz
sonarqube-cc9d2163a0feb24e4139db55bb616368122a18d4.zip
SONAR-11508, SONAR-11484 Index files at project level
Diffstat (limited to 'sonar-scanner-engine/src/test/java/org/sonar/scanner/rule')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java
index fb432157a58..18facbe6391 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/rule/QProfileVerifierTest.java
@@ -25,10 +25,11 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
-import org.sonar.api.batch.fs.internal.DefaultFileSystem;
import org.sonar.api.batch.fs.internal.TestInputFileBuilder;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.MessageException;
+import org.sonar.scanner.scan.branch.BranchConfiguration;
+import org.sonar.scanner.scan.filesystem.InputComponentStore;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -42,13 +43,13 @@ public class QProfileVerifierTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
- private DefaultFileSystem fs;
+ private InputComponentStore store;
private QualityProfiles profiles;
private MapSettings settings = new MapSettings();
@Before
public void before() throws Exception {
- fs = new DefaultFileSystem(temp.newFolder().toPath());
+ store = new InputComponentStore(mock(BranchConfiguration.class));
profiles = mock(QualityProfiles.class);
QProfile javaProfile = new QProfile("p1", "My Java profile", "java", null);
when(profiles.findByLanguage("java")).thenReturn(javaProfile);
@@ -58,10 +59,10 @@ public class QProfileVerifierTest {
@Test
public void should_log_all_used_profiles() {
- fs.add(new TestInputFileBuilder("foo", "src/Bar.java").setLanguage("java").build());
- fs.add(new TestInputFileBuilder("foo", "src/Baz.cbl").setLanguage("cobol").build());
+ store.put("foo", new TestInputFileBuilder("foo", "src/Bar.java").setLanguage("java").build());
+ store.put("foo", new TestInputFileBuilder("foo", "src/Baz.cbl").setLanguage("cobol").build());
- QProfileVerifier profileLogger = new QProfileVerifier(settings.asConfig(), fs, profiles);
+ QProfileVerifier profileLogger = new QProfileVerifier(settings.asConfig(), store, profiles);
Logger logger = mock(Logger.class);
profileLogger.execute(logger);
@@ -71,11 +72,11 @@ public class QProfileVerifierTest {
@Test
public void should_fail_if_default_profile_not_used() {
- fs.add(new TestInputFileBuilder("foo", "src/Bar.java").setLanguage("java").build());
+ store.put("foo", new TestInputFileBuilder("foo", "src/Bar.java").setLanguage("java").build());
settings.setProperty("sonar.profile", "Unknown");
- QProfileVerifier profileLogger = new QProfileVerifier(settings.asConfig(), fs, profiles);
+ QProfileVerifier profileLogger = new QProfileVerifier(settings.asConfig(), store, profiles);
thrown.expect(MessageException.class);
thrown.expectMessage("sonar.profile was set to 'Unknown' but didn't match any profile for any language. Please check your configuration.");
@@ -87,7 +88,7 @@ public class QProfileVerifierTest {
public void should_not_fail_if_no_language_on_project() {
settings.setProperty("sonar.profile", "Unknown");
- QProfileVerifier profileLogger = new QProfileVerifier(settings.asConfig(), fs, profiles);
+ QProfileVerifier profileLogger = new QProfileVerifier(settings.asConfig(), store, profiles);
profileLogger.execute();
@@ -95,11 +96,11 @@ public class QProfileVerifierTest {
@Test
public void should_not_fail_if_default_profile_used_at_least_once() {
- fs.add(new TestInputFileBuilder("foo", "src/Bar.java").setLanguage("java").build());
+ store.put("foo", new TestInputFileBuilder("foo", "src/Bar.java").setLanguage("java").build());
settings.setProperty("sonar.profile", "My Java profile");
- QProfileVerifier profileLogger = new QProfileVerifier(settings.asConfig(), fs, profiles);
+ QProfileVerifier profileLogger = new QProfileVerifier(settings.asConfig(), store, profiles);
profileLogger.execute();
}