Merge "Merge branch 'stable-3.0' into stable-3.1" into stable-3.1
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandlerTest.java
index 982ac52..24cbbc2 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandlerTest.java
@@ -143,4 +143,28 @@
   private Optional<GroupIndexEvent> groupIndexEvent(String uuid) {
     return Optional.of(new GroupIndexEvent(uuid, null));
   }
+
+  @Test
+  public void shouldChangeIndexEventWheNotUpToDate() throws IOException {
+    ForwardedIndexGroupHandler groupHandlerWithOutdatedEvent = groupHandler(false);
+    groupHandlerWithOutdatedEvent.index(uuid, Operation.INDEX, groupIndexEvent(uuid));
+    verify(indexerMock).index(new AccountGroup.UUID(uuid));
+  }
+
+  @Test
+  public void shouldRescheduleGroupIndexingWhenItIsNotUpToDate() throws IOException {
+    ForwardedIndexGroupHandler groupHandlerWithOutdatedEvent = groupHandler(false);
+    groupHandlerWithOutdatedEvent.index(uuid, Operation.INDEX, groupIndexEvent(uuid));
+    verify(indexExecutorMock)
+        .schedule(any(Runnable.class), eq(new Long(RETRY_INTERVAL)), eq(TimeUnit.MILLISECONDS));
+  }
+
+  private ForwardedIndexGroupHandler groupHandler(boolean checkIsUpToDate) {
+    return new ForwardedIndexGroupHandler(
+        indexerMock, config, new TestGroupChecker(checkIsUpToDate), indexExecutorMock);
+  }
+
+  private Optional<GroupIndexEvent> groupIndexEvent(String uuid) {
+    return Optional.of(new GroupIndexEvent(uuid, null));
+  }
 }