Merge branch 'stable-3.0' into stable-3.1
* stable-3.0:
Bump Bazel version to 3.0.0
Upgrade bazlets to latest stable-2.16 to build with 2.16.17 API
Upgrade bazlets to latest stable-2.16
Change-Id: I7a9d754bc6d4834315d5fe4d728cfa36e26ac926
diff --git a/BUILD b/BUILD
index 1af4ac5..35d676e 100644
--- a/BUILD
+++ b/BUILD
@@ -23,21 +23,8 @@
junit_tests(
name = "webhooks_tests",
srcs = glob(["src/test/java/**/*.java"]),
- tags = [
- "local",
- "webhooks",
- ],
- deps = [
- ":webhooks__plugin_test_deps",
- ],
-)
-
-java_library(
- name = "webhooks__plugin_test_deps",
- testonly = 1,
- visibility = ["//visibility:public"],
- exports = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
+ tags = ["webhooks"],
+ deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
":webhooks__plugin",
- "@mockito//jar",
],
)
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/PostTask.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/PostTask.java
index 90c03b9..354bdf8 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/PostTask.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/PostTask.java
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.util.Optional;
import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLException;
@@ -62,7 +63,9 @@
}
private void reschedule() {
- executor.schedule(this, remote.getRetryInterval(), TimeUnit.MILLISECONDS);
+ @SuppressWarnings("unused")
+ ScheduledFuture<?> ignored =
+ executor.schedule(this, remote.getRetryInterval(), TimeUnit.MILLISECONDS);
}
@Override
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/WebhooksConfig.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/WebhooksConfig.java
index 56db3f6..e46b308 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/WebhooksConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/WebhooksConfig.java
@@ -26,7 +26,7 @@
import static com.googlesource.gerrit.plugins.webhooks.RemoteConfig.SSL_VERIFY;
import com.google.common.base.Strings;
-import com.google.gerrit.reviewdb.client.RefNames;
+import com.google.gerrit.entities.RefNames;
import com.google.gerrit.server.git.meta.VersionedMetaData;
import com.google.inject.Inject;
import com.googlesource.gerrit.plugins.webhooks.rest.UpsertRemote;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/DeleteRemote.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/DeleteRemote.java
index 7bb1470..408b092 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/DeleteRemote.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/DeleteRemote.java
@@ -48,7 +48,7 @@
}
@Override
- public Object apply(RemoteResource rsrc, Input input)
+ public Response<?> apply(RemoteResource rsrc, Input input)
throws RepositoryNotFoundException, IOException, ConfigInvalidException, AuthException {
if (!permissions.canUpdate(rsrc.getProject())) {
throw new AuthException("not allowed to update webhooks");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/GetRemote.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/GetRemote.java
index 5e1a8bf..27e07ef 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/GetRemote.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/GetRemote.java
@@ -16,6 +16,7 @@
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
+import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.project.NoSuchProjectException;
import com.google.inject.Inject;
@@ -34,12 +35,12 @@
}
@Override
- public RemoteInfo apply(RemoteResource rsrc)
+ public Response<RemoteInfo> apply(RemoteResource rsrc)
throws NoSuchProjectException, ResourceNotFoundException, AuthException {
if (!permissions.canRead(rsrc.getProject())) {
throw new AuthException("not allowed to read webhooks");
}
- return fromRemoteConfig(rsrc.getRemoteConfig());
+ return Response.ok(fromRemoteConfig(rsrc.getRemoteConfig()));
}
static RemoteInfo fromRemoteConfig(RemoteConfig rc) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ListRemotes.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ListRemotes.java
index c1b5416..50d76e7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ListRemotes.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ListRemotes.java
@@ -18,6 +18,7 @@
import static com.googlesource.gerrit.plugins.webhooks.rest.GetRemote.fromRemoteConfig;
import com.google.gerrit.extensions.annotations.PluginName;
+import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.gerrit.server.project.NoSuchProjectException;
@@ -46,7 +47,7 @@
}
@Override
- public Map<String, RemoteInfo> apply(ProjectWebhooksResource resource)
+ public Response<Map<String, RemoteInfo>> apply(ProjectWebhooksResource resource)
throws NoSuchProjectException {
Map<String, RemoteInfo> remotes = new HashMap<>();
Config cfg =
@@ -54,6 +55,6 @@
for (String name : cfg.getSubsections(REMOTE)) {
remotes.put(name, fromRemoteConfig(remoteFactory.create(cfg, name)));
}
- return remotes;
+ return Response.ok(remotes);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/Permissions.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/Permissions.java
index 6f71ca1..bdceaaf 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/Permissions.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/Permissions.java
@@ -14,7 +14,7 @@
package com.googlesource.gerrit.plugins.webhooks.rest;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
public interface Permissions {
boolean canRead(Project.NameKey project);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/PermissionsImpl.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/PermissionsImpl.java
index 6d438ed..f512404 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/PermissionsImpl.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/PermissionsImpl.java
@@ -14,10 +14,10 @@
package com.googlesource.gerrit.plugins.webhooks.rest;
-import static com.google.gerrit.reviewdb.client.RefNames.REFS_CONFIG;
+import static com.google.gerrit.entities.RefNames.REFS_CONFIG;
-import com.google.gerrit.reviewdb.client.Branch;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.BranchNameKey;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.RefPermission;
@@ -50,7 +50,7 @@
private boolean can(Project.NameKey project, RefPermission permission) {
return permissionBackend
.user(currentUser.get())
- .ref(Branch.nameKey(project, REFS_CONFIG))
+ .ref(BranchNameKey.create(project, REFS_CONFIG))
.testOrFalse(permission);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ProjectWebhooksResource.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ProjectWebhooksResource.java
index ef7ea91..d27649d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ProjectWebhooksResource.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ProjectWebhooksResource.java
@@ -14,9 +14,9 @@
package com.googlesource.gerrit.plugins.webhooks.rest;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.restapi.RestResource;
import com.google.gerrit.extensions.restapi.RestView;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.inject.TypeLiteral;
public class ProjectWebhooksResource implements RestResource {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ProjectsCollection.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ProjectsCollection.java
index 0817969..a31f99c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ProjectsCollection.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ProjectsCollection.java
@@ -14,13 +14,13 @@
package com.googlesource.gerrit.plugins.webhooks.rest;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.restapi.ChildCollection;
import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestView;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.config.ConfigResource;
import com.google.gerrit.server.project.ProjectCache;
import com.google.inject.Inject;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/RemoteResource.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/RemoteResource.java
index 916b734..92b1aa0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/RemoteResource.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/RemoteResource.java
@@ -14,9 +14,9 @@
package com.googlesource.gerrit.plugins.webhooks.rest;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.restapi.RestResource;
import com.google.gerrit.extensions.restapi.RestView;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.inject.TypeLiteral;
import com.googlesource.gerrit.plugins.webhooks.RemoteConfig;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/UpsertRemote.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/UpsertRemote.java
index 41eedae..56d2836 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/UpsertRemote.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/UpsertRemote.java
@@ -17,12 +17,13 @@
import static com.googlesource.gerrit.plugins.webhooks.rest.GetRemote.fromRemoteConfig;
import com.google.common.base.Strings;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.IdString;
+import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestCollectionCreateView;
import com.google.gerrit.extensions.restapi.RestModifyView;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.gerrit.server.git.meta.MetaDataUpdate;
import com.google.gerrit.server.project.NoSuchProjectException;
@@ -59,10 +60,10 @@
}
@Override
- public RemoteInfo apply(RemoteResource rsrc, UpsertRemote.Input in)
+ public Response<RemoteInfo> apply(RemoteResource rsrc, UpsertRemote.Input in)
throws ConfigInvalidException, RepositoryNotFoundException, IOException,
NoSuchProjectException, AuthException {
- return upserter.upsert(rsrc.getProject(), rsrc.getRemoteConfig().getName(), in);
+ return Response.ok(upserter.upsert(rsrc.getProject(), rsrc.getRemoteConfig().getName(), in));
}
}
@@ -78,11 +79,11 @@
}
@Override
- public RemoteInfo apply(
+ public Response<RemoteInfo> apply(
ProjectWebhooksResource rsrc, IdString remoteName, UpsertRemote.Input in)
throws RepositoryNotFoundException, IOException, ConfigInvalidException,
NoSuchProjectException, AuthException {
- return upserter.upsert(rsrc.getProject(), remoteName.get(), in);
+ return Response.created(upserter.upsert(rsrc.getProject(), remoteName.get(), in));
}
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/webhooks/EventHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/webhooks/EventHandlerTest.java
index 404402a..8fd1e9e 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/webhooks/EventHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/webhooks/EventHandlerTest.java
@@ -21,7 +21,7 @@
import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableSet;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.gerrit.server.events.Event;
import com.google.gerrit.server.events.ProjectCreatedEvent;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/webhooks/PostTaskTest.java b/src/test/java/com/googlesource/gerrit/plugins/webhooks/PostTaskTest.java
index 40bf6eb..fddcfb6 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/webhooks/PostTaskTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/webhooks/PostTaskTest.java
@@ -20,7 +20,7 @@
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.server.events.ProjectCreatedEvent;
import com.googlesource.gerrit.plugins.webhooks.HttpResponseHandler.HttpResult;
import java.io.IOException;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/webhooks/processors/AbstractEventProcessorTest.java b/src/test/java/com/googlesource/gerrit/plugins/webhooks/processors/AbstractEventProcessorTest.java
index 807f7b0..2c8e9c4 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/webhooks/processors/AbstractEventProcessorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/webhooks/processors/AbstractEventProcessorTest.java
@@ -17,7 +17,7 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.when;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.server.events.ProjectCreatedEvent;
import com.google.gerrit.server.events.ProjectEvent;
import com.google.gerrit.server.events.RefUpdatedEvent;
@@ -84,7 +84,7 @@
assertThat(actual).isFalse();
}
- private class TestEventProcessor extends AbstractEventProcessor {
+ private static class TestEventProcessor extends AbstractEventProcessor {
@Override
public Optional<EventProcessor.Request> doProcess(ProjectEvent event, RemoteConfig config) {
// do nothing
diff --git a/src/test/java/com/googlesource/gerrit/plugins/webhooks/rest/GetRemoteIT.java b/src/test/java/com/googlesource/gerrit/plugins/webhooks/rest/GetRemoteIT.java
index 0f934d0..585fda6 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/webhooks/rest/GetRemoteIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/webhooks/rest/GetRemoteIT.java
@@ -15,7 +15,7 @@
package com.googlesource.gerrit.plugins.webhooks.rest;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.gerrit.reviewdb.client.RefNames.REFS_CONFIG;
+import static com.google.gerrit.entities.RefNames.REFS_CONFIG;
import static com.googlesource.gerrit.plugins.webhooks.Configuration.DEFAULT_MAX_TRIES;
import static com.googlesource.gerrit.plugins.webhooks.Configuration.DEFAULT_RETRY_INTERVAL;
import static com.googlesource.gerrit.plugins.webhooks.Configuration.DEFAULT_SSL_VERIFY;