Fix test failures at head.

Group uuid code copied from Groups acceptance tests no good in this
context.

Change-Id: I73abe808d046753d788fb9a42f47ee2025edfdf8
diff --git a/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightConfigIT.java b/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightConfigIT.java
index 3b5d5f4..7a31f07 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightConfigIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightConfigIT.java
@@ -33,18 +33,13 @@
 import com.google.gerrit.acceptance.PushOneCommit;
 import com.google.gerrit.acceptance.TestAccount;
 import com.google.gerrit.acceptance.TestPlugin;
+import com.google.gerrit.extensions.api.GerritApi;
+import com.google.gerrit.extensions.common.GroupInfo;
 import com.google.gerrit.reviewdb.client.AccountGroup;
 import com.google.gerrit.reviewdb.client.Comment;
 import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.reviewdb.client.RefNames;
-import com.google.gerrit.server.ServerInitiated;
-import com.google.gerrit.server.group.InternalGroup;
-import com.google.gerrit.server.group.db.GroupsUpdate;
-import com.google.gerrit.server.group.db.InternalGroupCreation;
-import com.google.gerrit.server.group.db.InternalGroupUpdate;
 import com.google.inject.Inject;
-import com.google.inject.Provider;
-import java.util.Optional;
 import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
 import org.eclipse.jgit.junit.TestRepository;
 import org.junit.Before;
@@ -104,8 +99,7 @@
   })
   public void testCopyrightConfig_pushWithSenderNoName() throws Exception {
     TestAccount anonymous =
-        accountCreator.create(
-            "copyright-scan", "", "", "Non-Interactive Users", expertGroup.getName());
+        accountCreator.create("copyright-scan", "", "", "Non-Interactive Users", expertGroup.name);
     testConfig.updatePlugin(
         cfg -> {
           cfg.setInt(KEY_FROM, anonymous.id().get());
@@ -305,29 +299,29 @@
 
   private static int nextId = 123;
 
-  @Inject @ServerInitiated private Provider<GroupsUpdate> groupsUpdateProvider;
-
   private TestAccount sender;
   private TestAccount reviewer;
   private TestAccount observer;
-  private InternalGroup botGroup;
-  private InternalGroup expertGroup;
+  private GroupInfo botGroup;
+  private GroupInfo expertGroup;
   private TestConfig testConfig;
 
+  @Inject GerritApi gApi;
+
   @Before
   public void setUp() throws Exception {
-    botGroup = testGroup("Non-Interactive Users");
-    expertGroup = testGroup("Copyright Experts");
+    botGroup = gApi.groups().id("Non-Interactive Users").detail();
+    expertGroup = gApi.groups().create("Copyright Experts").detail();
     sender =
         accountCreator.create(
             "copyright-scanner",
             "copyright-scanner@example.com",
             "Copyright Scanner",
             "Non-Interactive Users",
-            expertGroup.getName());
+            expertGroup.name);
     reviewer =
         accountCreator.create(
-            "lawyercat", "legal@example.com", "J. Doe J.D. LL.M. Esq.", expertGroup.getName());
+            "lawyercat", "legal@example.com", "J. Doe J.D. LL.M. Esq.", expertGroup.name);
     observer = accountCreator.create("my-team", "my-team@example.com", "My Team");
     testRepo = getTestRepo(allProjects);
     testConfig = new TestConfig(allProjects, plugin.getName(), admin, testRepo);
@@ -336,7 +330,7 @@
         RefNames.REFS_HEADS + "*",
         "Copyright-Review",
         new TestConfig.Voter("Administrators", -2, +2),
-        new TestConfig.Voter(expertGroup.getNameKey().get(), -2, +2),
+        new TestConfig.Voter(expertGroup.name, -2, +2),
         new TestConfig.Voter("Registered Users", -2, 0));
     testConfig.addGroups(botGroup, expertGroup);
     testConfig.updatePlugin(
@@ -365,23 +359,6 @@
     return testRepo;
   }
 
-  private InternalGroup testGroup(String name) throws Exception {
-    AccountGroup.NameKey nameKey = AccountGroup.nameKey(name);
-    Optional<InternalGroup> g = groupCache.get(nameKey);
-    if (g.isPresent()) {
-      return g.get();
-    }
-    GroupsUpdate groupsUpdate = groupsUpdateProvider.get();
-    InternalGroupCreation gc =
-        InternalGroupCreation.builder()
-            .setGroupUUID(AccountGroup.uuid("users-" + name.replace(" ", "_")))
-            .setNameKey(nameKey)
-            .setId(nextGroupId())
-            .build();
-    InternalGroupUpdate gu = InternalGroupUpdate.builder().setName(nameKey).build();
-    return groupsUpdate.createGroup(gc, gu);
-  }
-
   private static Correspondence<Comment, String> warningContains() {
     return new Correspondence<Comment, String>() {
       @Override
diff --git a/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightValidatorIT.java b/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightValidatorIT.java
index 61bfb8e..304e87f 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightValidatorIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightValidatorIT.java
@@ -29,19 +29,14 @@
 import com.google.gerrit.acceptance.PushOneCommit;
 import com.google.gerrit.acceptance.TestAccount;
 import com.google.gerrit.acceptance.TestPlugin;
+import com.google.gerrit.extensions.api.GerritApi;
+import com.google.gerrit.extensions.common.GroupInfo;
 import com.google.gerrit.reviewdb.client.AccountGroup;
 import com.google.gerrit.reviewdb.client.Change;
 import com.google.gerrit.reviewdb.client.Comment;
 import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.reviewdb.client.RefNames;
-import com.google.gerrit.server.ServerInitiated;
-import com.google.gerrit.server.group.InternalGroup;
-import com.google.gerrit.server.group.db.GroupsUpdate;
-import com.google.gerrit.server.group.db.InternalGroupCreation;
-import com.google.gerrit.server.group.db.InternalGroupUpdate;
 import com.google.inject.Inject;
-import com.google.inject.Provider;
-import java.util.Optional;
 import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
 import org.eclipse.jgit.junit.TestRepository;
 import org.junit.Before;
@@ -349,30 +344,30 @@
 
   private static int nextId = 123;
 
-  @Inject @ServerInitiated private Provider<GroupsUpdate> groupsUpdateProvider;
-
-  private InternalGroup botGroup;
-  private InternalGroup expertGroup;
+  private GroupInfo botGroup;
+  private GroupInfo expertGroup;
   private TestAccount pluginAccount;
   private TestAccount reviewer;
   private TestAccount observer;
   private TestAccount author;
   private String projectConfigContent;
 
+  @Inject GerritApi gApi;
+
   @Before
   public void setUp() throws Exception {
-    botGroup = testGroup("Non-Interactive Users");
-    expertGroup = testGroup("Copyright Experts");
+    botGroup = gApi.groups().id("Non-Interactive Users").detail();
+    expertGroup = gApi.groups().create("Copyright Experts").detail();
     pluginAccount =
         accountCreator.create(
             "copyright-scanner",
             "copyright-scanner@example.com",
             "Copyright Scanner",
             "Non-Interactive Users",
-            expertGroup.getName());
+            expertGroup.name);
     reviewer =
         accountCreator.create(
-            "lawyercat", "legal@example.com", "J. Doe J.D. LL.M. Esq.", expertGroup.getName());
+            "lawyercat", "legal@example.com", "J. Doe J.D. LL.M. Esq.", expertGroup.name);
     observer = accountCreator.create("my-team", "my-team@example.com", "My Team");
     author = accountCreator.create("author", "author@example.com", "J. Doe");
     TestRepository<InMemoryRepository> testRepo = getTestRepo(allProjects);
@@ -382,7 +377,7 @@
         RefNames.REFS_HEADS + "*",
         "Copyright-Review",
         new TestConfig.Voter("Administrators", -2, +2),
-        new TestConfig.Voter(expertGroup.getNameKey().get(), -2, +2),
+        new TestConfig.Voter(expertGroup.name, -2, +2),
         new TestConfig.Voter("Registered Users", -2, 0));
     testConfig.addGroups(botGroup, expertGroup);
     testConfig.updatePlugin(
@@ -415,36 +410,19 @@
     return testRepo;
   }
 
-  private InternalGroup testGroup(String name) throws Exception {
-    AccountGroup.NameKey nameKey = AccountGroup.nameKey(name);
-    Optional<InternalGroup> g = groupCache.get(nameKey);
-    if (g.isPresent()) {
-      return g.get();
-    }
-    GroupsUpdate groupsUpdate = groupsUpdateProvider.get();
-    InternalGroupCreation gc =
-        InternalGroupCreation.builder()
-            .setGroupUUID(AccountGroup.uuid("users-" + name.replace(" ", "_")))
-            .setNameKey(nameKey)
-            .setId(nextGroupId())
-            .build();
-    InternalGroupUpdate gu = InternalGroupUpdate.builder().setName(nameKey).build();
-    return groupsUpdate.createGroup(gc, gu);
-  }
-
   private void assertReviewerAdded(PushOneCommit.Result result) throws Exception {
     result.assertOkStatus();
     result.assertChange(
         Change.Status.NEW,
         null,
-        ImmutableList.of(author, reviewer),
-        ImmutableList.of(pluginAccount, observer));
+        ImmutableList.of(author, reviewer, pluginAccount),
+        ImmutableList.of(observer));
   }
 
   private void assertNoReviewerAdded(PushOneCommit.Result result) throws Exception {
     result.assertOkStatus();
     result.assertChange(
-        Change.Status.NEW, null, ImmutableList.of(author), ImmutableList.of(pluginAccount));
+        Change.Status.NEW, null, ImmutableList.of(author, pluginAccount), ImmutableList.of());
   }
 
   private CommentMatch resolved(String content) {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/copyright/TestConfig.java b/src/test/java/com/googlesource/gerrit/plugins/copyright/TestConfig.java
index f8aab70..f35cbc0 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/copyright/TestConfig.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/copyright/TestConfig.java
@@ -31,10 +31,11 @@
 import com.google.gerrit.acceptance.PushOneCommit;
 import com.google.gerrit.acceptance.TestAccount;
 import com.google.gerrit.common.data.GroupReference;
+import com.google.gerrit.extensions.common.GroupInfo;
+import com.google.gerrit.reviewdb.client.AccountGroup;
 import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.reviewdb.client.RefNames;
 import com.google.gerrit.server.config.PluginConfig;
-import com.google.gerrit.server.group.InternalGroup;
 import com.google.gerrit.server.project.GroupList;
 import com.google.gerrit.server.project.ProjectConfig;
 import java.util.Arrays;
@@ -117,13 +118,13 @@
       };
 
   /** Adds {@code groups} to the groups file. */
-  void addGroups(InternalGroup... groups) throws Exception {
+  void addGroups(GroupInfo... groups) throws Exception {
     if (groups == null) {
       return;
     }
-    for (InternalGroup group : groups) {
-      groupList.put(
-          group.getGroupUUID(), new GroupReference(group.getGroupUUID(), group.getNameKey().get()));
+    for (GroupInfo group : groups) {
+      AccountGroup.UUID uuid = AccountGroup.uuid(group.id);
+      groupList.put(uuid, new GroupReference(uuid, group.name));
     }
   }