Refactor event capturing in submit tests for more precise assertions
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
This commit is contained in:
@@ -19,7 +19,7 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.data.AccountAttribute;
|
||||
|
||||
public class ChangeMergedEvent extends PatchSetEvent {
|
||||
static final String TYPE = "change-merged";
|
||||
public static final String TYPE = "change-merged";
|
||||
public Supplier<AccountAttribute> submitter;
|
||||
public String newRev;
|
||||
|
||||
|
@@ -20,7 +20,7 @@ import com.google.gerrit.server.data.AccountAttribute;
|
||||
import com.google.gerrit.server.data.RefUpdateAttribute;
|
||||
|
||||
public class RefUpdatedEvent extends RefEvent {
|
||||
static final String TYPE = "ref-updated";
|
||||
public static final String TYPE = "ref-updated";
|
||||
public Supplier<AccountAttribute> submitter;
|
||||
public Supplier<RefUpdateAttribute> refUpdate;
|
||||
|
||||
|
Reference in New Issue
Block a user