Merge branch 'stable-3.0' into stable-3.1

* stable-3.0:
  DeletePreconditionsTest: Replace ExpectedException with assertThrows
  Bump Bazel version to 2.0.0
  Upgrade bazlets to latest stable-2.16 to build with 2.16.15 API
  Upgrade bazlets to latest stable-2.16 to build with 2.16.14 API

Change-Id: I338e043593dabd0626086827cecdfad91b06feb9
diff --git a/src/test/java/com/googlesource/gerrit/plugins/deleteproject/DeletePreconditionsTest.java b/src/test/java/com/googlesource/gerrit/plugins/deleteproject/DeletePreconditionsTest.java
index 12e0b64..235dc3c 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/deleteproject/DeletePreconditionsTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/deleteproject/DeletePreconditionsTest.java
@@ -15,6 +15,7 @@
 package com.googlesource.gerrit.plugins.deleteproject;
 
 import static com.google.common.truth.Truth.assertThat;
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static com.googlesource.gerrit.plugins.deleteproject.DeleteOwnProjectCapability.DELETE_OWN_PROJECT;
 import static com.googlesource.gerrit.plugins.deleteproject.DeleteProjectCapability.DELETE_PROJECT;
 import static org.mockito.Mockito.doNothing;
@@ -44,9 +45,7 @@
 import com.google.gerrit.server.submit.SubmoduleOp;
 import com.google.inject.Provider;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
@@ -69,8 +68,6 @@
   @Mock private PermissionBackend permissionBackend;
   @Mock private PermissionBackend.WithUser userPermission;
 
-  @Rule public ExpectedException expectedException = ExpectedException.none();
-
   private ProjectResource rsrc;
   private DeletePreconditions preConditions;
 
@@ -122,16 +119,17 @@
   @Test
   public void testUserCannotDelete() throws Exception {
     when(permissionBackend.user(currentUser)).thenReturn(userPermission);
-    expectedException.expect(AuthException.class);
-    expectedException.expectMessage("not allowed to delete project");
-    preConditions.assertDeletePermission(rsrc);
+    AuthException thrown =
+        assertThrows(AuthException.class, () -> preConditions.assertDeletePermission(rsrc));
+    assertThat(thrown).hasMessageThat().contains("not allowed to delete project");
   }
 
   @Test
   public void testIsProtectedSoCannotBeDeleted() throws Exception {
     doThrow(CannotDeleteProjectException.class).when(protectedProjects).assertIsNotProtected(rsrc);
-    expectedException.expect(ResourceConflictException.class);
-    preConditions.assertCanBeDeleted(rsrc, new DeleteProject.Input());
+    assertThrows(
+        ResourceConflictException.class,
+        () -> preConditions.assertCanBeDeleted(rsrc, new DeleteProject.Input()));
   }
 
   @Test
@@ -141,9 +139,13 @@
     when(listChildProjectsProvider.get()).thenReturn(childProjects);
     when(childProjects.withLimit(1)).thenReturn(childProjects);
     when(childProjects.apply(rsrc)).thenReturn(Response.ok(ImmutableList.of(new ProjectInfo())));
-    expectedException.expect(ResourceConflictException.class);
-    expectedException.expectMessage("Cannot delete project because it has at least one child:");
-    preConditions.assertCanBeDeleted(rsrc, new DeleteProject.Input());
+    ResourceConflictException thrown =
+        assertThrows(
+            ResourceConflictException.class,
+            () -> preConditions.assertCanBeDeleted(rsrc, new DeleteProject.Input()));
+    assertThat(thrown)
+        .hasMessageThat()
+        .contains("Cannot delete project because it has at least one child:");
   }
 
   @Test
@@ -153,9 +155,11 @@
     when(queryChange.byProjectOpen(PROJECT_NAMEKEY)).thenReturn(ImmutableList.of(cd));
     when(queryProvider.get()).thenReturn(queryChange);
     String expectedMessage = String.format("Project '%s' has open changes.", PROJECT_NAMEKEY.get());
-    expectedException.expectMessage(expectedMessage);
-    expectedException.expect(CannotDeleteProjectException.class);
-    preConditions.assertHasOpenChanges(PROJECT_NAMEKEY, false);
+    CannotDeleteProjectException thrown =
+        assertThrows(
+            CannotDeleteProjectException.class,
+            () -> preConditions.assertHasOpenChanges(PROJECT_NAMEKEY, false));
+    assertThat(thrown).hasMessageThat().contains(expectedMessage);
   }
 
   @Test
@@ -165,8 +169,10 @@
     when(queryProvider.get()).thenReturn(queryChange);
     String expectedMessage =
         String.format("Unable to verify if '%s' has open changes.", PROJECT_NAMEKEY.get());
-    expectedException.expectMessage(expectedMessage);
-    expectedException.expect(CannotDeleteProjectException.class);
-    preConditions.assertHasOpenChanges(PROJECT_NAMEKEY, false);
+    CannotDeleteProjectException thrown =
+        assertThrows(
+            CannotDeleteProjectException.class,
+            () -> preConditions.assertHasOpenChanges(PROJECT_NAMEKEY, false));
+    assertThat(thrown).hasMessageThat().contains(expectedMessage);
   }
 }