aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/test
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-10-01 10:50:17 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-10-01 10:57:00 +0200
commit33cbe7daa7722a29e115ad9343a448c561d875a9 (patch)
tree5de951abf7745e40d8de512f71bed90884dd0a81 /sonar-batch/src/test
parent9cd17b26616cd146c8954e1e38ee7c9589280842 (diff)
downloadsonarqube-33cbe7daa7722a29e115ad9343a448c561d875a9.tar.gz
sonarqube-33cbe7daa7722a29e115ad9343a448c561d875a9.zip
Use sonar.profile when project is not provisioned
Diffstat (limited to 'sonar-batch/src/test')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/cache/NonAssociatedCacheSynchronizerTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/cache/ProjectCacheSynchronizerTest.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/BatchMediumTester.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/repository/DefaultQualityProfileLoaderTest.java2
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/repository/QualityProfileProviderTest.java40
5 files changed, 41 insertions, 11 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/cache/NonAssociatedCacheSynchronizerTest.java b/sonar-batch/src/test/java/org/sonar/batch/cache/NonAssociatedCacheSynchronizerTest.java
index 7934c0fed45..f16a22a0444 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/cache/NonAssociatedCacheSynchronizerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/cache/NonAssociatedCacheSynchronizerTest.java
@@ -52,7 +52,7 @@ public class NonAssociatedCacheSynchronizerTest {
QualityProfile pf = QualityProfile.newBuilder().setKey("profile").setName("profile").setLanguage("lang").build();
LoadedActiveRule ar = new LoadedActiveRule();
- when(qualityProfileLoader.loadDefault(null)).thenReturn(ImmutableList.of(pf));
+ when(qualityProfileLoader.loadDefault(null, null)).thenReturn(ImmutableList.of(pf));
when(activeRulesLoader.load("profile", null)).thenReturn(ImmutableList.of(ar));
synchronizer = new NonAssociatedCacheSynchronizer(qualityProfileLoader, activeRulesLoader, cacheStatus);
@@ -81,7 +81,7 @@ public class NonAssociatedCacheSynchronizerTest {
private void checkSync() {
verify(cacheStatus).getSyncStatus();
verify(cacheStatus).save();
- verify(qualityProfileLoader).loadDefault(null);
+ verify(qualityProfileLoader).loadDefault(null, null);
verify(activeRulesLoader).load("profile", null);
verifyNoMoreInteractions(qualityProfileLoader, activeRulesLoader);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/cache/ProjectCacheSynchronizerTest.java b/sonar-batch/src/test/java/org/sonar/batch/cache/ProjectCacheSynchronizerTest.java
index 548e6124313..6098850be55 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/cache/ProjectCacheSynchronizerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/cache/ProjectCacheSynchronizerTest.java
@@ -102,7 +102,7 @@ public class ProjectCacheSynchronizerTest {
ProjectRepositories repo = mock(ProjectRepositories.class);
when(qualityProfileLoader.load(PROJECT_KEY, null, null)).thenReturn(ImmutableList.of(pf));
- when(qualityProfileLoader.loadDefault(null)).thenReturn(ImmutableList.of(pf));
+ when(qualityProfileLoader.loadDefault(null, null)).thenReturn(ImmutableList.of(pf));
when(activeRulesLoader.load("profile", null)).thenReturn(ImmutableList.of(ar));
when(repo.lastAnalysisDate()).thenReturn(lastAnalysisDate);
when(repo.exists()).thenReturn(projectExists);
@@ -142,7 +142,7 @@ public class ProjectCacheSynchronizerTest {
synchronizer.load(PROJECT_KEY, false);
verify(projectRepositoriesLoader).load(eq(PROJECT_KEY), eq(true), any(MutableBoolean.class));
- verify(qualityProfileLoader).loadDefault(null);
+ verify(qualityProfileLoader).loadDefault(null, null);
verify(activeRulesLoader).load("profile", null);
verifyNoMoreInteractions(issuesLoader, userRepositoryLoader, qualityProfileLoader, activeRulesLoader, projectRepositoriesLoader);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/BatchMediumTester.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/BatchMediumTester.java
index ab8ee270983..c330d304a8e 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/BatchMediumTester.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/BatchMediumTester.java
@@ -459,7 +459,7 @@ public class BatchMediumTester {
}
@Override
- public List<QualityProfile> loadDefault(MutableBoolean fromCache) {
+ public List<QualityProfile> loadDefault(String profileName, MutableBoolean fromCache) {
return qualityProfiles;
}
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultQualityProfileLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultQualityProfileLoaderTest.java
index 6a52a3f1c50..f0215aa18e2 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultQualityProfileLoaderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/repository/DefaultQualityProfileLoaderTest.java
@@ -89,7 +89,7 @@ public class DefaultQualityProfileLoaderTest {
InputStream is = getTestResource("quality_profile_search_default");
when(ws.loadStream(anyString())).thenReturn(new WSLoaderResult<InputStream>(is, false));
- List<QualityProfile> loaded = qpLoader.loadDefault(null);
+ List<QualityProfile> loaded = qpLoader.loadDefault(null, null);
verify(ws).loadStream("/api/qualityprofiles/search.protobuf?defaults=true");
verifyNoMoreInteractions(ws);
assertThat(loaded).hasSize(1);
diff --git a/sonar-batch/src/test/java/org/sonar/batch/repository/QualityProfileProviderTest.java b/sonar-batch/src/test/java/org/sonar/batch/repository/QualityProfileProviderTest.java
index 361d147ac0d..799022ecbe3 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/repository/QualityProfileProviderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/repository/QualityProfileProviderTest.java
@@ -20,6 +20,9 @@
package org.sonar.batch.repository;
import static org.mockito.Mockito.when;
+
+import org.mockito.Matchers;
+
import org.apache.commons.lang.mutable.MutableBoolean;
import org.sonar.api.batch.bootstrap.ProjectKey;
import org.sonar.batch.analysis.DefaultAnalysisMode;
@@ -28,8 +31,8 @@ import org.sonarqube.ws.QualityProfiles.WsSearchResponse.QualityProfile;
import java.util.ArrayList;
import java.util.List;
+import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.isNull;
-
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.verifyNoMoreInteractions;
@@ -84,11 +87,11 @@ public class QualityProfileProviderTest {
@Test
public void testNonAssociated() {
when(mode.isNotAssociated()).thenReturn(true);
- when(loader.loadDefault(any(MutableBoolean.class))).thenReturn(response);
+ when(loader.loadDefault(anyString(), any(MutableBoolean.class))).thenReturn(response);
ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props, mode);
assertResponse(qps);
- verify(loader).loadDefault(any(MutableBoolean.class));
+ verify(loader).loadDefault(anyString(), any(MutableBoolean.class));
verifyNoMoreInteractions(loader);
}
@@ -96,11 +99,11 @@ public class QualityProfileProviderTest {
public void testProjectDoesntExist() {
when(mode.isNotAssociated()).thenReturn(false);
when(projectRepo.exists()).thenReturn(false);
- when(loader.loadDefault(any(MutableBoolean.class))).thenReturn(response);
+ when(loader.loadDefault(anyString(), any(MutableBoolean.class))).thenReturn(response);
ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props, mode);
assertResponse(qps);
- verify(loader).loadDefault(any(MutableBoolean.class));
+ verify(loader).loadDefault(anyString(), any(MutableBoolean.class));
verifyNoMoreInteractions(loader);
}
@@ -117,6 +120,33 @@ public class QualityProfileProviderTest {
verifyNoMoreInteractions(loader);
}
+ @Test
+ public void testIgnoreSonarProfileIssuesMode() {
+ when(mode.isNotAssociated()).thenReturn(false);
+ when(mode.isIssues()).thenReturn(true);
+ when(loader.load(eq("project"), (String) eq(null), any(MutableBoolean.class))).thenReturn(response);
+ when(props.property(ModuleQProfiles.SONAR_PROFILE_PROP)).thenReturn("custom");
+
+ ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props, mode);
+ assertResponse(qps);
+
+ verify(loader).load(eq("project"), (String) eq(null), any(MutableBoolean.class));
+ verifyNoMoreInteractions(loader);
+ }
+
+ @Test
+ public void testProfilePropDefault() {
+ when(mode.isNotAssociated()).thenReturn(true);
+ when(loader.loadDefault(eq("custom"), any(MutableBoolean.class))).thenReturn(response);
+ when(props.property(ModuleQProfiles.SONAR_PROFILE_PROP)).thenReturn("custom");
+
+ ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props, mode);
+ assertResponse(qps);
+
+ verify(loader).loadDefault(eq("custom"), any(MutableBoolean.class));
+ verifyNoMoreInteractions(loader);
+ }
+
private void assertResponse(ModuleQProfiles qps) {
assertThat(qps.findAll()).hasSize(1);
assertThat(qps.findAll()).extracting("key").containsExactly("profile");