Merge branch 'stable-2.16' into stable-3.0
* stable-2.16:
SingleUserGroupTest: Remove unnecessary groupBackend member
Change-Id: I6e091ea1d7381ddc176948aa3def7de4adc879db
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 89c466b..678418c 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroupTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/singleusergroup/SingleUserGroupTest.java
@@ -20,10 +20,12 @@
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;
import com.google.gerrit.server.IdentifiedUser;
+import com.google.inject.Inject;
import java.util.Map;
import org.junit.Test;
@@ -32,10 +34,12 @@
name = "singleusergroup",
sysModule = "com.googlesource.gerrit.plugins.singleusergroup.SingleUserGroup$Module")
public class SingleUserGroupTest extends LightweightPluginDaemonTest {
+ @Inject private RequestScopeOperations requestScopeOperations;
+
@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)");
}
@@ -44,7 +48,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));