aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2014-06-24 10:39:26 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2014-06-24 10:39:35 +0200
commit499ee54abf8c0d673be77d76c119f41e52e4de84 (patch)
tree9e045e56ba2645f34a69402c22a0c7ecaa1a0f91 /sonar-batch
parent058273a7be1fd07ad1abff67c777a9ef52eb1498 (diff)
downloadsonarqube-499ee54abf8c0d673be77d76c119f41e52e4de84.tar.gz
sonarqube-499ee54abf8c0d673be77d76c119f41e52e4de84.zip
SONAR-5007 add link to Q profile changelog in the events widget
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java10
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/rule/QProfileEventsDecoratorTest.java3
2 files changed, 11 insertions, 2 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 3774f9f1b5e..cfbed1da0e6 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
@@ -20,6 +20,7 @@
package org.sonar.batch.rule;
import com.google.common.collect.ImmutableSortedMap;
+import org.apache.commons.lang.time.DateUtils;
import org.sonar.api.batch.Decorator;
import org.sonar.api.batch.DecoratorContext;
import org.sonar.api.batch.DependsUpon;
@@ -40,6 +41,7 @@ import org.sonar.core.UtcDateUtils;
import javax.annotation.CheckForNull;
+import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -107,9 +109,15 @@ public class QProfileEventsDecorator implements Decorator {
Event event = new Event();
event.setName(String.format("Changes in %s", profileLabel(profile)));
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(previousProfile.getRulesUpdatedAt()),
+ "from", UtcDateUtils.formatDateTime(from),
"to", UtcDateUtils.formatDateTime(profile.getRulesUpdatedAt())));
event.setData(data);
persistenceManager.saveEvent(context.getResource(), event);
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 c1afcb1e2ee..3d7f46fde69 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,7 +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=2014-01-15T12:00:00+0000;key=J1;to=2014-02-20T12:00:00+0000".equals(event.getData());
+ // "from" is one second more !
+ "from=2014-01-15T12:00:01+0000;key=J1;to=2014-02-20T12:00:00+0000".equals(event.getData());
}
}));
}