Adapt to Gerrit 2.11

Change-Id: Ica1ca7809e3d3d7df14d6b821b972ea273e12917
diff --git a/.travis.yml b/.travis.yml
index 15abc33..4baa578 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -26,7 +26,7 @@
   - ant
   - export PATH=$PATH:$TRAVIS_BUILD_DIR/../../build/buck/bin
   - cd ..
-  - git clone -b stable-2.10 https://gerrit.googlesource.com/gerrit
+  - git clone -b stable-2.11 https://gerrit.googlesource.com/gerrit
   - cd gerrit
   - ln -s $TRAVIS_BUILD_DIR plugins
   - travis_retry tools/download_all.py > download.log
diff --git a/README.md b/README.md
index 7831fb7..cace79e 100644
--- a/README.md
+++ b/README.md
@@ -11,4 +11,4 @@
 in different gerrit repositories. They will be merged at the same time,
 when all approvals for all reviews are present, and all reviews are mergeable.
 
-Requires Gerrit 2.10 or later.
+Requires Gerrit 2.11 or later.
diff --git a/src/main/java/com/criteo/gerrit/plugins/automerge/AtomicityHelper.java b/src/main/java/com/criteo/gerrit/plugins/automerge/AtomicityHelper.java
index 3f3196e..b910113 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/AtomicityHelper.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/AtomicityHelper.java
@@ -19,6 +19,7 @@
 import com.google.gerrit.server.git.MergeUtil;
 import com.google.gerrit.server.project.ChangeControl;
 import com.google.gerrit.server.project.NoSuchChangeException;
+import com.google.gerrit.server.project.SubmitRuleEvaluator;
 import com.google.gerrit.server.query.change.ChangeData;
 import com.google.gwtorm.server.OrmException;
 import com.google.inject.Inject;
@@ -107,7 +108,7 @@
    */
   public boolean isSubmittable(final int change) throws OrmException {
     final ChangeData changeData = changeDataFactory.create(db.get(), new Change.Id(change));
-    final List<SubmitRecord> cansubmit = changeData.changeControl().canSubmit(db.get(), changeData.currentPatchSet());
+    final List<SubmitRecord> cansubmit = new SubmitRuleEvaluator(changeData).evaluate();
     log.debug(String.format("Checking if change %d is submitable.", change));
     for (final SubmitRecord submit : cansubmit) {
       if (submit.status != SubmitRecord.Status.OK) {
diff --git a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java
index 4b293a6..b27e7cf 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java
@@ -15,11 +15,11 @@
 package com.criteo.gerrit.plugins.automerge;
 
 import com.google.common.collect.Lists;
-import com.google.gerrit.common.ChangeListener;
+import com.google.gerrit.common.EventListener;
 import com.google.gerrit.extensions.api.GerritApi;
 import com.google.gerrit.extensions.api.changes.ChangeApi;
 import com.google.gerrit.extensions.common.ChangeInfo;
-import com.google.gerrit.extensions.common.ListChangesOption;
+import com.google.gerrit.extensions.client.ListChangesOption;
 import com.google.gerrit.extensions.events.LifecycleListener;
 import com.google.gerrit.extensions.restapi.RestApiException;
 import com.google.gerrit.reviewdb.server.ReviewDb;
@@ -28,8 +28,8 @@
 import com.google.gerrit.server.change.Submit;
 import com.google.gerrit.server.data.ApprovalAttribute;
 import com.google.gerrit.server.data.ChangeAttribute;
-import com.google.gerrit.server.events.ChangeEvent;
 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.TopicChangedEvent;
 import com.google.gerrit.server.git.MergeUtil;
@@ -50,7 +50,7 @@
  * Starts at the same time as the gerrit server, and sets up our change hook
  * listener.
  */
-public class AutomaticMerger implements ChangeListener, LifecycleListener {
+public class AutomaticMerger implements EventListener, LifecycleListener {
 
   private final static Logger log = LoggerFactory.getLogger(AutomaticMerger.class);
 
@@ -85,7 +85,7 @@
   Submit submitter;
 
   @Override
-  synchronized public void onChangeEvent(final ChangeEvent event) {
+  synchronized public void onEvent(final Event event) {
     if (event instanceof TopicChangedEvent) {
       onTopicChanged((TopicChangedEvent)event);
     }
diff --git a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeModule.java b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeModule.java
index b5f180e..744bb2d 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeModule.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeModule.java
@@ -14,7 +14,7 @@
 
 package com.criteo.gerrit.plugins.automerge;
 
-import com.google.gerrit.common.ChangeListener;
+import com.google.gerrit.common.EventListener;
 import com.google.gerrit.extensions.registration.DynamicSet;
 import com.google.inject.AbstractModule;
 
@@ -27,7 +27,7 @@
 
   @Override
   protected void configure() {
-    DynamicSet.bind(binder(), ChangeListener.class).to(AutomaticMerger.class);
+    DynamicSet.bind(binder(), EventListener.class).to(AutomaticMerger.class);
     bind(AutomergeConfig.class).asEagerSingleton();
     bind(AtomicityHelper.class);
     bind(ReviewUpdater.class);