Factor the event capturing out to a new class, EventRecorder, which
listens to the events and records those that are of type RefEvent.
Events are recorded in a map keyed on a combination of the event type,
project name and ref (branch name). In each map entry the received
events are stored in a list.
This allows us to make assertions about the events that were received
for a project and branch, and in which order they were received.
Convert the existing tests of change-merged events to use the new
class.
Also extend the submit-by-fast-forward tests to assert that when a
stack of changes is submitted by fast-forward, there was only one
ref-updated event for that project/branch and it contains:
- old ref: the sha1 of the branch's original HEAD
- new ref: the sha1 of the change at the top of the stack
Bug: Issue 4123
Change-Id: Ic978fb28fda601c9ab5897e0a0e2f9280d59216c