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;
import javax.annotation.CheckForNull;
+import java.util.Date;
import java.util.List;
import java.util.Map;
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);
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());
}
}));
}