RepositorySizeQuotaIT: change try/catch to assertThrows
It offers the same functionality with less boilerplate code. Change-Id: If5e4876e8bb21a40da28fe977ea0227022bbf32e
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user