Mock CommitReceiveEvent to be master-compatible

Gerrit master has changed the way CommitReceiveEvent gets created.
However, it is not the scope of our test to assert Gerrit's internal
behavior, as it may change across different versions.

By using a mocked event, we can concentrate on what we care and test in
our scenario, and be more Gerrit-independent in the future.

Fix the associated tests on master and stable-2.14

Bug: Issue 6106
Change-Id: I28dd3c4b9c0b635ff42ba0a87a4c0b13791b3588
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java
index 17d31a1..b016edf 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java
@@ -15,6 +15,7 @@
 package com.googlesource.gerrit.plugins.its.base.its;
 
 import com.google.common.base.Function;
+import com.google.common.base.Optional;
 import com.google.common.base.Predicate;
 import com.google.common.collect.FluentIterable;
 import com.google.gerrit.common.data.RefConfigSection;
@@ -188,7 +189,7 @@
    *    to match issue ids.
    */
   public Pattern getIssuePattern() {
-    String match =
+    Optional<String> match =
         FluentIterable
             .from(getCommitLinkInfo(getCommentLinkName()))
             .filter(new Predicate<CommentLinkInfo>() {
@@ -203,15 +204,16 @@
                 return input.match;
               }
             })
-            .last()
-            .or(gerritConfig.getString("commentlink", getCommentLinkName(),
-                "match"));
-    Pattern ret = null;
+            .last();
+    
+    String defPattern = gerritConfig.getString("commentlink", getCommentLinkName(),
+        "match");
 
-    if (match != null) {
-      ret = Pattern.compile(match);
+    if (!match.isPresent() && defPattern == null) {
+      return null;
     }
-    return ret;
+    
+    return Pattern.compile(match.or(defPattern));
   }
 
   /**
@@ -239,7 +241,7 @@
    */
   public ItsAssociationPolicy getItsAssociationPolicy() {
     ItsAssociationPolicy legacyItsAssociationPolicy =
-        gerritConfig.getEnum("commentLink", getCommentLinkName(),
+        gerritConfig.getEnum("commentlink", getCommentLinkName(),
             "association", ItsAssociationPolicy.OPTIONAL);
 
     return getPluginConfigEnum("association", legacyItsAssociationPolicy);
@@ -274,16 +276,16 @@
     return new PluginConfig(pluginName, new Config());
   }
 
-  private List<CommentLinkInfo> getCommitLinkInfo(final String commentLinkName) {
+  private List<CommentLinkInfo> getCommitLinkInfo(final String commentlinkName) {
     NameKey projectName = currentProjectName.get();
     if (projectName != null) {
-      List<CommentLinkInfo> commentLinks =
+      List<CommentLinkInfo> commentlinks =
           projectCache.get(projectName).getCommentLinks();
-      return FluentIterable.from(commentLinks)
+      return FluentIterable.from(commentlinks)
           .filter(new Predicate<CommentLinkInfo>() {
             @Override
             public boolean apply(CommentLinkInfo input) {
-              return input.name.equals(commentLinkName);
+              return input.name.equals(commentlinkName);
             }
           }).toList();
     }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfigTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfigTest.java
index 84c7bff..1b9e1bb 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfigTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfigTest.java
@@ -71,7 +71,7 @@
       expect(pluginConfigFactory.getFromProjectConfig(
           parentProjectState, "ItsTestName")).andReturn(parentPluginConfig);
 
-      expect(parentPluginConfig.getString("enabled")).andReturn(parentEnabled)
+      expect(parentPluginConfig.getString("enabled", "false")).andReturn(parentEnabled)
           .anyTimes();
 
       PluginConfig parentPluginConfigWI = createMock(PluginConfig.class);
@@ -93,15 +93,15 @@
     expect(pluginConfigFactory.getFromProjectConfig(
         projectState, "ItsTestName")).andReturn(pluginConfig).anyTimes();
 
-    expect(pluginConfig.getString("enabled")).andReturn(enabled).anyTimes();
+    expect(pluginConfig.getString("enabled", "false")).andReturn(enabled).anyTimes();
 
     PluginConfig pluginConfigWI = createMock(PluginConfig.class);
 
     expect(pluginConfigFactory.getFromProjectConfigWithInheritance(
         projectState, "ItsTestName")).andReturn(pluginConfigWI).anyTimes();
 
-    expect(pluginConfigWI.getBoolean("enabled", false))
-        .andReturn("true".equals(enabled)).anyTimes();
+    expect(pluginConfigWI.getString("enabled", "false"))
+        .andReturn(enabled).anyTimes();
 
     expect(pluginConfigWI.getStringList("branch")).andReturn(branches)
         .anyTimes();
@@ -514,7 +514,7 @@
   public void testGetIssuePatternNullMatch() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn(null).atLeastOnce();
     expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
         .andReturn(null).atLeastOnce();
@@ -528,7 +528,7 @@
   public void testGetIssuePatternNullMatchWCommentLink() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn("foo").atLeastOnce();
     expect(serverConfig.getString("commentlink", "foo", "match"))
         .andReturn(null).atLeastOnce();
@@ -542,7 +542,7 @@
   public void testGetIssuePattern() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn(null).atLeastOnce();
     expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
         .andReturn("TestPattern").atLeastOnce();
@@ -556,7 +556,7 @@
   public void testGetIssuePatternWCommentLink() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn("foo").atLeastOnce();
     expect(serverConfig.getString("commentlink", "foo", "match"))
         .andReturn("TestPattern").atLeastOnce();
@@ -571,11 +571,11 @@
   public void testGetIssuePatternGroupIndexGroupDefault() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn(null).atLeastOnce();
     expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
         .andReturn("(foo)(bar)(baz)").atLeastOnce();
-    expect(serverConfig.getInt("ItsTestName", "commentlinkGroupIndex", 1))
+    expect(serverConfig.getInt("plugin", "ItsTestName", "commentlinkGroupIndex", 1))
         .andReturn(1).atLeastOnce();
 
     replayMocks();
@@ -587,11 +587,11 @@
   public void testGetIssuePatternGroupIndexGroupDefaultGroupless() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn(null).atLeastOnce();
     expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
         .andReturn("foo").atLeastOnce();
-    expect(serverConfig.getInt("ItsTestName", "commentlinkGroupIndex", 1))
+    expect(serverConfig.getInt("plugin", "ItsTestName", "commentlinkGroupIndex", 1))
         .andReturn(1).atLeastOnce();
 
     replayMocks();
@@ -603,11 +603,11 @@
   public void testGetIssuePatternGroupIndexGroup1() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn(null).atLeastOnce();
     expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
         .andReturn("(foo)(bar)(baz)").atLeastOnce();
-    expect(serverConfig.getInt("ItsTestName", "commentlinkGroupIndex", 1))
+    expect(serverConfig.getInt("plugin", "ItsTestName", "commentlinkGroupIndex", 1))
         .andReturn(1).atLeastOnce();
 
     replayMocks();
@@ -619,11 +619,11 @@
   public void testGetIssuePatternGroupIndexGroup3() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn(null).atLeastOnce();
     expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
         .andReturn("(foo)(bar)(baz)").atLeastOnce();
-    expect(serverConfig.getInt("ItsTestName", "commentlinkGroupIndex", 1))
+    expect(serverConfig.getInt("plugin", "ItsTestName", "commentlinkGroupIndex", 1))
         .andReturn(3).atLeastOnce();
 
     replayMocks();
@@ -635,11 +635,11 @@
   public void testGetIssuePatternGroupIndexGroupTooHigh() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn(null).atLeastOnce();
     expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
         .andReturn("(foo)(bar)(baz)").atLeastOnce();
-    expect(serverConfig.getInt("ItsTestName", "commentlinkGroupIndex", 1))
+    expect(serverConfig.getInt("plugin", "ItsTestName", "commentlinkGroupIndex", 1))
         .andReturn(5).atLeastOnce();
 
     replayMocks();
@@ -651,11 +651,11 @@
   public void testGetIssuePatternGroupIndexGroupTooHighGroupless() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn(null).atLeastOnce();
     expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
         .andReturn("foo").atLeastOnce();
-    expect(serverConfig.getInt("ItsTestName", "commentlinkGroupIndex", 1))
+    expect(serverConfig.getInt("plugin", "ItsTestName", "commentlinkGroupIndex", 1))
         .andReturn(5).atLeastOnce();
 
     replayMocks();
@@ -667,12 +667,16 @@
   public void testGetItsAssociationPolicyOptional() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn(null).atLeastOnce();
     expect(serverConfig.getEnum("commentlink", "ItsTestName", "association",
         ItsAssociationPolicy.OPTIONAL))
         .andReturn(ItsAssociationPolicy.OPTIONAL)
         .atLeastOnce();
+    expect(serverConfig.getEnum("plugin", "ItsTestName", "association",
+        ItsAssociationPolicy.OPTIONAL))
+        .andReturn(ItsAssociationPolicy.OPTIONAL)
+        .atLeastOnce();
 
     replayMocks();
 
@@ -683,12 +687,16 @@
   public void testGetItsAssociationPolicyOptionalWCommentLink() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn("foo").atLeastOnce();
     expect(serverConfig.getEnum("commentlink", "foo", "association",
         ItsAssociationPolicy.OPTIONAL))
         .andReturn(ItsAssociationPolicy.OPTIONAL)
         .atLeastOnce();
+    expect(serverConfig.getEnum("plugin", "ItsTestName", "association",
+        ItsAssociationPolicy.OPTIONAL))
+        .andReturn(ItsAssociationPolicy.OPTIONAL)
+        .atLeastOnce();
 
     replayMocks();
 
@@ -699,13 +707,16 @@
   public void testGetItsAssociationPolicySuggested() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn(null).atLeastOnce();
     expect(serverConfig.getEnum("commentlink", "ItsTestName", "association",
         ItsAssociationPolicy.OPTIONAL))
         .andReturn(ItsAssociationPolicy.SUGGESTED)
         .atLeastOnce();
-
+    expect(serverConfig.getEnum("plugin", "ItsTestName", "association",
+        ItsAssociationPolicy.SUGGESTED))
+        .andReturn(ItsAssociationPolicy.SUGGESTED)
+        .atLeastOnce();
     replayMocks();
 
     assertEquals("Expected and generated associated policy do not match",
@@ -715,8 +726,12 @@
   public void testGetItsAssociationPolicySuggestedWCommentLink() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn("foo").atLeastOnce();
+    expect(serverConfig.getEnum("plugin", "ItsTestName", "association",
+        ItsAssociationPolicy.SUGGESTED))
+        .andReturn(ItsAssociationPolicy.SUGGESTED)
+        .atLeastOnce();
     expect(serverConfig.getEnum("commentlink", "foo", "association",
         ItsAssociationPolicy.OPTIONAL))
         .andReturn(ItsAssociationPolicy.SUGGESTED)
@@ -731,12 +746,16 @@
   public void testGetItsAssociationPolicyMandatory() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn(null).atLeastOnce();
     expect(serverConfig.getEnum("commentlink", "ItsTestName", "association",
         ItsAssociationPolicy.OPTIONAL))
         .andReturn(ItsAssociationPolicy.MANDATORY)
         .atLeastOnce();
+    expect(serverConfig.getEnum("plugin", "ItsTestName", "association",
+        ItsAssociationPolicy.MANDATORY))
+        .andReturn(ItsAssociationPolicy.MANDATORY)
+        .atLeastOnce();
 
     replayMocks();
 
@@ -747,12 +766,16 @@
   public void testGetItsAssociationPolicyMandatoryWCommentLink() {
     ItsConfig itsConfig = createItsConfig();
 
-    expect(serverConfig.getString("ItsTestName", null, "commentlink"))
+    expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
         .andReturn("foo").atLeastOnce();
     expect(serverConfig.getEnum("commentlink", "foo", "association",
         ItsAssociationPolicy.OPTIONAL))
         .andReturn(ItsAssociationPolicy.MANDATORY)
         .atLeastOnce();
+    expect(serverConfig.getEnum("plugin", "ItsTestName", "association",
+        ItsAssociationPolicy.MANDATORY))
+        .andReturn(ItsAssociationPolicy.MANDATORY)
+        .atLeastOnce();
 
     replayMocks();
 
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java
index 5a45dd4..ea38875 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java
@@ -18,6 +18,7 @@
 import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.config.FactoryModule;
 import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.server.IdentifiedUser;
 import com.google.gerrit.server.events.CommitReceivedEvent;
 import com.google.gerrit.server.git.validators.CommitValidationException;
 import com.google.gerrit.server.git.validators.CommitValidationMessage;
@@ -54,7 +55,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
 
     expect(itsConfig.getItsAssociationPolicy())
@@ -72,7 +73,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
 
     expect(itsConfig.getItsAssociationPolicy())
@@ -97,7 +98,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
 
     expect(itsConfig.getItsAssociationPolicy())
@@ -126,7 +127,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
     expect(itsConfig.getItsAssociationPolicy())
         .andReturn(ItsAssociationPolicy.SUGGESTED).atLeastOnce();
@@ -150,7 +151,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
 
     expect(itsConfig.getItsAssociationPolicy())
@@ -175,7 +176,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
 
     expect(itsConfig.getItsAssociationPolicy())
@@ -204,7 +205,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
 
     expect(itsConfig.getItsAssociationPolicy())
@@ -233,7 +234,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
 
     expect(itsConfig.getItsAssociationPolicy())
@@ -260,7 +261,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
 
     expect(itsConfig.getItsAssociationPolicy())
@@ -287,7 +288,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
 
     expect(itsConfig.getItsAssociationPolicy())
@@ -320,7 +321,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
 
     expect(itsConfig.getItsAssociationPolicy())
@@ -351,7 +352,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
 
     expect(itsConfig.getItsAssociationPolicy())
@@ -384,7 +385,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
 
     expect(itsConfig.getItsAssociationPolicy())
@@ -415,7 +416,7 @@
     ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
     ReceiveCommand command = createMock(ReceiveCommand.class);
     RevCommit commit = createMock(RevCommit.class);
-    CommitReceivedEvent event = new CommitReceivedEvent(command, project, null,
+    CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
         commit, null);
 
     expect(itsConfig.getItsAssociationPolicy())
@@ -481,6 +482,23 @@
     setupCommonMocks();
   }
 
+  private CommitReceivedEvent newCommitReceivedEvent(
+      ReceiveCommand command,
+      Project project,
+      String refName,
+      RevCommit commit,
+      IdentifiedUser user) {
+    CommitReceivedEvent event = createMock(CommitReceivedEvent.class);
+    event.command = command;
+    event.project = project;
+    event.refName = refName;
+    event.commit = commit;
+    event.user = user;
+    expect(event.getProjectNameKey()).andReturn(project.getNameKey()).anyTimes();
+    expect(event.getRefName()).andReturn(null).anyTimes();
+    return event;
+  }
+
   private class TestModule extends FactoryModule {
     @Override
     protected void configure() {