]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6143 'SonarQube way' quality gate should be set as default 541/head
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 28 Sep 2015 10:03:12 +0000 (12:03 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 28 Sep 2015 11:31:19 +0000 (13:31 +0200)
server/sonar-server/src/main/java/org/sonar/server/qualitygate/RegisterQualityGates.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/RegisterQualityGatesTest.java

index e16ba4733486150bd7013c271465291fbe7e078e..62bf899b1668b9694ae66d611079732891187771 100644 (file)
@@ -21,10 +21,10 @@ package org.sonar.server.qualitygate;
 
 import org.picocontainer.Startable;
 import org.sonar.api.measures.CoreMetrics;
-import org.sonar.db.qualitygate.QualityGateConditionDto;
-import org.sonar.db.qualitygate.QualityGateDto;
 import org.sonar.db.loadedtemplate.LoadedTemplateDao;
 import org.sonar.db.loadedtemplate.LoadedTemplateDto;
+import org.sonar.db.qualitygate.QualityGateConditionDto;
+import org.sonar.db.qualitygate.QualityGateDto;
 
 public class RegisterQualityGates implements Startable {
 
@@ -61,6 +61,7 @@ public class RegisterQualityGates implements Startable {
     qualityGates.createCondition(builtin.getId(), CoreMetrics.NEW_CRITICAL_VIOLATIONS_KEY, QualityGateConditionDto.OPERATOR_GREATER_THAN, null, "0", 3);
     qualityGates.createCondition(builtin.getId(), CoreMetrics.NEW_SQALE_DEBT_RATIO_KEY, QualityGateConditionDto.OPERATOR_GREATER_THAN, null, "5", 3);
     qualityGates.createCondition(builtin.getId(), CoreMetrics.NEW_COVERAGE_KEY, QualityGateConditionDto.OPERATOR_LESS_THAN, null, "80", 3);
+    qualityGates.setDefault(builtin.getId());
   }
 
   private void registerBuiltinQualityGate() {
index 953adf4388358f7c5d1ba2c1b37311484b07a4c1..a1b8d7c8d792dfe8000b38ccf2d3338a2936ec39 100644 (file)
@@ -25,12 +25,19 @@ import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.sonar.db.qualitygate.QualityGateDto;
 import org.sonar.db.loadedtemplate.LoadedTemplateDao;
 import org.sonar.db.loadedtemplate.LoadedTemplateDto;
+import org.sonar.db.qualitygate.QualityGateDto;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.anyLong;
+import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
 
 @RunWith(MockitoJUnitRunner.class)
 public class RegisterQualityGatesTest {
@@ -60,6 +67,8 @@ public class RegisterQualityGatesTest {
     verify(templateDao).countByTypeAndKey(templateType, templateName);
     verify(qualityGates).create(templateName);
     verify(qualityGates, times(4)).createCondition(anyLong(), anyString(), anyString(), anyString(), anyString(), anyInt());
+    verify(qualityGates).setDefault(anyLong());
+
     ArgumentCaptor<LoadedTemplateDto> templateArg = ArgumentCaptor.forClass(LoadedTemplateDto.class);
     verify(templateDao).insert(templateArg.capture());
     LoadedTemplateDto template = templateArg.getValue();