Merge branch 'stable-2.16' into stable-3.0

* stable-2.16:
  Fix the testAllNumericUserGroup all-numeric username
  Test all-numeric username

Change-Id: I26b459a5c835f1fbf8d3d07107881fb1952ecc27
diff --git a/src/main/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroup.java b/src/main/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroup.java
index 59e78e0..5b2bed9 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroup.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroup.java
@@ -23,6 +23,7 @@
 import com.google.gerrit.common.Nullable;
 import com.google.gerrit.common.data.GroupDescription;
 import com.google.gerrit.common.data.GroupReference;
+import com.google.gerrit.exceptions.StorageException;
 import com.google.gerrit.extensions.registration.DynamicSet;
 import com.google.gerrit.index.query.QueryParseException;
 import com.google.gerrit.reviewdb.client.Account;
@@ -39,7 +40,6 @@
 import com.google.gerrit.server.query.account.AccountPredicates;
 import com.google.gerrit.server.query.account.AccountQueryBuilder;
 import com.google.gerrit.server.query.account.AccountQueryProcessor;
-import com.google.gwtorm.server.OrmException;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
@@ -149,7 +149,7 @@
           .query(AccountPredicates.andActive(queryBuilder.defaultQuery(name))).entities().stream()
           .map(SingleUserGroup::accountToGroup)
           .collect(toList());
-    } catch (OrmException | QueryParseException err) {
+    } catch (StorageException | QueryParseException err) {
       logger.atWarning().withCause(err).log("Cannot suggest users");
       return Collections.emptyList();
     }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroupTest.java b/src/test/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroupTest.java
index e24db66..8d18233 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroupTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroupTest.java
@@ -20,6 +20,7 @@
 import com.google.gerrit.acceptance.NoHttpd;
 import com.google.gerrit.acceptance.TestAccount;
 import com.google.gerrit.acceptance.TestPlugin;
+import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations;
 import com.google.gerrit.common.data.GroupDescription;
 import com.google.gerrit.extensions.common.GroupInfo;
 import com.google.gerrit.reviewdb.client.AccountGroup;
@@ -34,12 +35,14 @@
     name = "singleusergroup",
     sysModule = "com.googlesource.gerrit.plugins.singleusergroup.SingleUserGroup$Module")
 public class SingleUserGroupTest extends LightweightPluginDaemonTest {
+  @Inject private RequestScopeOperations requestScopeOperations;
+
   @Inject private GroupBackend groupBackend;
 
   @Test
   public void testSuggestion() throws Exception {
     // No ability to modify account and therefore no ACL to see secondary email
-    setApiUser(user);
+    requestScopeOperations.setApiUser(user.id());
     Map<String, GroupInfo> groups = gApi.groups().list().withSuggest("adm").getAsMap();
     assertThat(groups).containsKey("user/Administrator (admin)");
   }
@@ -48,7 +51,7 @@
   public void testAllNumericUserGroup() throws Exception {
     String numericUsername = "123456";
     TestAccount numericAccount = accountCreator.create(numericUsername);
-    IdentifiedUser numericUser = identifiedUserFactory.create(numericAccount.getId());
+    IdentifiedUser numericUser = identifiedUserFactory.create(numericAccount.id());
 
     GroupDescription.Basic numericUserGroup =
         groupBackend.get(AccountGroup.UUID.parse("user:" + numericUsername));