Fix compilation against latest master branch of Gerrit

ChangeListener was renamed to EventListener.

Also organize imports in the touched classes.

Change-Id: Ica986530b17e6461bf13d7d2992594b46a7d0fb9
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/ItsHookModule.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/ItsHookModule.java
index 52bca59..2504937 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/ItsHookModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/ItsHookModule.java
@@ -14,7 +14,7 @@
 
 package com.googlesource.gerrit.plugins.hooks;
 
-import com.google.gerrit.common.ChangeListener;
+import com.google.gerrit.common.EventListener;
 import com.google.gerrit.extensions.annotations.Exports;
 import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.registration.DynamicSet;
@@ -57,17 +57,17 @@
         .annotatedWith(Exports.named("enabled"))
         .toInstance(new ItsHookEnabledConfigEntry(pluginName, pluginCfgFactory));
     bind(ItsConfig.class);
-    DynamicSet.bind(binder(), ChangeListener.class).to(
+    DynamicSet.bind(binder(), EventListener.class).to(
         GerritHookFilterAddRelatedLinkToChangeId.class);
-    DynamicSet.bind(binder(), ChangeListener.class).to(
+    DynamicSet.bind(binder(), EventListener.class).to(
         GerritHookFilterAddComment.class);
-    DynamicSet.bind(binder(), ChangeListener.class).to(
+    DynamicSet.bind(binder(), EventListener.class).to(
         GerritHookFilterChangeState.class);
-    DynamicSet.bind(binder(), ChangeListener.class).to(
+    DynamicSet.bind(binder(), EventListener.class).to(
         GerritHookFilterAddRelatedLinkToGitWeb.class);
     DynamicSet.bind(binder(), CommitValidationListener.class).to(
         ItsValidateComment.class);
-    DynamicSet.bind(binder(), ChangeListener.class).to(
+    DynamicSet.bind(binder(), EventListener.class).to(
         ActionController.class);
     factory(ActionRequest.Factory.class);
     factory(Property.Factory.class);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/its/ItsConfig.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/its/ItsConfig.java
index 6fa5d9b..83ed535 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/its/ItsConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/its/ItsConfig.java
@@ -20,10 +20,10 @@
 import com.google.gerrit.server.config.PluginConfig;
 import com.google.gerrit.server.config.PluginConfigFactory;
 import com.google.gerrit.server.events.ChangeAbandonedEvent;
-import com.google.gerrit.server.events.ChangeEvent;
 import com.google.gerrit.server.events.ChangeMergedEvent;
 import com.google.gerrit.server.events.ChangeRestoredEvent;
 import com.google.gerrit.server.events.CommentAddedEvent;
+import com.google.gerrit.server.events.Event;
 import com.google.gerrit.server.events.PatchSetCreatedEvent;
 import com.google.gerrit.server.events.RefUpdatedEvent;
 import com.google.gerrit.server.project.ProjectCache;
@@ -49,7 +49,7 @@
     this.pluginCfgFactory = pluginCfgFactory;
   }
 
-  public boolean isEnabled(ChangeEvent event) {
+  public boolean isEnabled(Event event) {
     if (event instanceof PatchSetCreatedEvent) {
       PatchSetCreatedEvent e = (PatchSetCreatedEvent) event;
       return isEnabled(e.change.project, e.change.branch);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractor.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractor.java
index 77ef563..0f6f937 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractor.java
@@ -27,6 +27,7 @@
 import com.google.gerrit.server.events.ChangeRestoredEvent;
 import com.google.gerrit.server.events.CommentAddedEvent;
 import com.google.gerrit.server.events.DraftPublishedEvent;
+import com.google.gerrit.server.events.Event;
 import com.google.gerrit.server.events.PatchSetCreatedEvent;
 import com.google.gerrit.server.events.RefUpdatedEvent;
 import com.google.inject.Inject;
@@ -197,7 +198,7 @@
    * @param event The event to extract property sets from.
    * @return sets of property sets extracted from the event.
    */
-  public Set<Set<Property>> extractFrom(ChangeEvent event) {
+  public Set<Set<Property>> extractFrom(Event event) {
     Map<String,Set<String>> associations = null;
     Set<Set<Property>> ret = Sets.newHashSet();
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionController.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionController.java
index 9b5f4c6..885db3e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionController.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionController.java
@@ -14,23 +14,23 @@
 
 package com.googlesource.gerrit.plugins.hooks.workflow;
 
-import java.util.Collection;
-import java.util.Set;
-
-import com.google.gerrit.common.ChangeListener;
-import com.google.gerrit.server.events.ChangeEvent;
+import com.google.gerrit.common.EventListener;
+import com.google.gerrit.server.events.Event;
 import com.google.inject.Inject;
 
 import com.googlesource.gerrit.plugins.hooks.its.ItsConfig;
 import com.googlesource.gerrit.plugins.hooks.util.PropertyExtractor;
 
+import java.util.Collection;
+import java.util.Set;
+
 /**
  * Controller that takes actions according to {@code ChangeEvents@}.
  *
  * The taken actions are typically Its related (e.g.: adding an Its comment, or
  * changing an issue's status).
  */
-public class ActionController implements ChangeListener {
+public class ActionController implements EventListener {
   private final PropertyExtractor propertyExtractor;
   private final RuleBase ruleBase;
   private final ActionExecutor actionExecutor;
@@ -46,7 +46,7 @@
   }
 
   @Override
-  public void onChangeEvent(ChangeEvent event) {
+  public void onEvent(Event event) {
     if (!itsConfig.isEnabled(event)) {
       return;
     }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilter.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilter.java
index 6ab647c..da062bc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilter.java
@@ -14,17 +14,12 @@
 
 package com.googlesource.gerrit.plugins.hooks.workflow;
 
-import java.io.IOException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.gerrit.common.ChangeListener;
+import com.google.gerrit.common.EventListener;
 import com.google.gerrit.server.events.ChangeAbandonedEvent;
-import com.google.gerrit.server.events.ChangeEvent;
 import com.google.gerrit.server.events.ChangeMergedEvent;
 import com.google.gerrit.server.events.ChangeRestoredEvent;
 import com.google.gerrit.server.events.CommentAddedEvent;
+import com.google.gerrit.server.events.Event;
 import com.google.gerrit.server.events.PatchSetCreatedEvent;
 import com.google.gerrit.server.events.RefUpdatedEvent;
 import com.google.gwtorm.server.OrmException;
@@ -33,7 +28,12 @@
 import com.googlesource.gerrit.plugins.hooks.its.ItsConfig;
 import com.googlesource.gerrit.plugins.hooks.util.CommitMessageFetcher;
 
-public class GerritHookFilter implements ChangeListener {
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+public class GerritHookFilter implements EventListener {
   private static final Logger log = LoggerFactory.getLogger(GerritHookFilter.class);
 
   @Inject
@@ -69,7 +69,7 @@
   }
 
   @Override
-  public void onChangeEvent(ChangeEvent event) {
+  public void onEvent(Event event) {
     if (!itsConfig.isEnabled(event)) {
       return;
     }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractorTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractorTest.java
index bb3f7df..7657f24 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractorTest.java
@@ -15,14 +15,10 @@
 
 import static org.easymock.EasyMock.expect;
 
-import java.util.HashMap;
-import java.util.Set;
-
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.google.gerrit.reviewdb.client.Change;
 import com.google.gerrit.reviewdb.client.PatchSet;
-import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.config.FactoryModule;
 import com.google.gerrit.server.data.AccountAttribute;
 import com.google.gerrit.server.data.ApprovalAttribute;
@@ -30,21 +26,22 @@
 import com.google.gerrit.server.data.PatchSetAttribute;
 import com.google.gerrit.server.data.RefUpdateAttribute;
 import com.google.gerrit.server.events.ChangeAbandonedEvent;
-import com.google.gerrit.server.events.ChangeEvent;
 import com.google.gerrit.server.events.ChangeMergedEvent;
 import com.google.gerrit.server.events.ChangeRestoredEvent;
 import com.google.gerrit.server.events.CommentAddedEvent;
 import com.google.gerrit.server.events.DraftPublishedEvent;
+import com.google.gerrit.server.events.Event;
 import com.google.gerrit.server.events.PatchSetCreatedEvent;
 import com.google.gerrit.server.events.RefUpdatedEvent;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 
 import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
-import com.googlesource.gerrit.plugins.hooks.util.IssueExtractor;
-import com.googlesource.gerrit.plugins.hooks.util.PropertyExtractor;
 import com.googlesource.gerrit.plugins.hooks.workflow.Property;
 
+import java.util.HashMap;
+import java.util.Set;
+
 public class PropertyExtractorTest extends LoggingMockingTestCase {
   private Injector injector;
 
@@ -58,13 +55,13 @@
 
     Property property1 = createMock(Property.class);
     expect(propertyFactory.create("event", "com.googlesource.gerrit.plugins." +
-        "hooks.util.PropertyExtractorTest$DummyChangeEvent"))
+        "hooks.util.PropertyExtractorTest$DummyEvent"))
         .andReturn(property1);
 
     replayMocks();
 
     Set<Set<Property>> actual = propertyExtractor.extractFrom(
-        new DummyChangeEvent());
+        new DummyEvent());
 
     Set<Set<Property>> expected = Sets.newHashSet();
     assertEquals("Properties do not match", expected, actual);
@@ -375,7 +372,7 @@
     eventHelper(event, "RefUpdatedEvent", "ref-updated", common, false);
   }
 
-  private void eventHelper(ChangeEvent event, String className, String type,
+  private void eventHelper(Event event, String className, String type,
       Set<Property> common, boolean withRevision) {
     PropertyExtractor propertyExtractor = injector.getInstance(
         PropertyExtractor.class);
@@ -466,21 +463,9 @@
     }
   }
 
-  private class DummyChangeEvent extends ChangeEvent {
-	  public String getType() {
-		  return null;
-	  }
-
-	  public Project.NameKey getProjectNameKey() {
-		  return null;
-	  }
-
-	  public Change.Key getChangeKey() {
-		  return null;
-	  }
-
-	  public String getRefName() {
-		  return null;
-	  }
+  private class DummyEvent extends Event {
+    public DummyEvent() {
+      super(null);
+    }
   }
 }
\ No newline at end of file
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionControllerTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionControllerTest.java
index 7266d81..8819040 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionControllerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionControllerTest.java
@@ -23,6 +23,7 @@
 import com.google.common.collect.Sets;
 import com.google.gerrit.server.config.FactoryModule;
 import com.google.gerrit.server.events.ChangeEvent;
+import com.google.gerrit.server.events.Event;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 
@@ -48,7 +49,7 @@
 
     replayMocks();
 
-    actionController.onChangeEvent(event);
+    actionController.onEvent(event);
   }
 
   public void testNoActions() {
@@ -68,7 +69,7 @@
 
     replayMocks();
 
-    actionController.onChangeEvent(event);
+    actionController.onEvent(event);
   }
 
   public void testNoIssues() {
@@ -90,7 +91,7 @@
 
     replayMocks();
 
-    actionController.onChangeEvent(event);
+    actionController.onEvent(event);
   }
 
   public void testSinglePropertySetSingleActionSingleIssue() {
@@ -122,7 +123,7 @@
 
     replayMocks();
 
-    actionController.onChangeEvent(event);
+    actionController.onEvent(event);
   }
 
   public void testMultiplePropertySetsMultipleActionMultipleIssue() {
@@ -175,7 +176,7 @@
 
     replayMocks();
 
-    actionController.onChangeEvent(event);
+    actionController.onEvent(event);
   }
   private ActionController createActionController() {
     return injector.getInstance(ActionController.class);
@@ -200,7 +201,7 @@
 
       bind(ItsConfig.class).toInstance(new ItsConfig(null, null, null) {
         @Override
-        public boolean isEnabled(ChangeEvent event) {
+        public boolean isEnabled(Event event) {
           return true;
         }
       });