EventConsumerIT: Support ReviewDb and NoteDb backends

When NoteDb mode is used more ref updated events are triggered.

Test Plan:

1. Run tests in ReviewDb mode:
  $ bazel test plugins/kafka-events:kafka_events_tests

2. Run tests in NoteDb mode:
  $ bazel test --test_env=GERRIT_NOTEDB=READ_WRITE \
      plugins/kafka-events:kafka_events_tests

Change-Id: I96d9602d978c419c5fcc753015d6b01ed6cf620b
diff --git a/src/test/java/com/googlesource/gerrit/plugins/kafka/EventConsumerIT.java b/src/test/java/com/googlesource/gerrit/plugins/kafka/EventConsumerIT.java
index 9007e91..30d7a11 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/kafka/EventConsumerIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/kafka/EventConsumerIT.java
@@ -17,6 +17,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import com.google.common.base.Supplier;
+import com.google.common.collect.Iterables;
 import com.google.gerrit.acceptance.GerritConfig;
 import com.google.gerrit.acceptance.LightweightPluginDaemonTest;
 import com.google.gerrit.acceptance.NoHttpd;
@@ -103,16 +104,23 @@
       }
     }
 
-    // The received 6 events in order:
-    //
-    // 1. refUpdate:        ref: refs/sequences/changes
-    // 2. refUpdate:        ref: refs/changes/01/1/1
-    // 3. refUpdate:        ref: refs/changes/01/1/meta
-    // 4. patchset-created: ref: refs/changes/01/1/1
-    // 5. refUpdate:        ref: refs/changes/01/1/meta"
-    // 6. comment-added:    ref: refs/heads/master
-    assertThat(events).hasSize(6);
-    String commentAddedEventJson = events.get(5);
+    // TODO(davido): Remove special ReviewDb case when it is killed
+    // In ReviewDb case 3 events are received in the following order:
+    // 1. refUpdate:          ref: refs/changes/01/1/1
+    // 2. patchset-created:   ref: refs/changes/01/1/1
+    // 3. comment-added:      ref: refs/heads/master
+    int numberOfEvents = 3;
+    if (notesMigration.commitChangeWrites()) {
+      // In NoteDb case the 4 events are received in the following order:
+      // 1. refUpdate:        ref: refs/sequences/changes
+      // 2. refUpdate:        ref: refs/changes/01/1/1
+      // 3. patchset-created: ref: refs/changes/01/1/1
+      // 4. comment-added:    ref: refs/heads/master
+      numberOfEvents = 4;
+    }
+
+    assertThat(events).hasSize(numberOfEvents);
+    String commentAddedEventJson = Iterables.getLast(events);
 
     Gson gson =
         new GsonBuilder()