RequestScopeOperationsImplTest: Migrate from try-catch-fail to assertThrows
Change-Id: Ia74e25bb38178b643fd12d4f6cc13b09d0d0f6ef
This commit is contained in:
@@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user