Merge branch 'stable-3.0'

* stable-3.0:
  Upgrade bazlets to latest stable-2.16 to build with 2.16.17 API
  Upgrade bazlets to latest stable-3.0 to build with 3.0.8 API

Change-Id: I3eae1de6b9a5fbe6de2dac54f5825d4b9a4a8700
diff --git a/BUILD b/BUILD
index 2885dda..3ebfd66 100644
--- a/BUILD
+++ b/BUILD
@@ -14,7 +14,6 @@
 ]
 
 EXECUTOR_DEPS = CONDUCTOR_DEPS + [
-    "@jgit//jar",
     "@javaewah//jar",
     "@guava//jar",
     "@guava-failureaccess//jar",
@@ -28,6 +27,7 @@
     "@log4j-api//jar",
     "@log4j-core//jar",
     "@retry//jar",
+    "//lib:jgit",
 ]
 
 gerrit_plugin(
diff --git a/WORKSPACE b/WORKSPACE
index 26f5ced..523fb80 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
 load("//:bazlets.bzl", "load_bazlets")
 
 load_bazlets(
-    commit = "97eef86854b0fb68b9287831f3075b6f6218ff41",
+    commit = "2add9fecf8bec8634bddf354815bd0fa93f58dd5",
     #local_path = "/home/<user>/projects/bazlets",
 )
 
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
index 9ba9532..52ac094 100644
--- a/external_plugin_deps.bzl
+++ b/external_plugin_deps.bzl
@@ -100,8 +100,8 @@
     maven_jar(
         name = "jgit",
         artifact =
-            "org.eclipse.jgit:org.eclipse.jgit:5.3.6.201910020505-r",
-        sha1 = "0b9085bd16c630412bfa50bcc509dcedfbbe16d3",
+            "org.eclipse.jgit:org.eclipse.jgit:5.5.1.201910021850-r",
+        sha1 = "e0ba7a468e8c62da8521ca3a06a061d4dde95223",
     )
 
     maven_jar(
diff --git a/lib/BUILD b/lib/BUILD
new file mode 100644
index 0000000..dd99fbc
--- /dev/null
+++ b/lib/BUILD
@@ -0,0 +1,7 @@
+load("@rules_java//java:defs.bzl", "java_library")
+
+java_library(
+    name = "jgit",
+    visibility = ["//visibility:public"],
+    exports = ["@jgit//jar"],
+)
diff --git a/src/main/java/com/ericsson/gerrit/plugins/gcconductor/command/AddToQueue.java b/src/main/java/com/ericsson/gerrit/plugins/gcconductor/command/AddToQueue.java
index d9fe107..25939a2 100644
--- a/src/main/java/com/ericsson/gerrit/plugins/gcconductor/command/AddToQueue.java
+++ b/src/main/java/com/ericsson/gerrit/plugins/gcconductor/command/AddToQueue.java
@@ -20,8 +20,8 @@
 import com.ericsson.gerrit.plugins.gcconductor.GcQueueException;
 import com.ericsson.gerrit.plugins.gcconductor.Hostname;
 import com.google.gerrit.common.data.GlobalCapability;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.extensions.annotations.RequiresCapability;
-import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.git.GitRepositoryManager;
 import com.google.gerrit.server.git.LocalDiskRepositoryManager;
 import com.google.gerrit.server.project.ProjectCache;
@@ -85,7 +85,7 @@
       throw die("Unable to resolve path to " + repository);
     }
     String projectName = extractFrom(repository);
-    Project.NameKey nameKey = new Project.NameKey(projectName);
+    Project.NameKey nameKey = Project.nameKey(projectName);
     if (projectCache.get(nameKey) == null) {
       throw die(String.format("Repository %s not found", repository));
     }
diff --git a/src/main/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/Evaluator.java b/src/main/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/Evaluator.java
index 5ae7fac..037d11d 100644
--- a/src/main/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/Evaluator.java
+++ b/src/main/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/Evaluator.java
@@ -18,8 +18,8 @@
 import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.MoreExecutors;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
-import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.config.GerritServerConfig;
 import com.google.gerrit.server.git.GitRepositoryManager;
 import com.google.gerrit.server.git.validators.UploadValidationListener;
@@ -109,7 +109,7 @@
   @Override
   public void onGitReferenceUpdated(Event event) {
     String projectName = event.getProjectName();
-    Project.NameKey projectNameKey = new Project.NameKey(projectName);
+    Project.NameKey projectNameKey = Project.nameKey(projectName);
     try (Repository repository = repoManager.openRepository(projectNameKey)) {
       String repositoryPath = repository.getDirectory().getAbsolutePath();
       queueEvaluationIfNecessary(repositoryPath);
diff --git a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/EvaluatorTest.java b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/EvaluatorTest.java
index 7dc403b..b503259 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/EvaluatorTest.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/evaluator/EvaluatorTest.java
@@ -23,8 +23,8 @@
 
 import com.ericsson.gerrit.plugins.gcconductor.EvaluationTask;
 import com.ericsson.gerrit.plugins.gcconductor.EvaluationTask.Factory;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
-import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.git.GitRepositoryManager;
 import java.io.File;
 import java.io.IOException;
@@ -43,7 +43,7 @@
 public class EvaluatorTest {
   private static final String REPOSITORY_PATH = "/path/someRepo.git";
   private static final String REPOSITORY_PATH_OTHER = "/path/otherRepo.git";
-  private static final Project.NameKey NAME_KEY = new Project.NameKey("testProject");
+  private static final Project.NameKey NAME_KEY = Project.nameKey("testProject");
 
   @Mock private GitReferenceUpdatedListener.Event event;
   @Mock private GitRepositoryManager repoManager;
diff --git a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ConfigUtilTest.java b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ConfigUtilTest.java
index c99201a..1485d72 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ConfigUtilTest.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ConfigUtilTest.java
@@ -15,6 +15,7 @@
 package com.ericsson.gerrit.plugins.gcconductor.executor;
 
 import static com.google.common.truth.Truth.assertThat;
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static java.util.concurrent.TimeUnit.DAYS;
 import static java.util.concurrent.TimeUnit.HOURS;
 import static java.util.concurrent.TimeUnit.MILLISECONDS;
@@ -52,22 +53,24 @@
         .isEqualTo(DEFAULT_VALUE);
   }
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void testGetTimeThrowsExceptionIfNegativeValue() {
     when(config.getString("", null, "")).thenReturn("-1");
-    assertThat(ConfigUtil.getTimeUnit(config, "", "", DEFAULT_VALUE, DAYS))
-        .isEqualTo(DEFAULT_VALUE);
+    assertThrows(
+        IllegalArgumentException.class,
+        () -> ConfigUtil.getTimeUnit(config, "", "", DEFAULT_VALUE, DAYS));
 
     when(config.getString("", null, "")).thenReturn("");
     assertThat(ConfigUtil.getTimeUnit(config, "", "", DEFAULT_VALUE, DAYS))
         .isEqualTo(DEFAULT_VALUE);
   }
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void testGetTimeThrowsExceptionIfBadTimeUnit() {
     when(config.getString("", null, "")).thenReturn("1s");
-    assertThat(ConfigUtil.getTimeUnit(config, "", "", DEFAULT_VALUE, DAYS))
-        .isEqualTo(DEFAULT_VALUE);
+    assertThrows(
+        IllegalArgumentException.class,
+        () -> ConfigUtil.getTimeUnit(config, "", "", DEFAULT_VALUE, DAYS));
   }
 
   @Test
@@ -99,9 +102,9 @@
     assertEquals(ms(1, MILLISECONDS), parse(""));
   }
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void testUnsupportedTimeUnit() {
-    parse("1 min");
+    assertThrows(IllegalArgumentException.class, () -> parse("1 min"));
   }
 
   private static long ms(int cnt, TimeUnit unit) {
diff --git a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ExecutorModuleTest.java b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ExecutorModuleTest.java
index f4d3cef..3e88f2b 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ExecutorModuleTest.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ExecutorModuleTest.java
@@ -15,7 +15,7 @@
 package com.ericsson.gerrit.plugins.gcconductor.executor;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static com.google.common.truth.Truth8.assertThat;
 import static org.mockito.Mockito.when;
 
 import com.google.inject.Binder;
@@ -45,9 +45,7 @@
     String host = "hostname";
     when(execCfg.isPickOwnHostOnly()).thenReturn(true);
     Optional<String> wasQueuedFrom = executorModule.wasQueuedFrom(execCfg, host);
-    if (!wasQueuedFrom.isPresent()) {
-      fail("wasQueued from is empty");
-    }
+    assertThat(wasQueuedFrom).isPresent();
     assertThat(wasQueuedFrom.get()).isEqualTo(host);
 
     when(execCfg.isPickOwnHostOnly()).thenReturn(false);
diff --git a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ScheduledEvaluationTaskTest.java b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ScheduledEvaluationTaskTest.java
index c560fbf..302c4c8 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ScheduledEvaluationTaskTest.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/executor/ScheduledEvaluationTaskTest.java
@@ -14,6 +14,7 @@
 
 package com.ericsson.gerrit.plugins.gcconductor.executor;
 
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
@@ -50,10 +51,12 @@
     periodicEvaluator = new ScheduledEvaluationTask(evaluationTaskFactory, config);
   }
 
-  @Test(expected = ProvisionException.class)
-  public void shouldThrowAnExceptionOnInvalidrepositoryPath() {
+  @Test
+  public void shouldThrowAnExceptionOnInvalidrepositoryPath() throws Exception {
     when(config.getRepositoriesPath()).thenReturn("unexistingPath");
-    periodicEvaluator = new ScheduledEvaluationTask(evaluationTaskFactory, config);
+    assertThrows(
+        ProvisionException.class,
+        () -> periodicEvaluator = new ScheduledEvaluationTask(evaluationTaskFactory, config));
   }
 
   @Test
diff --git a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresModuleTest.java b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresModuleTest.java
index 5df97d0..7721b8c 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresModuleTest.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresModuleTest.java
@@ -18,6 +18,7 @@
 import static com.ericsson.gerrit.plugins.gcconductor.postgresqueue.TestUtil.invalidConfigMockFor;
 import static com.ericsson.gerrit.plugins.gcconductor.postgresqueue.TestUtil.newContainer;
 import static com.google.common.truth.Truth.assertThat;
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
 
@@ -73,9 +74,10 @@
     assertThat(dataSource.isClosed()).isFalse();
   }
 
-  @Test(expected = SQLException.class)
-  public void shouldFailIfDatabaseNameIsInvalid() throws SQLException {
-    module.provideGcDatabaseAccess(invalidConfigMockFor(container));
+  @Test
+  public void shouldFailIfDatabaseNameIsInvalid() throws Exception {
+    assertThrows(
+        SQLException.class, () -> module.provideGcDatabaseAccess(invalidConfigMockFor(container)));
   }
 
   @Test
@@ -87,11 +89,11 @@
     assertThat(dataSource.isClosed()).isTrue();
   }
 
-  @Test(expected = RuntimeException.class)
-  public void shouldThrowExceptionIfFailsToCloseDatabaseAccess() throws SQLException {
+  @Test
+  public void shouldThrowExceptionIfFailsToCloseDatabaseAccess() throws Exception {
     BasicDataSource dataSouceMock = mock(BasicDataSource.class);
     doThrow(new SQLException("somme error")).when(dataSouceMock).close();
     DatabaseAccessCleanUp dbCleanUp = new DatabaseAccessCleanUp(dataSouceMock);
-    dbCleanUp.onShutdown();
+    assertThrows(RuntimeException.class, () -> dbCleanUp.onShutdown());
   }
 }
diff --git a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresQueueTest.java b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresQueueTest.java
index b767d04..aab695c 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresQueueTest.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/gcconductor/postgresqueue/PostgresQueueTest.java
@@ -17,7 +17,7 @@
 import static com.ericsson.gerrit.plugins.gcconductor.postgresqueue.TestUtil.configMockFor;
 import static com.ericsson.gerrit.plugins.gcconductor.postgresqueue.TestUtil.newContainer;
 import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -52,33 +52,33 @@
   }
 
   @Before
-  public void setUp() throws SQLException, GcQueueException {
+  public void setUp() throws Exception {
     dataSource = new PostgresModule(null).provideGcDatabaseAccess(configMockFor(container));
     queue = new PostgresQueue(dataSource);
     emptyQueue();
   }
 
   @After
-  public void tearDown() throws SQLException {
+  public void tearDown() throws Exception {
     if (dataSource != null) {
       dataSource.close();
     }
   }
 
   @Test
-  public void shouldCreateSchemaOnInit() throws GcQueueException {
+  public void shouldCreateSchemaOnInit() throws Exception {
     assertThat(queue.list()).isEmpty();
   }
 
-  @Test(expected = SQLException.class)
+  @Test
   public void shouldThrowExceptionIfFailsToCreateSchemaOnInit() throws Exception {
     BasicDataSource dataSouceMock = mock(BasicDataSource.class);
     when(dataSouceMock.getConnection()).thenThrow(new SQLException("some message"));
-    queue = new PostgresQueue(dataSouceMock);
+    assertThrows(SQLException.class, () -> queue = new PostgresQueue(dataSouceMock));
   }
 
   @Test
-  public void testAddContainsAndRemove() throws GcQueueException {
+  public void testAddContainsAndRemove() throws Exception {
     String repoPath = "/some/path/to/some/repository";
     String hostname = "someHostname";
 
@@ -115,68 +115,68 @@
     assertThat(queue.contains(repoPath)).isFalse();
   }
 
-  @Test(expected = GcQueueException.class)
+  @Test
   public void testAddThatFailsWhenGettingConnection() throws Exception {
     queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection());
-    queue.add("repo", "hostname");
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testAddThatFailsWhenCreatingStatement() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
-    queue.add("repo", "hostname");
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testAddThatFailsWhenExecutingQuery() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
-    queue.add("repo", "hostname");
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testContainsThatFailsWhenGettingConnection() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection());
-    queue.contains("repo");
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testContainsThatFailsWhenCreatingStatement() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
-    queue.contains("repo");
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testContainsThatFailsWhenExecutingQuery() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
-    queue.contains("repo");
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testContainsThatFailsWhenIteratingResults() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenIteratingResults());
-    queue.contains("repo");
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testRemoveThatFailsWhenGettingConnection() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection());
-    queue.remove("repo");
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testRemoveThatFailsWhenCreatingStatement() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
-    queue.remove("repo");
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testRemoveThatFailsWhenExecutingQuery() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
-    queue.remove("repo");
+    assertThrows(GcQueueException.class, () -> queue.add("repo", "hostname"));
   }
 
   @Test
-  public void testList() throws GcQueueException {
+  public void testAddThatFailsWhenCreatingStatement() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
+    assertThrows(GcQueueException.class, () -> queue.add("repo", "hostname"));
+  }
+
+  @Test
+  public void testAddThatFailsWhenExecutingQuery() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
+    assertThrows(GcQueueException.class, () -> queue.add("repo", "hostname"));
+  }
+
+  @Test
+  public void testContainsThatFailsWhenGettingConnection() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection());
+    assertThrows(GcQueueException.class, () -> queue.contains("repo"));
+  }
+
+  @Test
+  public void testContainsThatFailsWhenCreatingStatement() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
+    assertThrows(GcQueueException.class, () -> queue.contains("repo"));
+  }
+
+  @Test
+  public void testContainsThatFailsWhenExecutingQuery() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
+    assertThrows(GcQueueException.class, () -> queue.contains("repo"));
+  }
+
+  @Test
+  public void testContainsThatFailsWhenIteratingResults() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenIteratingResults());
+    assertThrows(GcQueueException.class, () -> queue.contains("repo"));
+  }
+
+  @Test
+  public void testRemoveThatFailsWhenGettingConnection() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection());
+    assertThrows(GcQueueException.class, () -> queue.remove("repo"));
+  }
+
+  @Test
+  public void testRemoveThatFailsWhenCreatingStatement() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
+    assertThrows(GcQueueException.class, () -> queue.remove("repo"));
+  }
+
+  @Test
+  public void testRemoveThatFailsWhenExecutingQuery() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
+    assertThrows(GcQueueException.class, () -> queue.remove("repo"));
+  }
+
+  @Test
+  public void testList() throws Exception {
     String repoPath = "/some/path/to/some/repository.git";
     String repoPath2 = "/some/path/to/some/repository2.git";
     String hostname = "hostname";
@@ -208,32 +208,32 @@
     assertThat(timestampDiff).isAtMost(TimeUnit.SECONDS.toMillis(1));
   }
 
-  @Test(expected = GcQueueException.class)
+  @Test
   public void testListThatFailsWhenGettingConnection() throws Exception {
     queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection());
-    queue.list();
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testListThatFailsWhenCreatingStatement() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
-    queue.list();
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testListThatFailsWhenExecutingQuery() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
-    queue.list();
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testListThatFailsWhenIteratingResults() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenIteratingResults());
-    queue.list();
+    assertThrows(GcQueueException.class, () -> queue.list());
   }
 
   @Test
-  public void testPick() throws GcQueueException {
+  public void testListThatFailsWhenCreatingStatement() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
+    assertThrows(GcQueueException.class, () -> queue.list());
+  }
+
+  @Test
+  public void testListThatFailsWhenExecutingQuery() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
+    assertThrows(GcQueueException.class, () -> queue.list());
+  }
+
+  @Test
+  public void testListThatFailsWhenIteratingResults() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenIteratingResults());
+    assertThrows(GcQueueException.class, () -> queue.list());
+  }
+
+  @Test
+  public void testPick() throws Exception {
     String repoPath = "/some/path/to/some/repository";
     String hostname = "someHostname";
     String executor = "someExecutor";
@@ -262,7 +262,7 @@
   }
 
   @Test
-  public void testPickRepositoriesInOrder() throws GcQueueException {
+  public void testPickRepositoriesInOrder() throws Exception {
     String repositoryFormat = "my/path%s.git";
     for (int i = 0; i < 100; i++) {
       queue.add(String.format(repositoryFormat, i), "someHostname");
@@ -275,7 +275,7 @@
   }
 
   @Test
-  public void testPickInQueueForLongerThan() throws GcQueueException, InterruptedException {
+  public void testPickInQueueForLongerThan() throws Exception {
     String repoPath = "/some/path/to/some/repository";
     String hostname = "someHostname";
     String executor = "someExecutor";
@@ -293,7 +293,7 @@
   }
 
   @Test
-  public void testPickQueuedFrom() throws GcQueueException {
+  public void testPickQueuedFrom() throws Exception {
     String repoPath = "/some/path/to/some/repository";
     String hostname = "hostname";
     String otherHostname = "otherHostname";
@@ -310,32 +310,32 @@
     assertThat(picked.getExecutor()).isEqualTo(executor);
   }
 
-  @Test(expected = GcQueueException.class)
+  @Test
   public void testPickThatFailsWhenGettingConnection() throws Exception {
     queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection());
-    queue.pick("executor", 0, Optional.empty());
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testPickThatFailsWhenCreatingStatement() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
-    queue.pick("executor", 0, Optional.empty());
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testPickThatFailsWhenExecutingQuery() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
-    queue.pick("executor", 0, Optional.empty());
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testPickThatFailsWhenIteratingResults() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenIteratingResults());
-    queue.pick("executor", 0, Optional.empty());
+    assertThrows(GcQueueException.class, () -> queue.pick("executor", 0, Optional.empty()));
   }
 
   @Test
-  public void testUnpick() throws GcQueueException {
+  public void testPickThatFailsWhenCreatingStatement() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
+    assertThrows(GcQueueException.class, () -> queue.pick("executor", 0, Optional.empty()));
+  }
+
+  @Test
+  public void testPickThatFailsWhenExecutingQuery() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
+    assertThrows(GcQueueException.class, () -> queue.pick("executor", 0, Optional.empty()));
+  }
+
+  @Test
+  public void testPickThatFailsWhenIteratingResults() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenIteratingResults());
+    assertThrows(GcQueueException.class, () -> queue.pick("executor", 0, Optional.empty()));
+  }
+
+  @Test
+  public void testUnpick() throws Exception {
     String repoPath = "/some/path/to/some/repository";
     String hostname = "someHostname";
     String executor = "someExecutor";
@@ -354,26 +354,26 @@
     assertThat(picked.getExecutor()).isEqualTo(executor);
   }
 
-  @Test(expected = GcQueueException.class)
+  @Test
   public void testUnpickThatFailsWhenGettingConnection() throws Exception {
     queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection());
-    queue.unpick("/some/path/to/some/repository.git");
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testUnpickFailsWhenCreatingStatement() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
-    queue.unpick("/some/path/to/some/repository.git");
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testUnpickThatFailsWhenExecutingQuery() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
-    queue.unpick("/some/path/to/some/repository.git");
+    assertThrows(GcQueueException.class, () -> queue.unpick("/some/path/to/some/repository.git"));
   }
 
   @Test
-  public void testResetQueuedFrom() throws GcQueueException {
+  public void testUnpickFailsWhenCreatingStatement() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
+    assertThrows(GcQueueException.class, () -> queue.unpick("/some/path/to/some/repository.git"));
+  }
+
+  @Test
+  public void testUnpickThatFailsWhenExecutingQuery() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
+    assertThrows(GcQueueException.class, () -> queue.unpick("/some/path/to/some/repository.git"));
+  }
+
+  @Test
+  public void testResetQueuedFrom() throws Exception {
     String repoPath = "/some/path/to/some/repository";
     String repoPath2 = "/some/path/to/some/repository2";
     String hostname = "hostname";
@@ -389,26 +389,26 @@
     assertThat(queue.list().get(1).getQueuedFrom()).isEqualTo(otherHostname);
   }
 
-  @Test(expected = GcQueueException.class)
+  @Test
   public void testResetQueuedFromThatFailsWhenGettingConnection() throws Exception {
     queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection());
-    queue.resetQueuedFrom("someHostname");
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testResetQueuedFromFailsWhenCreatingStatement() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
-    queue.resetQueuedFrom("someHostname");
-  }
-
-  @Test(expected = GcQueueException.class)
-  public void testResetQueuedFromThatFailsWhenExecutingQuery() throws Exception {
-    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
-    queue.resetQueuedFrom("someHostname");
+    assertThrows(GcQueueException.class, () -> queue.resetQueuedFrom("someHostname"));
   }
 
   @Test
-  public void testBumpToFirst() throws GcQueueException {
+  public void testResetQueuedFromFailsWhenCreatingStatement() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
+    assertThrows(GcQueueException.class, () -> queue.resetQueuedFrom("someHostname"));
+  }
+
+  @Test
+  public void testResetQueuedFromThatFailsWhenExecutingQuery() throws Exception {
+    queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
+    assertThrows(GcQueueException.class, () -> queue.resetQueuedFrom("someHostname"));
+  }
+
+  @Test
+  public void testBumpToFirst() throws Exception {
     String repoPath = "/some/path/to/some/repository";
     String repoPath2 = "/some/path/to/some/repository2";
     String repoPath3 = "/some/path/to/some/repository3";
@@ -439,25 +439,25 @@
     assertThat(queue.list().get(2).getPath()).isEqualTo(repoPath2);
   }
 
-  @Test(expected = GcQueueException.class)
+  @Test
   public void testBumpToFirstThatFailsWhenGettingConnection() throws Exception {
     queue = new PostgresQueue(createDataSourceThatFailsWhenGettingConnection());
-    queue.bumpToFirst("someHostname");
+    assertThrows(GcQueueException.class, () -> queue.bumpToFirst("someHostname"));
   }
 
-  @Test(expected = GcQueueException.class)
+  @Test
   public void testBumpToFirstFailsWhenCreatingStatement() throws Exception {
     queue = new PostgresQueue(createDataSourceThatFailsWhenCreatingStatement());
-    queue.bumpToFirst("someHostname");
+    assertThrows(GcQueueException.class, () -> queue.bumpToFirst("someHostname"));
   }
 
-  @Test(expected = GcQueueException.class)
+  @Test
   public void testBumpToFirstThatFailsWhenExecutingQuery() throws Exception {
     queue = new PostgresQueue(createDataSourceThatFailsWhenExecutingQuery());
-    queue.bumpToFirst("someHostname");
+    assertThrows(GcQueueException.class, () -> queue.bumpToFirst("someHostname"));
   }
 
-  private BasicDataSource createDataSourceThatFailsWhenGettingConnection() throws SQLException {
+  private BasicDataSource createDataSourceThatFailsWhenGettingConnection() throws Exception {
     BasicDataSource dataSouceMock = mock(BasicDataSource.class);
     Connection connectionMock = mock(Connection.class);
     Statement statementMock = mock(Statement.class);
@@ -468,7 +468,7 @@
     return dataSouceMock;
   }
 
-  private BasicDataSource createDataSourceThatFailsWhenCreatingStatement() throws SQLException {
+  private BasicDataSource createDataSourceThatFailsWhenCreatingStatement() throws Exception {
     BasicDataSource dataSouceMock = mock(BasicDataSource.class);
     Connection connectionMock = mock(Connection.class);
     Statement statementMock = mock(Statement.class);
@@ -479,7 +479,7 @@
     return dataSouceMock;
   }
 
-  private BasicDataSource createDataSourceThatFailsWhenExecutingQuery() throws SQLException {
+  private BasicDataSource createDataSourceThatFailsWhenExecutingQuery() throws Exception {
     BasicDataSource dataSouceMock = mock(BasicDataSource.class);
     Connection connectionMock = mock(Connection.class);
     Statement statementMock = mock(Statement.class);
@@ -492,7 +492,7 @@
     return dataSouceMock;
   }
 
-  private BasicDataSource createDataSourceThatFailsWhenIteratingResults() throws SQLException {
+  private BasicDataSource createDataSourceThatFailsWhenIteratingResults() throws Exception {
     BasicDataSource dataSouceMock = mock(BasicDataSource.class);
     Connection connectionMock = mock(Connection.class);
     Statement statementMock = mock(Statement.class);
@@ -506,17 +506,16 @@
     return dataSouceMock;
   }
 
-  private void emptyQueue() throws GcQueueException {
-    queue.list().stream()
-        .map(RepositoryInfo::getPath)
-        .forEach(
-            repository -> {
-              try {
-                queue.remove(repository);
-              } catch (GcQueueException e) {
-                fail();
-              }
-            });
+  private void emptyQueue() throws Exception {
+    queue.list().stream().map(RepositoryInfo::getPath).forEach(this::doEmptyQueue);
     assertThat(queue.list()).isEmpty();
   }
+
+  private void doEmptyQueue(String repository) {
+    try {
+      queue.remove(repository);
+    } catch (GcQueueException e) {
+      throw new RuntimeException(e);
+    }
+  }
 }