From: Julien Lancelot Date: Mon, 28 Sep 2015 10:03:12 +0000 (+0200) Subject: SONAR-6143 'SonarQube way' quality gate should be set as default X-Git-Tag: 5.2-RC1~242 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8e107135d6b856cf05d3b32519852831bef740ae;p=sonarqube.git SONAR-6143 'SonarQube way' quality gate should be set as default --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/RegisterQualityGates.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/RegisterQualityGates.java index e16ba473348..62bf899b166 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/RegisterQualityGates.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/RegisterQualityGates.java @@ -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() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/RegisterQualityGatesTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/RegisterQualityGatesTest.java index 953adf43883..a1b8d7c8d79 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/RegisterQualityGatesTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/RegisterQualityGatesTest.java @@ -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 templateArg = ArgumentCaptor.forClass(LoadedTemplateDto.class); verify(templateDao).insert(templateArg.capture()); LoadedTemplateDto template = templateArg.getValue();