RequestScopeOperationsImplTest: Migrate from try-catch-fail to assertThrows

Change-Id: Ia74e25bb38178b643fd12d4f6cc13b09d0d0f6ef
This commit is contained in:
David Pursehouse
2019-05-22 19:10:14 +09:00
parent 3a6ace8043
commit 53e8618bdd

View File

@@ -16,8 +16,8 @@ package com.google.gerrit.acceptance.testsuite.request;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth.assert_;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.gerrit.testing.GerritJUnit.assertThrows;
import com.google.common.collect.ImmutableSet;
import com.google.gerrit.acceptance.AbstractDaemonTest;
@@ -68,12 +68,9 @@ public class RequestScopeOperationsImplTest extends AbstractDaemonTest {
@Test
public void setApiUserToNonExistingUser() throws Exception {
fastCheckCurrentUser(admin.id());
try {
requestScopeOperations.setApiUser(Account.id(sequences.nextAccountId()));
assert_().fail("expected RuntimeException");
} catch (RuntimeException e) {
// Expected.
}
assertThrows(
RuntimeException.class,
() -> requestScopeOperations.setApiUser(Account.id(sequences.nextAccountId())));
checkCurrentUser(admin.id());
}