summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacek Centkowski <geminica.programs@gmail.com>2021-03-02 14:55:56 +0100
committerJacek Centkowski <geminica.programs@gmail.com>2021-03-03 13:31:28 +0100
commitcda59e51e052667c917f7410d25a99f7a458dc18 (patch)
tree28367e013b88d0a305906c3b972ea9b20f8ad4b7
parentc99414ab4bed8b028d59b355d329d57b59bc6588 (diff)
RepositorySizeQuotaIT: change try/catch to assertThrows
It offers the same functionality with less boilerplate code. Change-Id: If5e4876e8bb21a40da28fe977ea0227022bbf32e
-rw-r--r--javatests/com/google/gerrit/acceptance/server/quota/RepositorySizeQuotaIT.java25
1 files changed, 8 insertions, 17 deletions
diff --git a/javatests/com/google/gerrit/acceptance/server/quota/RepositorySizeQuotaIT.java b/javatests/com/google/gerrit/acceptance/server/quota/RepositorySizeQuotaIT.java
index 018b4e608c..24c90fce32 100644
--- a/javatests/com/google/gerrit/acceptance/server/quota/RepositorySizeQuotaIT.java
+++ b/javatests/com/google/gerrit/acceptance/server/quota/RepositorySizeQuotaIT.java
@@ -15,9 +15,9 @@
package com.google.gerrit.acceptance.server.quota;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.common.truth.Truth.assert_;
import static com.google.gerrit.server.quota.QuotaGroupDefinitions.REPOSITORY_SIZE_GROUP;
import static com.google.gerrit.server.quota.QuotaResponse.ok;
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
import static org.easymock.EasyMock.anyLong;
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
@@ -98,16 +98,10 @@ public class RepositorySizeQuotaIT extends AbstractDaemonTest {
expect(quotaBackendWithUser.project(project)).andReturn(quotaBackendWithResource).anyTimes();
replay(quotaBackendWithResource);
replay(quotaBackendWithUser);
- try {
- pushCommit();
- assert_().fail("expected TooLargeObjectInPackException");
- } catch (TooLargePackException e) {
- String msg = e.getMessage();
- assertThat(msg)
- .contains(
- String.format(
- "Pack exceeds the limit of %d bytes, rejecting the pack", availableTokens));
- }
+ assertThat(assertThrows(TooLargePackException.class, () -> pushCommit()).getMessage())
+ .contains(
+ String.format(
+ "Pack exceeds the limit of %d bytes, rejecting the pack", availableTokens));
verify(quotaBackendWithUser);
verify(quotaBackendWithResource);
}
@@ -121,12 +115,9 @@ public class RepositorySizeQuotaIT extends AbstractDaemonTest {
expect(quotaBackendWithUser.project(project)).andReturn(quotaBackendWithResource).anyTimes();
replay(quotaBackendWithResource);
replay(quotaBackendWithUser);
- try {
- pushCommit();
- assert_().fail("expected TransportException");
- } catch (TransportException e) {
- // TransportException has not much info about the cause
- }
+
+ assertThrows(TransportException.class, () -> pushCommit());
+
verify(quotaBackendWithUser);
verify(quotaBackendWithResource);
}