]> source.dussan.org Git - sonarqube.git/commitdiff
Support missing dates in the migration FeedLissueLongDates
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 8 Dec 2014 15:59:54 +0000 (16:59 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 8 Dec 2014 16:11:28 +0000 (17:11 +0100)
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/FeedIssueLongDates.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/FeedIssueLongDatesTest.java
server/sonar-server/src/test/resources/org/sonar/server/db/migrations/v50/FeedIssueLongDatesTest/before.xml

index cc65ac86564b02636612e23f187475634e9e37a7..c97938f721d2bc7f1e0070dd9b5a7c5760d14f96 100644 (file)
@@ -53,8 +53,16 @@ public class FeedIssueLongDates extends BaseDataChange {
         Date createdAt = row.getDate(2);
         Date updatedAt = row.getDate(3);
 
-        update.setLong(1, Math.min(now, createdAt.getTime()));
-        update.setLong(2, Math.min(now, updatedAt.getTime()));
+        if (createdAt == null) {
+          update.setLong(1, now);
+        } else {
+          update.setLong(1, Math.min(now, createdAt.getTime()));
+        }
+        if (updatedAt == null) {
+          update.setLong(2, now);
+        } else {
+          update.setLong(2, Math.min(now, updatedAt.getTime()));
+        }
         update.setLong(3, id);
         return true;
       }
index 91d47c7ea2eb17ef9e3441f27a3021e76c7193c3..b164d8e18bea3419f69142032e6d1dcdbe1f0fd2 100644 (file)
@@ -45,7 +45,7 @@ public class FeedIssueLongDatesTest {
     migration.execute();
 
     int count = db.count("select count(*) from issues where created_at_ms is not null and updated_at_ms is not null");
-    assertThat(count).isEqualTo(2);
+    assertThat(count).isEqualTo(3);
   }
 
 }
index 2c029ebf89516ed42869952fe4e2672346f32a86..9e28208c4268181c30967ea3c962f32aa87c7854 100644 (file)
           UPDATED_AT_MS="1500000000000"
     />
 
+  <issues id="3" kee="MISSINGDATES" resolution="OPEN" status="OPEN" severity="BLOCKER" manual_severity="[false]"
+          assignee="[null]"
+          author_login="[null]"
+          checksum="[null]"
+          effort_to_fix="[null]"
+          technical_debt="10"
+          message="[null]"
+          line="5000"
+          component_id="100"
+          root_component_id="10"
+          rule_id="200"
+          reporter="emmerik"
+          issue_attributes="foo=bar"
+          action_plan_key="[null]"
+          issue_creation_date="[null]"
+          issue_update_date="[null]"
+          issue_close_date="[null]"
+          created_at="2014-05-12"
+          updated_at="2014-05-13"
+          CREATED_AT_MS="[null]"
+          UPDATED_AT_MS="[null]"
+    />
+
 </dataset>