summaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-06-25 15:50:17 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-06-25 17:57:33 +0200
commit5775a857cef75304c0e35bbd801a7a01552e8a08 (patch)
tree90f2ee5c03fb0be3b4988c382b36806ff815bae3 /sonar-batch
parent01d0246e4799f7634ab55722bc4a1e3e6ee186b0 (diff)
downloadsonarqube-5775a857cef75304c0e35bbd801a7a01552e8a08.tar.gz
sonarqube-5775a857cef75304c0e35bbd801a7a01552e8a08.zip
SONAR-5007 fix link to profile changelog
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java15
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/rule/QProfileEventsDecoratorTest.java4
2 files changed, 11 insertions, 8 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java
index cfbed1da0e6..28c1fea24c3 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java
@@ -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);
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/rule/QProfileEventsDecoratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/rule/QProfileEventsDecoratorTest.java
index 3d7f46fde69..6618cc7f832 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/rule/QProfileEventsDecoratorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/rule/QProfileEventsDecoratorTest.java
@@ -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());
}
}));
}