]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5056 Convert duration with value 0 to null
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 17 Mar 2014 08:29:02 +0000 (09:29 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 17 Mar 2014 08:29:02 +0000 (09:29 +0100)
sonar-server/src/main/java/org/sonar/server/startup/CopyRequirementsFromCharacteristicsToRules.java
sonar-server/src/test/java/org/sonar/server/startup/CopyRequirementsFromCharacteristicsToRulesTest.java

index 9a7497eec443a23a8882a656aadcd65d06543d8b..51fcac7192f14285119cae0f196eafb345a339fd 100644 (file)
@@ -209,7 +209,7 @@ public class CopyRequirementsFromCharacteristicsToRules {
   @CheckForNull
   @VisibleForTesting
   static String convertDuration(@Nullable Double oldValue, @Nullable String oldUnit) {
-    if (oldValue != null) {
+    if (oldValue != null && oldValue > 0) {
       String unit = oldUnit != null ? oldUnit : Duration.DAY;
       // min is replaced by mn
       unit = "mn".equals(unit) ? Duration.MINUTE : unit;
index bd67a8b08e7b30cc1c4cb06d04a25e050541ef52..f7d48d21523cc8e73c21229c2a90303245a04257 100644 (file)
@@ -92,6 +92,8 @@ public class CopyRequirementsFromCharacteristicsToRulesTest extends AbstractDaoT
 
     assertThat(CopyRequirementsFromCharacteristicsToRules.convertDuration(1.0, null)).isEqualTo("1d");
     assertThat(CopyRequirementsFromCharacteristicsToRules.convertDuration(null, "d")).isNull();
+
+    assertThat(CopyRequirementsFromCharacteristicsToRules.convertDuration(0.0, "d")).isNull();
   }
 
   @Test