Do not ignore DraftPublishedEvent anymore

It was always considered as not enabled.

Change-Id: If5a2a4a968559bf7b8c5736ac08d13638c8655a3
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 57fe4d2..4eee049 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
@@ -24,6 +24,7 @@
 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;
@@ -76,6 +77,9 @@
     } else if (event instanceof ChangeRestoredEvent) {
       ChangeRestoredEvent e = (ChangeRestoredEvent) event;
       return isEnabled(e.change.project, e.getRefName());
+    } else if (event instanceof DraftPublishedEvent) {
+      DraftPublishedEvent e = (DraftPublishedEvent) event;
+      return isEnabled(e.change.project, e.getRefName());
     } else if (event instanceof RefUpdatedEvent) {
       RefUpdatedEvent e = (RefUpdatedEvent) event;
       return isEnabled(e.refUpdate.project, e.refUpdate.refName);
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 a278752..22bc4ee 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
@@ -23,7 +23,16 @@
 import com.google.gerrit.server.config.PluginConfig;
 import com.google.gerrit.server.config.PluginConfigFactory;
 import com.google.gerrit.server.data.ChangeAttribute;
+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.PatchSetCreatedEvent;
+import com.google.gerrit.server.events.RefUpdatedEvent;
+import com.google.gerrit.server.events.TopicChangedEvent;
 import com.google.gerrit.server.project.ProjectCache;
 import com.google.gerrit.server.project.ProjectState;
 import com.google.inject.Guice;
@@ -409,6 +418,73 @@
     assertFalse(itsConfig.isEnabled(event));
   }
 
+  public void testIsEnabledCommentAddedEvent() {
+    testIsEnabledEvent(CommentAddedEvent.class);
+  }
+
+  public void testIsEnabledChangeMergedEvent() {
+    testIsEnabledEvent(ChangeMergedEvent.class);
+  }
+
+  public void testIsEnabledChangeAbandonedEvent() {
+    testIsEnabledEvent(ChangeAbandonedEvent.class);
+  }
+
+  public void testIsEnabledChangeRestoredEvent() {
+    testIsEnabledEvent(ChangeRestoredEvent.class);
+  }
+
+  public void testIsEnabledDraftPublishedEvent() {
+    testIsEnabledEvent(DraftPublishedEvent.class);
+  }
+
+  private <T extends ChangeEvent> void testIsEnabledEvent(Class<T> clazz) {
+    try {
+      String[] branches = {};
+      setupIsEnabled("true", null, branches);
+
+      T event = clazz.newInstance();
+      event.change = new ChangeAttribute();
+      event.change.project = "testProject";
+      event.change.branch = "testBranch";
+
+      ItsConfig itsConfig = createItsConfig();
+
+      replayMocks();
+
+      assertTrue(itsConfig.isEnabled(event));
+    } catch (InstantiationException | IllegalAccessException e) {
+      throw new RuntimeException("Unable to implement event class " + clazz.getCanonicalName(), e);
+    }
+  }
+
+  public void testIsEnabledRefUpdatedEvent() {
+    String[] branches = {};
+    setupIsEnabled("true", null, branches);
+
+    RefUpdatedEvent event = new RefUpdatedEvent();
+    event.refUpdate = new RefUpdateAttribute();
+    event.refUpdate.project = "testProject";
+    event.refUpdate.refName = "refs/heads/testBranch";
+
+    ItsConfig itsConfig = createItsConfig();
+
+    replayMocks();
+
+    assertTrue(itsConfig.isEnabled(event));
+  }
+
+  public void testIsIgnoredTopicChangedEvent() {
+    TopicChangedEvent event = new TopicChangedEvent();
+
+    ItsConfig itsConfig = createItsConfig();
+
+    replayMocks();
+
+    assertFalse(itsConfig.isEnabled(event));
+    assertLogMessageContains("not recognised and ignored");
+  }
+
   public void testGetIssuePatternNullMatch() {
     ItsConfig itsConfig = createItsConfig();