Merge branch 'stable-3.0' into stable-3.1

* stable-3.0:
  Introduce a configuration to define time lapse for rate limiter
  Upgrade bazlets to latest stable-3.0 to build with 3.0.15 API
  Upgrade bazlets to latest stable-2.16 to build with 2.16.26 API
  Upgrade bazlets to latest stable-2.16 to build with 2.16.23 API

Conflict resolution for WORKSPACE is to keep the original bazlets
version. Also, adjust the test to use project.nameKeys instead of new
Project.NameKeys.

Change-Id: Ic5af1ac3006d66884ed5d257bacee8a5f26a3b69
diff --git a/.gitignore b/.gitignore
index 9a6a3fa..045b49d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
 /.primary_build_tool
 /bazel-*
 /eclipse-out/
+/.apt_generated/
diff --git a/WORKSPACE b/WORKSPACE
index e929d4a..5720e36 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
 load("//:bazlets.bzl", "load_bazlets")
 
 load_bazlets(
-    commit = "a029d8e41d6211c8b23052aa0a0c2c7649577e85",
+    commit = "87fd5f0d0a89d01df13deaf2d21a4bdb3bc03cfd",
     #local_path = "/home/<user>/projects/bazlets",
 )
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/Configuration.java b/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/Configuration.java
index c05a01b..bb6db02 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/Configuration.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/Configuration.java
@@ -18,8 +18,8 @@
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Table;
 import com.google.gerrit.common.data.GroupDescription.Basic;
+import com.google.gerrit.entities.AccountGroup;
 import com.google.gerrit.extensions.annotations.PluginName;
-import com.google.gerrit.reviewdb.client.AccountGroup;
 import com.google.gerrit.server.config.PluginConfigFactory;
 import com.google.gerrit.server.group.GroupResolver;
 import com.google.inject.Inject;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/RateLimitFinder.java b/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/RateLimitFinder.java
index 173d1fc..4375f1a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/RateLimitFinder.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/RateLimitFinder.java
@@ -16,7 +16,7 @@
 
 import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
 
-import com.google.gerrit.reviewdb.client.AccountGroup;
+import com.google.gerrit.entities.AccountGroup;
 import com.google.gerrit.server.IdentifiedUser;
 import com.google.gerrit.server.account.GroupMembership;
 import com.google.gerrit.server.group.SystemGroupBackend;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/RateLimitUploadPack.java b/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/RateLimitUploadPack.java
index 3af4f5b..fddb2ec 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/RateLimitUploadPack.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/RateLimitUploadPack.java
@@ -18,7 +18,7 @@
 import static com.googlesource.gerrit.plugins.ratelimiter.Module.UPLOAD_PACK_PER_HOUR;
 
 import com.google.common.cache.LoadingCache;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.server.CurrentUser;
 import com.google.gerrit.server.git.validators.UploadValidationListener;
 import com.google.gerrit.server.validators.ValidationException;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/ReplenishCommand.java b/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/ReplenishCommand.java
index f86784f..a4646d5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/ReplenishCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/ReplenishCommand.java
@@ -19,9 +19,9 @@
 
 import com.google.common.cache.LoadingCache;
 import com.google.gerrit.common.data.GlobalCapability;
+import com.google.gerrit.entities.Account;
 import com.google.gerrit.extensions.annotations.CapabilityScope;
 import com.google.gerrit.extensions.annotations.RequiresCapability;
-import com.google.gerrit.reviewdb.client.Account;
 import com.google.gerrit.sshd.CommandMetaData;
 import com.google.gerrit.sshd.SshCommand;
 import com.google.inject.Inject;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/UserResolver.java b/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/UserResolver.java
index 11dffed..0e79529 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/UserResolver.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/ratelimiter/UserResolver.java
@@ -14,7 +14,7 @@
 
 package com.googlesource.gerrit.plugins.ratelimiter;
 
-import com.google.gerrit.reviewdb.client.Account;
+import com.google.gerrit.entities.Account;
 import com.google.gerrit.server.IdentifiedUser;
 import com.google.gerrit.server.IdentifiedUser.GenericFactory;
 import com.google.inject.Inject;
@@ -33,7 +33,7 @@
 
   Optional<IdentifiedUser> getIdentifiedUser(String key) {
     return isNumeric(key)
-        ? Optional.ofNullable(userFactory.create(new Account.Id(Integer.parseInt(key))))
+        ? Optional.ofNullable(userFactory.create(Account.id(Integer.parseInt(key))))
         : Optional.empty();
   }
 
diff --git a/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/ConfigurationTest.java b/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/ConfigurationTest.java
index 4f8d1a1..cc353a5 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/ConfigurationTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/ConfigurationTest.java
@@ -19,7 +19,7 @@
 import static org.mockito.Mockito.when;
 
 import com.google.gerrit.common.data.GroupDescription;
-import com.google.gerrit.reviewdb.client.AccountGroup;
+import com.google.gerrit.entities.AccountGroup;
 import com.google.gerrit.server.config.PluginConfigFactory;
 import com.google.gerrit.server.group.GroupResolver;
 import com.google.inject.ProvisionException;
@@ -51,12 +51,11 @@
 
     when(pluginConfigFactoryMock.getGlobalPluginConfig(PLUGIN_NAME)).thenReturn(globalPluginConfig);
 
-    when(administratorsGroupDescMock.getGroupUUID())
-        .thenReturn(new AccountGroup.UUID("admin_uuid"));
+    when(administratorsGroupDescMock.getGroupUUID()).thenReturn(AccountGroup.uuid("admin_uuid"));
     when(groupsCollectionMock.parseId("Administrators")).thenReturn(administratorsGroupDescMock);
 
     when(someGroupDescMock.getName()).thenReturn("someGroup");
-    when(someGroupDescMock.getGroupUUID()).thenReturn(new AccountGroup.UUID("some_uuid"));
+    when(someGroupDescMock.getGroupUUID()).thenReturn(AccountGroup.uuid("some_uuid"));
     when(groupsCollectionMock.parseId("someGroup")).thenReturn(someGroupDescMock);
   }
 
diff --git a/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/RateLimitUploadPackIT.java b/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/RateLimitUploadPackIT.java
index 2db0fc5..4c73d22 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/RateLimitUploadPackIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/ratelimiter/RateLimitUploadPackIT.java
@@ -14,14 +14,16 @@
 
 package com.googlesource.gerrit.plugins.ratelimiter;
 
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
+
 import com.google.gerrit.acceptance.GlobalPluginConfig;
 import com.google.gerrit.acceptance.LightweightPluginDaemonTest;
 import com.google.gerrit.acceptance.TestPlugin;
 import com.google.gerrit.acceptance.UseLocalDisk;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.extensions.api.groups.GroupInput;
 import com.google.gerrit.extensions.api.projects.ProjectInput;
 import com.google.gerrit.extensions.restapi.RestApiException;
-import com.google.gerrit.reviewdb.client.Project;
 import org.eclipse.jgit.api.errors.TransportException;
 import org.junit.Test;
 
@@ -55,9 +57,8 @@
     createProjectWithChange(projectA);
     createProjectWithChange(projectB);
 
-    cloneProject(new Project.NameKey(projectA), user);
-    exception.expect(TransportException.class);
-    cloneProject(new Project.NameKey(projectB), user);
+    cloneProject(Project.nameKey(projectA), user);
+    assertThrows(TransportException.class, () -> cloneProject(Project.nameKey(projectB), user));
   }
 
   @Test
@@ -81,9 +82,9 @@
     createProjectWithChange(projectA);
     createProjectWithChange(projectB);
 
-    cloneProject(new Project.NameKey(projectA), user);
+    cloneProject(Project.nameKey(projectA), user);
     Thread.sleep(PeriodicRateLimiter.DEFAULT_TIME_LAPSE_IN_MINUTES * 1000);
-    cloneProject(new Project.NameKey(projectB), user);
+    cloneProject(Project.nameKey(projectB), user);
   }
 
   private void addUserToNewGroup() throws RestApiException {