]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 fix link to profile changelog
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 25 Jun 2014 13:50:17 +0000 (15:50 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 25 Jun 2014 15:57:33 +0000 (17:57 +0200)
sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java
sonar-batch/src/test/java/org/sonar/batch/rule/QProfileEventsDecoratorTest.java

index cfbed1da0e64eeee6d960bcfaa993531bb7b4429..28c1fea24c3a68e6a6bfdb8f1f22c834a7f30dbb 100644 (file)
@@ -111,18 +111,21 @@ public class QProfileEventsDecorator implements Decorator {
     event.setCategory(Event.CATEGORY_PROFILE);
     Date from = previousProfile.getRulesUpdatedAt();
 
-    // strictly greater than previous date
-    // This hack must be done because date precision is millisecond in db/es and date format is select only
-    from = DateUtils.addSeconds(from, 1);
-
     String data = KeyValueFormat.format(ImmutableSortedMap.of(
       "key", profile.getKey(),
-      "from", UtcDateUtils.formatDateTime(from),
-      "to", UtcDateUtils.formatDateTime(profile.getRulesUpdatedAt())));
+      "from", UtcDateUtils.formatDateTime(fixDate(from)),
+      "to", UtcDateUtils.formatDateTime(fixDate(profile.getRulesUpdatedAt()))));
     event.setData(data);
     persistenceManager.saveEvent(context.getResource(), event);
   }
 
+  /**
+   * This hack must be done because date precision is millisecond in db/es and date format is select only
+   */
+  private Date fixDate(Date date) {
+    return DateUtils.addSeconds(date, 1);
+  }
+
   private void markAsRemoved(DecoratorContext context, QProfile profile) {
     context.createEvent(String.format("Stop using %s", profileLabel(profile)), null, Event.CATEGORY_PROFILE, null);
   }
index 3d7f46fde693c80efe59c5e22067c5eab2df1360..6618cc7f83231feb61796e47f09f5f6fa30f1270 100644 (file)
@@ -122,8 +122,8 @@ public class QProfileEventsDecoratorTest {
         Event event = (Event) item;
         return event.getCategory().equals(Event.CATEGORY_PROFILE) &&
           "Changes in 'Java One' (Java)".equals(event.getName()) &&
-          // "from" is one second more !
-          "from=2014-01-15T12:00:01+0000;key=J1;to=2014-02-20T12:00:00+0000".equals(event.getData());
+          // "from" and "to" must have one second more because of lack of ms precision
+          "from=2014-01-15T12:00:01+0000;key=J1;to=2014-02-20T12:00:01+0000".equals(event.getData());
       }
     }));
   }