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