ForwardedIndexGroupHandler: do not use UUID as key

The AccountGroup.UUID is based on the GWT-ORM hierarchy
and uses static methods for its printing.

The GWT-ORM stack is not used anymore and there is no reason
why we should be relying on it in our code. The Gerrit API
still rely on the UUID class for reindeixng, so materialise
the strings at the very last moment.

This fixes random NPEs in tests.

Change-Id: I64edc597940f25597cb18488165eaedfe90bbf12
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandler.java
index c89a9d5..700397d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandler.java
@@ -32,7 +32,7 @@
  */
 @Singleton
 public class ForwardedIndexGroupHandler
-    extends ForwardedIndexingHandler<AccountGroup.UUID, GroupIndexEvent> {
+    extends ForwardedIndexingHandler<String, GroupIndexEvent> {
   private final GroupIndexer indexer;
 
   @Inject
@@ -42,14 +42,14 @@
   }
 
   @Override
-  protected void doIndex(AccountGroup.UUID uuid, Optional<GroupIndexEvent> event)
+  protected void doIndex(String uuid, Optional<GroupIndexEvent> event)
       throws IOException, OrmException {
-    indexer.index(uuid);
+    indexer.index(new AccountGroup.UUID(uuid));
     log.debug("Group {} successfully indexed", uuid);
   }
 
   @Override
-  protected void doDelete(AccountGroup.UUID uuid, Optional<GroupIndexEvent> event) {
+  protected void doDelete(String uuid, Optional<GroupIndexEvent> event) {
     throw new UnsupportedOperationException("Delete from group index not supported");
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/IndexEventRouter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/IndexEventRouter.java
index 2c637d8..1f2a882 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/IndexEventRouter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/kafka/router/IndexEventRouter.java
@@ -70,7 +70,7 @@
     } else if (sourceEvent instanceof GroupIndexEvent) {
       GroupIndexEvent groupIndexEvent = (GroupIndexEvent) sourceEvent;
       indexGroupHandler.index(
-          new AccountGroup.UUID(groupIndexEvent.groupUUID), INDEX, Optional.of(groupIndexEvent));
+          groupIndexEvent.groupUUID, INDEX, Optional.of(groupIndexEvent));
     } else if (sourceEvent instanceof ProjectIndexEvent) {
       ProjectIndexEvent projectIndexEvent = (ProjectIndexEvent) sourceEvent;
       indexProjectHandler.index(
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 d47643a..9013646 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
@@ -43,20 +43,20 @@
   @Mock private Configuration config;
   @Mock private Configuration.Index index;
   private ForwardedIndexGroupHandler handler;
-  private AccountGroup.UUID uuid;
+  private String uuid;
 
   @Before
   public void setUp() throws Exception {
     when(config.index()).thenReturn(index);
     when(index.numStripedLocks()).thenReturn(10);
     handler = new ForwardedIndexGroupHandler(indexerMock, config);
-    uuid = new AccountGroup.UUID("123");
+    uuid = "123";
   }
 
   @Test
   public void testSuccessfulIndexing() throws Exception {
     handler.index(uuid, Operation.INDEX, Optional.empty());
-    verify(indexerMock).index(uuid);
+    verify(indexerMock).index(new AccountGroup.UUID(uuid));
   }
 
   @Test
@@ -77,13 +77,13 @@
                   return null;
                 })
         .when(indexerMock)
-        .index(uuid);
+        .index(new AccountGroup.UUID(uuid));
 
     assertThat(Context.isForwardedEvent()).isFalse();
     handler.index(uuid, Operation.INDEX, Optional.empty());
     assertThat(Context.isForwardedEvent()).isFalse();
 
-    verify(indexerMock).index(uuid);
+    verify(indexerMock).index(new AccountGroup.UUID(uuid));
   }
 
   @Test
@@ -95,7 +95,7 @@
                   throw new IOException("someMessage");
                 })
         .when(indexerMock)
-        .index(uuid);
+        .index(new AccountGroup.UUID(uuid));
 
     assertThat(Context.isForwardedEvent()).isFalse();
     try {
@@ -106,6 +106,6 @@
     }
     assertThat(Context.isForwardedEvent()).isFalse();
 
-    verify(indexerMock).index(uuid);
+    verify(indexerMock).index(new AccountGroup.UUID(uuid));
   }
 }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/kafka/consumer/IndexEventRouterTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/kafka/consumer/IndexEventRouterTest.java
index 26a665d..773c635 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/kafka/consumer/IndexEventRouterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/kafka/consumer/IndexEventRouterTest.java
@@ -76,7 +76,7 @@
 
     verify(indexGroupHandler)
         .index(
-            new AccountGroup.UUID(groupId),
+            groupId,
             ForwardedIndexingHandler.Operation.INDEX,
             Optional.of(event));